Merge PR #118: Philips Hue: Add support for the hue indoor motion sensor
This commit is contained in:
commit
bab355721e
@ -169,7 +169,7 @@ void DevicePluginAnel::init()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginAnel::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginAnel::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(deviceClassId)
|
||||
Q_UNUSED(params)
|
||||
@ -184,7 +184,7 @@ DeviceManager::DeviceError DevicePluginAnel::discoverDevices(const DeviceClassId
|
||||
if (len != discoveryString.length()) {
|
||||
searchSocket->deleteLater();
|
||||
qCWarning(dcAnelElektronik()) << "Error sending discovery";
|
||||
return DeviceManager::DeviceErrorHardwareFailure;
|
||||
return Device::DeviceErrorHardwareFailure;
|
||||
}
|
||||
|
||||
QTimer::singleShot(2000, this, [this, searchSocket, deviceClassId](){
|
||||
@ -233,10 +233,10 @@ DeviceManager::DeviceError DevicePluginAnel::discoverDevices(const DeviceClassId
|
||||
emit devicesDiscovered(deviceClassId, descriptorList);
|
||||
searchSocket->deleteLater();
|
||||
});
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginAnel::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginAnel::setupDevice(Device *device)
|
||||
{
|
||||
if (device->deviceClassId() == netPwrCtlHomeDeviceClassId
|
||||
|| device->deviceClassId() == netPwrCtlProDeviceClassId) {
|
||||
@ -253,11 +253,11 @@ DeviceManager::DeviceSetupStatus DevicePluginAnel::setupDevice(Device *device)
|
||||
m_pollTimer = hardwareManager()->pluginTimerManager()->registerTimer(2);
|
||||
connect(m_pollTimer, &PluginTimer::timeout, this, &DevicePluginAnel::refreshStates);
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
qCWarning(dcAnelElektronik) << "Unhandled DeviceClass in setupDevice" << device->deviceClassId();
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
void DevicePluginAnel::deviceRemoved(Device *device)
|
||||
@ -269,7 +269,7 @@ void DevicePluginAnel::deviceRemoved(Device *device)
|
||||
}
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginAnel::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginAnel::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (device->deviceClassId() == socketDeviceClassId) {
|
||||
if (action.actionTypeId() == socketPowerActionTypeId) {
|
||||
@ -291,15 +291,15 @@ DeviceManager::DeviceError DevicePluginAnel::executeAction(Device *device, const
|
||||
connect(reply, &QNetworkReply::finished, device, [this, reply, action](){
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
qCWarning(dcAnelElektronik()) << "Execute action failed:" << reply->error() << reply->errorString();
|
||||
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorHardwareNotAvailable);
|
||||
emit actionExecutionFinished(action.id(), Device::DeviceErrorHardwareNotAvailable);
|
||||
}
|
||||
qCDebug(dcAnelElektronik()) << "Execute action done.";
|
||||
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(action.id(), Device::DeviceErrorNoError);
|
||||
});
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginAnel::refreshStates()
|
||||
@ -326,7 +326,7 @@ void DevicePluginAnel::setConnectedState(Device *device, bool connected)
|
||||
}
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginAnel::setupHomeProDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginAnel::setupHomeProDevice(Device *device)
|
||||
{
|
||||
QString ipAddress = device->paramValue(m_ipAddressParamTypeIdMap.value(device->deviceClassId())).toString();
|
||||
int port = device->paramValue(m_portParamTypeIdMap.value(device->deviceClassId())).toInt();
|
||||
@ -344,7 +344,7 @@ DeviceManager::DeviceSetupStatus DevicePluginAnel::setupHomeProDevice(Device *de
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
qCWarning(dcAnelElektronik()) << "Error fetching state for" << device->name() << reply->error() << reply->errorString();
|
||||
device->setStateValue(connectedStateTypeId, false);
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
return;
|
||||
}
|
||||
device->setStateValue(connectedStateTypeId, true);
|
||||
@ -356,12 +356,12 @@ DeviceManager::DeviceSetupStatus DevicePluginAnel::setupHomeProDevice(Device *de
|
||||
int startIndex = parts.indexOf("end") - 58;
|
||||
if (startIndex < 0 || !parts.at(startIndex).startsWith("NET-PWRCTRL") || parts.length() < 60) {
|
||||
qCWarning(dcAnelElektronik()) << "Bad data from panel:" << data << "Length:" << parts.length();
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
// At this point we're done with gathering information about the panel. Setup defintely succeeded for the gateway device
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusSuccess);
|
||||
|
||||
// If we haven't set up childs for this gateway yet, let's do it now
|
||||
foreach (Device *child, myDevices()) {
|
||||
@ -390,10 +390,10 @@ DeviceManager::DeviceSetupStatus DevicePluginAnel::setupHomeProDevice(Device *de
|
||||
emit autoDevicesAppeared(socketDeviceClassId, descriptorList);
|
||||
});
|
||||
|
||||
return DeviceManager::DeviceSetupStatusAsync;
|
||||
return Device::DeviceSetupStatusAsync;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginAnel::setupAdvDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginAnel::setupAdvDevice(Device *device)
|
||||
{
|
||||
QString ipAddress = device->paramValue(m_ipAddressParamTypeIdMap.value(device->deviceClassId())).toString();
|
||||
int port = device->paramValue(m_portParamTypeIdMap.value(device->deviceClassId())).toInt();
|
||||
@ -411,7 +411,7 @@ DeviceManager::DeviceSetupStatus DevicePluginAnel::setupAdvDevice(Device *device
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
qCWarning(dcAnelElektronik()) << "Error fetching state for" << device->name() << reply->error() << reply->errorString();
|
||||
device->setStateValue(connectedStateTypeId, false);
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
return;
|
||||
}
|
||||
device->setStateValue(connectedStateTypeId, true);
|
||||
@ -423,12 +423,12 @@ DeviceManager::DeviceSetupStatus DevicePluginAnel::setupAdvDevice(Device *device
|
||||
int startIndex = parts.indexOf("end") - 40;
|
||||
if (startIndex < 0 || parts.length() < 58) {
|
||||
qCWarning(dcAnelElektronik()) << "Bad data from panel:" << data << "Length:" << parts.length();
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
// At this point we're done with gathering information about the panel. Setup defintely succeeded for the gateway device
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusSuccess);
|
||||
|
||||
// If we haven't set up childs for this gateway yet, let's do it now
|
||||
foreach (Device *child, myDevices()) {
|
||||
@ -448,7 +448,7 @@ DeviceManager::DeviceSetupStatus DevicePluginAnel::setupAdvDevice(Device *device
|
||||
emit autoDevicesAppeared(socketDeviceClassId, descriptorList);
|
||||
});
|
||||
|
||||
return DeviceManager::DeviceSetupStatusAsync;
|
||||
return Device::DeviceSetupStatusAsync;
|
||||
}
|
||||
|
||||
void DevicePluginAnel::refreshHomePro(Device *device)
|
||||
|
||||
@ -21,8 +21,7 @@
|
||||
#ifndef DEVICEPLUGINANEL_H
|
||||
#define DEVICEPLUGINANEL_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
#include <QUdpSocket>
|
||||
|
||||
@ -42,10 +41,10 @@ public:
|
||||
~DevicePluginAnel();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private slots:
|
||||
void refreshStates();
|
||||
@ -53,8 +52,8 @@ private slots:
|
||||
private:
|
||||
void setConnectedState(Device *device, bool connected);
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupHomeProDevice(Device *device);
|
||||
DeviceManager::DeviceSetupStatus setupAdvDevice(Device *device);
|
||||
Device::DeviceSetupStatus setupHomeProDevice(Device *device);
|
||||
Device::DeviceSetupStatus setupAdvDevice(Device *device);
|
||||
|
||||
void refreshHomePro(Device *device);
|
||||
void refreshAdv(Device *device);
|
||||
|
||||
@ -23,8 +23,7 @@
|
||||
|
||||
#include "devicepluginavahimonitor.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
#include "platform/platformzeroconfcontroller.h"
|
||||
#include "network/zeroconf/zeroconfservicebrowser.h"
|
||||
@ -39,19 +38,19 @@ DevicePluginAvahiMonitor::DevicePluginAvahiMonitor()
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginAvahiMonitor::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginAvahiMonitor::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcAvahiMonitor()) << "Setup" << device->name() << device->params();
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginAvahiMonitor::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginAvahiMonitor::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params)
|
||||
|
||||
if (deviceClassId != avahiDeviceClassId)
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
|
||||
if (!m_serviceBrowser) {
|
||||
m_serviceBrowser = hardwareManager()->zeroConfController()->createServiceBrowser();
|
||||
@ -77,7 +76,7 @@ DeviceManager::DeviceError DevicePluginAvahiMonitor::discoverDevices(const Devic
|
||||
|
||||
emit devicesDiscovered(avahiDeviceClassId, deviceDescriptors);
|
||||
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
void DevicePluginAvahiMonitor::onServiceEntryAdded(const ZeroConfServiceEntry &serviceEntry)
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
#ifndef DEVICEPLUGINAVAHIMONITOR_H
|
||||
#define DEVICEPLUGINAVAHIMONITOR_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "network/zeroconf/zeroconfservicebrowser.h"
|
||||
#include "network/zeroconf/zeroconfserviceentry.h"
|
||||
|
||||
@ -40,8 +40,8 @@ class DevicePluginAvahiMonitor : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginAvahiMonitor();
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
|
||||
private slots:
|
||||
void onServiceEntryAdded(const ZeroConfServiceEntry &serviceEntry);
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
|
||||
#include "devicepluginawattar.h"
|
||||
#include "plugin/device.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
#include "hardwaremanager.h"
|
||||
#include "network/networkaccessmanager.h"
|
||||
@ -39,7 +39,7 @@ DevicePluginAwattar::~DevicePluginAwattar()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginAwattar::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginAwattar::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcAwattar) << "Setup device" << device->name() << device->params();
|
||||
|
||||
@ -48,7 +48,7 @@ DeviceManager::DeviceSetupStatus DevicePluginAwattar::setupDevice(Device *device
|
||||
|
||||
if (token.isEmpty() || userUuid.isEmpty()) {
|
||||
qCWarning(dcAwattar) << "Missing token oder user uuid.";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
if (!m_pluginTimer) {
|
||||
@ -58,7 +58,7 @@ DeviceManager::DeviceSetupStatus DevicePluginAwattar::setupDevice(Device *device
|
||||
|
||||
requestPriceData(device, true);
|
||||
|
||||
return DeviceManager::DeviceSetupStatusAsync;
|
||||
return Device::DeviceSetupStatusAsync;
|
||||
}
|
||||
|
||||
void DevicePluginAwattar::deviceRemoved(Device *device)
|
||||
@ -93,7 +93,7 @@ void DevicePluginAwattar::requestPriceData(Device* device, bool setupInProgress)
|
||||
if (status != 200) {
|
||||
qCWarning(dcAwattar) << "Update reply HTTP error:" << status << reply->errorString();
|
||||
if (setupInProgress) {
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
} else {
|
||||
device->setStateValue(awattarConnectedStateTypeId, false);
|
||||
}
|
||||
@ -105,14 +105,14 @@ void DevicePluginAwattar::requestPriceData(Device* device, bool setupInProgress)
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCWarning(dcAwattar) << "Update reply JSON error:" << error.errorString();
|
||||
if (setupInProgress) {
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
} else {
|
||||
device->setStateValue(awattarConnectedStateTypeId, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusSuccess);
|
||||
device->setStateValue(awattarConnectedStateTypeId, true);
|
||||
|
||||
processPriceData(device, jsonDoc.toVariant().toMap());
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef DEVICEPLUGINAWATTAR_H
|
||||
#define DEVICEPLUGINAWATTAR_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "plugintimer.h"
|
||||
|
||||
#include "heatpump.h"
|
||||
@ -44,7 +44,7 @@ public:
|
||||
explicit DevicePluginAwattar();
|
||||
~DevicePluginAwattar();
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -21,8 +21,7 @@
|
||||
|
||||
#include "devicepluginboblight.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
|
||||
#include "bobclient.h"
|
||||
#include "plugininfo.h"
|
||||
@ -164,7 +163,7 @@ QColor DevicePluginBoblight::tempToRgb(int temp)
|
||||
return QColor(red, green, blue);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginBoblight::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginBoblight::setupDevice(Device *device)
|
||||
{
|
||||
if (device->deviceClassId() == boblightServerDeviceClassId) {
|
||||
|
||||
@ -189,7 +188,7 @@ DeviceManager::DeviceSetupStatus DevicePluginBoblight::setupDevice(Device *devic
|
||||
m_bobClients.insert(device->id(), bobClient);
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
void DevicePluginBoblight::postSetupDevice(Device *device)
|
||||
@ -214,53 +213,53 @@ void DevicePluginBoblight::postSetupDevice(Device *device)
|
||||
}
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginBoblight::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginBoblight::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (!device->setupComplete()) {
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
qCDebug(dcBoblight()) << "Execute action for boblight" << action.params();
|
||||
if (device->deviceClassId() == boblightServerDeviceClassId) {
|
||||
BobClient *bobClient = m_bobClients.value(device->id());
|
||||
if (!bobClient || !bobClient->connected()) {
|
||||
qCWarning(dcBoblight()) << "Boblight on" << device->paramValue(boblightServerDeviceHostAddressParamTypeId).toString() << "not connected";
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
if (action.actionTypeId() == boblightServerPriorityActionTypeId) {
|
||||
bobClient->setPriority(action.param(boblightServerPriorityActionPriorityParamTypeId).value().toInt());
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
qCWarning(dcBoblight()) << "Unhandled action" << action.actionTypeId() << "for BoblightServer device" << device;
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == boblightDeviceClassId) {
|
||||
BobClient *bobClient = m_bobClients.value(device->parentId());
|
||||
if (!bobClient || !bobClient->connected()) {
|
||||
qCWarning(dcBoblight()) << "Boblight not connected";
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
if (action.actionTypeId() == boblightPowerActionTypeId) {
|
||||
bobClient->setPower(device->paramValue(boblightDeviceChannelParamTypeId).toInt(), action.param(boblightPowerActionPowerParamTypeId).value().toBool());
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == boblightColorActionTypeId) {
|
||||
bobClient->setColor(device->paramValue(boblightDeviceChannelParamTypeId).toInt(), action.param(boblightColorActionColorParamTypeId).value().value<QColor>());
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == boblightBrightnessActionTypeId) {
|
||||
bobClient->setBrightness(device->paramValue(boblightDeviceChannelParamTypeId).toInt(), action.param(boblightBrightnessActionBrightnessParamTypeId).value().toInt());
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == boblightColorTemperatureActionTypeId) {
|
||||
bobClient->setColor(device->paramValue(boblightDeviceChannelParamTypeId).toInt(), tempToRgb(action.param(boblightColorTemperatureActionColorTemperatureParamTypeId).value().toInt()));
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginBoblight::onConnectionChanged()
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
#ifndef DEVICEPLUGINBOBLIGHT_H
|
||||
#define DEVICEPLUGINBOBLIGHT_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "bobclient.h"
|
||||
|
||||
class BobClient;
|
||||
@ -39,13 +39,13 @@ public:
|
||||
|
||||
void init() override;
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void postSetupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
void startMonitoringAutoDevices() override;
|
||||
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private slots:
|
||||
void onConnectionChanged();
|
||||
|
||||
@ -23,8 +23,7 @@
|
||||
|
||||
#include "deviceplugincommandlauncher.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
#include <QDebug>
|
||||
@ -34,11 +33,11 @@ DevicePluginCommandLauncher::DevicePluginCommandLauncher()
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginCommandLauncher::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginCommandLauncher::setupDevice(Device *device)
|
||||
{
|
||||
// Application
|
||||
if(device->deviceClassId() == applicationDeviceClassId)
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
|
||||
// Script
|
||||
if(device->deviceClassId() == scriptDeviceClassId){
|
||||
@ -47,23 +46,23 @@ DeviceManager::DeviceSetupStatus DevicePluginCommandLauncher::setupDevice(Device
|
||||
QFileInfo fileInfo(scriptArguments.first());
|
||||
if (!fileInfo.exists()) {
|
||||
qCWarning(dcCommandLauncher) << "script " << scriptArguments.first() << "does not exist.";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
if (!fileInfo.isExecutable()) {
|
||||
qCWarning(dcCommandLauncher) << "script " << scriptArguments.first() << "is not executable. Please check the permissions.";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
if (!fileInfo.isReadable()) {
|
||||
qCWarning(dcCommandLauncher) << "script " << scriptArguments.first() << "is not readable. Please check the permissions.";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginCommandLauncher::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginCommandLauncher::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
// Application
|
||||
if (device->deviceClassId() == applicationDeviceClassId ) {
|
||||
@ -72,7 +71,7 @@ DeviceManager::DeviceError DevicePluginCommandLauncher::executeAction(Device *de
|
||||
// check if we already have started the application
|
||||
if (m_applications.values().contains(device)) {
|
||||
if (m_applications.key(device)->state() == QProcess::Running) {
|
||||
return DeviceManager::DeviceErrorDeviceInUse;
|
||||
return Device::DeviceErrorDeviceInUse;
|
||||
}
|
||||
}
|
||||
QProcess *process = new QProcess(this);
|
||||
@ -83,21 +82,21 @@ DeviceManager::DeviceError DevicePluginCommandLauncher::executeAction(Device *de
|
||||
m_startingApplications.insert(process, action.id());
|
||||
process->start("/bin/bash", QStringList() << "-c" << device->paramValue(applicationDeviceCommandParamTypeId).toString());
|
||||
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
// kill application...
|
||||
if (action.actionTypeId() == applicationKillActionTypeId) {
|
||||
// check if the application is running...
|
||||
if (!m_applications.values().contains(device)) {
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
QProcess *process = m_applications.key(device);
|
||||
m_killingApplications.insert(process,action.id());
|
||||
process->kill();
|
||||
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
// Script
|
||||
@ -107,7 +106,7 @@ DeviceManager::DeviceError DevicePluginCommandLauncher::executeAction(Device *de
|
||||
// check if we already have started the script
|
||||
if (m_scripts.values().contains(device)) {
|
||||
if (m_scripts.key(device)->state() == QProcess::Running) {
|
||||
return DeviceManager::DeviceErrorDeviceInUse;
|
||||
return Device::DeviceErrorDeviceInUse;
|
||||
}
|
||||
}
|
||||
QProcess *process = new QProcess(this);
|
||||
@ -118,23 +117,23 @@ DeviceManager::DeviceError DevicePluginCommandLauncher::executeAction(Device *de
|
||||
m_startingScripts.insert(process, action.id());
|
||||
process->start("/bin/bash", QStringList() << device->paramValue(scriptDeviceScriptParamTypeId).toString());
|
||||
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
// kill script...
|
||||
if (action.actionTypeId() == scriptKillActionTypeId) {
|
||||
// check if the script is running...
|
||||
if (!m_scripts.values().contains(device)) {
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
QProcess *process = m_scripts.key(device);
|
||||
m_killingScripts.insert(process,action.id());
|
||||
process->kill();
|
||||
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginCommandLauncher::deviceRemoved(Device *device)
|
||||
@ -179,13 +178,13 @@ void DevicePluginCommandLauncher::scriptStateChanged(QProcess::ProcessState stat
|
||||
switch (state) {
|
||||
case QProcess::Running:
|
||||
device->setStateValue(scriptRunningStateTypeId, true);
|
||||
emit actionExecutionFinished(m_startingScripts.value(process), DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(m_startingScripts.value(process), Device::DeviceErrorNoError);
|
||||
m_startingScripts.remove(process);
|
||||
break;
|
||||
case QProcess::NotRunning:
|
||||
device->setStateValue(scriptRunningStateTypeId, false);
|
||||
if (m_killingScripts.contains(process)) {
|
||||
emit actionExecutionFinished(m_killingScripts.value(process), DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(m_killingScripts.value(process), Device::DeviceErrorNoError);
|
||||
m_killingScripts.remove(process);
|
||||
}
|
||||
break;
|
||||
@ -216,13 +215,13 @@ void DevicePluginCommandLauncher::applicationStateChanged(QProcess::ProcessState
|
||||
switch (state) {
|
||||
case QProcess::Running:
|
||||
device->setStateValue(applicationRunningStateTypeId, true);
|
||||
emit actionExecutionFinished(m_startingApplications.value(process), DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(m_startingApplications.value(process), Device::DeviceErrorNoError);
|
||||
m_startingApplications.remove(process);
|
||||
break;
|
||||
case QProcess::NotRunning:
|
||||
device->setStateValue(applicationRunningStateTypeId, false);
|
||||
if (m_killingApplications.contains(process)) {
|
||||
emit actionExecutionFinished(m_killingApplications.value(process), DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(m_killingApplications.value(process), Device::DeviceErrorNoError);
|
||||
m_killingApplications.remove(process);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef DEVICEPLUGINCOMMANDLAUNCHER_H
|
||||
#define DEVICEPLUGINCOMMANDLAUNCHER_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
#include <QProcess>
|
||||
#include <QFileInfo>
|
||||
@ -38,8 +38,8 @@ class DevicePluginCommandLauncher : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginCommandLauncher();
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
|
||||
@ -23,8 +23,7 @@
|
||||
|
||||
#include "devicepluginconrad.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
#include "hardware/radio433/radio433.h"
|
||||
|
||||
@ -37,19 +36,19 @@ DevicePluginConrad::DevicePluginConrad()
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginConrad::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginConrad::setupDevice(Device *device)
|
||||
{
|
||||
if (device->deviceClassId() == conradShutterDeviceClassId)
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginConrad::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginConrad::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
|
||||
if (!hardwareManager()->radio433()->available()) {
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
QList<int> rawData;
|
||||
@ -65,7 +64,7 @@ DeviceManager::DeviceError DevicePluginConrad::executeAction(Device *device, con
|
||||
binCode = "10100000";
|
||||
repetitions = 20;
|
||||
} else {
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
// append ID
|
||||
@ -104,9 +103,9 @@ DeviceManager::DeviceError DevicePluginConrad::executeAction(Device *device, con
|
||||
qCDebug(dcConrad) << "Transmitted successfully" << device->name() << action.actionTypeId();
|
||||
}else{
|
||||
qCWarning(dcConrad) << "Could not transmitt" << pluginName() << device->name() << action.actionTypeId();
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
void DevicePluginConrad::radioData(const QList<int> &rawData)
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
#ifndef DEVICEPLUGINCONRAD_H
|
||||
#define DEVICEPLUGINCONRAD_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
class DevicePluginConrad : public DevicePlugin
|
||||
{
|
||||
@ -36,12 +36,12 @@ class DevicePluginConrad : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginConrad();
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void radioData(const QList<int> &rawData);
|
||||
|
||||
|
||||
public slots:
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -22,8 +22,7 @@
|
||||
|
||||
#include "deviceplugindatetime.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
#include "hardwaremanager.h"
|
||||
#include "network/networkaccessmanager.h"
|
||||
@ -49,19 +48,19 @@ DevicePluginDateTime::DevicePluginDateTime() :
|
||||
connect(m_timer, &QTimer::timeout, this, &DevicePluginDateTime::onSecondChanged);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginDateTime::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginDateTime::setupDevice(Device *device)
|
||||
{
|
||||
// check timezone
|
||||
if(!m_timeZone.isValid()){
|
||||
qCWarning(dcDateTime) << "Invalid time zone.";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
// date
|
||||
if (device->deviceClassId() == todayDeviceClassId) {
|
||||
if (m_todayDevice != 0) {
|
||||
qCWarning(dcDateTime) << "There is already a date device or not deleted correctly! this should never happen!!";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
m_todayDevice = device;
|
||||
qCDebug(dcDateTime) << "Create today device: current time" << m_currentDateTime.currentDateTime().toString();
|
||||
@ -109,7 +108,7 @@ DeviceManager::DeviceSetupStatus DevicePluginDateTime::setupDevice(Device *devic
|
||||
|
||||
m_timer->start();
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
void DevicePluginDateTime::postSetupDevice(Device *device)
|
||||
@ -150,23 +149,23 @@ void DevicePluginDateTime::deviceRemoved(Device *device)
|
||||
//startMonitoringAutoDevices();
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginDateTime::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginDateTime::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (device->deviceClassId() == countdownDeviceClassId) {
|
||||
Countdown *countdown = m_countdowns.value(device);
|
||||
if (action.actionTypeId() == countdownStartActionTypeId) {
|
||||
countdown->start();
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == countdownRestartActionTypeId) {
|
||||
countdown->restart();
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == countdownStopActionTypeId) {
|
||||
countdown->stop();
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
void DevicePluginDateTime::startMonitoringAutoDevices()
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef DEVICEPLUGINDATETIME_H
|
||||
#define DEVICEPLUGINDATETIME_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "alarm.h"
|
||||
#include "countdown.h"
|
||||
|
||||
@ -43,11 +43,11 @@ class DevicePluginDateTime : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginDateTime();
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void postSetupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
void startMonitoringAutoDevices() override;
|
||||
|
||||
|
||||
@ -22,7 +22,6 @@
|
||||
|
||||
|
||||
#include "plugininfo.h"
|
||||
#include "devicemanager.h"
|
||||
#include "deviceplugindaylightsensor.h"
|
||||
#include "network/networkaccessmanager.h"
|
||||
|
||||
@ -45,7 +44,7 @@ DevicePluginDaylightSensor::~DevicePluginDaylightSensor()
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginDaylightSensor::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginDaylightSensor::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(deviceClassId)
|
||||
Q_UNUSED(params)
|
||||
@ -84,14 +83,14 @@ DeviceManager::DeviceError DevicePluginDaylightSensor::discoverDevices(const Dev
|
||||
emit devicesDiscovered(deviceClassId, results);
|
||||
});
|
||||
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginDaylightSensor::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginDaylightSensor::setupDevice(Device *device)
|
||||
{
|
||||
updateDevice(device);
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
void DevicePluginDaylightSensor::deviceRemoved(Device *device)
|
||||
|
||||
@ -24,8 +24,7 @@
|
||||
#define DEVICEPLUGINDAYLIGHTSENSOR_H
|
||||
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "plugintimer.h"
|
||||
|
||||
class DevicePluginDaylightSensor: public DevicePlugin
|
||||
@ -38,8 +37,8 @@ public:
|
||||
explicit DevicePluginDaylightSensor();
|
||||
~DevicePluginDaylightSensor() override;
|
||||
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
private slots:
|
||||
|
||||
@ -40,20 +40,20 @@ void DevicePluginDenon::init()
|
||||
connect(m_pluginTimer, &PluginTimer::timeout, this, &DevicePluginDenon::onPluginTimer);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginDenon::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginDenon::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcDenon) << "Setup Denon device" << device->paramValue(AVRX1000DeviceIpParamTypeId).toString();
|
||||
|
||||
// Check if we already have a denon device
|
||||
if (!myDevices().isEmpty()) {
|
||||
qCWarning(dcDenon) << "Could not add denon device. Only one denon device allowed.";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
QHostAddress address(device->paramValue(AVRX1000DeviceIpParamTypeId).toString());
|
||||
if (address.isNull()) {
|
||||
qCWarning(dcDenon) << "Could not parse ip address" << device->paramValue(AVRX1000DeviceIpParamTypeId).toString();
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
m_device = device;
|
||||
@ -65,7 +65,7 @@ DeviceManager::DeviceSetupStatus DevicePluginDenon::setupDevice(Device *device)
|
||||
m_asyncSetups.append(m_denonConnection);
|
||||
m_denonConnection->connectDenon();
|
||||
|
||||
return DeviceManager::DeviceSetupStatusAsync;
|
||||
return Device::DeviceSetupStatusAsync;
|
||||
}
|
||||
|
||||
void DevicePluginDenon::deviceRemoved(Device *device)
|
||||
@ -80,14 +80,14 @@ void DevicePluginDenon::deviceRemoved(Device *device)
|
||||
m_denonConnection->deleteLater();
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginDenon::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginDenon::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
qCDebug(dcDenon) << "Execute action" << device->id() << action.id() << action.params();
|
||||
if (device->deviceClassId() == AVRX1000DeviceClassId) {
|
||||
|
||||
// check connection state
|
||||
if (m_denonConnection.isNull() || !m_denonConnection->connected())
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
// check if the requested action is our "update" action ...
|
||||
if (action.actionTypeId() == AVRX1000PowerActionTypeId) {
|
||||
@ -106,7 +106,7 @@ DeviceManager::DeviceError DevicePluginDenon::executeAction(Device *device, cons
|
||||
m_denonConnection->sendData(cmd);
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
|
||||
} else if (action.actionTypeId() == AVRX1000VolumeActionTypeId) {
|
||||
|
||||
@ -116,7 +116,7 @@ DeviceManager::DeviceError DevicePluginDenon::executeAction(Device *device, cons
|
||||
qCDebug(dcDenon) << "Execute volume" << action.id() << cmd;
|
||||
m_denonConnection->sendData(cmd);
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
|
||||
} else if (action.actionTypeId() == AVRX1000ChannelActionTypeId) {
|
||||
|
||||
@ -127,11 +127,11 @@ DeviceManager::DeviceError DevicePluginDenon::executeAction(Device *device, cons
|
||||
qCDebug(dcDenon) << "Change to channel:" << cmd;
|
||||
m_denonConnection->sendData(cmd);
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginDenon::onPluginTimer()
|
||||
@ -157,7 +157,7 @@ void DevicePluginDenon::onConnectionChanged()
|
||||
if (m_asyncSetups.contains(m_denonConnection)) {
|
||||
m_asyncSetups.removeAll(m_denonConnection);
|
||||
m_denonConnection->sendData("PW?\rSI?\rMV?\r");
|
||||
emit deviceSetupFinished(m_device, DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit deviceSetupFinished(m_device, Device::DeviceSetupStatusSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ void DevicePluginDenon::onSocketError()
|
||||
// Check if setup running for this device
|
||||
if (m_asyncSetups.contains(m_denonConnection)) {
|
||||
qCWarning(dcDenon()) << "Could not add device. The setup failed.";
|
||||
emit deviceSetupFinished(m_device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(m_device, Device::DeviceSetupStatusFailure);
|
||||
// Delete the connection, the device will not be added and
|
||||
// the connection will be created in the next setup
|
||||
m_denonConnection->deleteLater();
|
||||
|
||||
@ -24,8 +24,7 @@
|
||||
#ifndef DEVICEPLUGINDENON_H
|
||||
#define DEVICEPLUGINDENON_H
|
||||
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
|
||||
#include <QHash>
|
||||
@ -49,9 +48,9 @@ public:
|
||||
~DevicePluginDenon();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private:
|
||||
PluginTimer *m_pluginTimer = nullptr;
|
||||
|
||||
@ -49,7 +49,7 @@ void DevicePluginDweetio::init()
|
||||
connect(m_pluginTimer, &PluginTimer::timeout, this, &DevicePluginDweetio::onPluginTimer);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginDweetio::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginDweetio::setupDevice(Device *device)
|
||||
{
|
||||
|
||||
if (device->deviceClassId() == postDeviceClassId) {
|
||||
@ -59,12 +59,12 @@ DeviceManager::DeviceSetupStatus DevicePluginDweetio::setupDevice(Device *device
|
||||
qDebug(dcDweetio) << "No thing name given, creating one";
|
||||
thing = QUuid::createUuid().toString();
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
} else if (device->deviceClassId() == getDeviceClassId) {
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
void DevicePluginDweetio::postSetupDevice(Device *device)
|
||||
@ -93,7 +93,7 @@ void DevicePluginDweetio::deviceRemoved(Device *device)
|
||||
}
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginDweetio::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginDweetio::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
qCDebug(dcDweetio) << "Execute action" << device->id() << action.id() << action.params();
|
||||
|
||||
@ -104,11 +104,11 @@ DeviceManager::DeviceError DevicePluginDweetio::executeAction(Device *device, co
|
||||
QString content = action.param(postContentDataActionContentDataAreaParamTypeId).value().toString();
|
||||
postContent(content, device, action);
|
||||
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginDweetio::postContent(const QString &content, Device *device, const Action &action)
|
||||
@ -174,13 +174,13 @@ void DevicePluginDweetio::onNetworkReplyFinished()
|
||||
// check HTTP status code
|
||||
if ((status != 200) && (status != 204)) {
|
||||
qCWarning(dcDweetio) << "Update reply HTTP error:" << status << reply->errorString() << reply->readAll();
|
||||
emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorMissingParameter);
|
||||
emit actionExecutionFinished(actionId, Device::DeviceErrorMissingParameter);
|
||||
setConnectionStatus(false, device);
|
||||
reply->deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(actionId, Device::DeviceErrorNoError);
|
||||
setConnectionStatus(true, device);
|
||||
if (status == 204){
|
||||
reply->deleteLater();
|
||||
|
||||
@ -23,8 +23,7 @@
|
||||
#ifndef DEVICEPLUGINDWEETIO_H
|
||||
#define DEVICEPLUGINDWEETIO_H
|
||||
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
@ -46,9 +45,9 @@ public:
|
||||
~DevicePluginDweetio();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
void postSetupDevice(Device *device) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
#include <QColor>
|
||||
|
||||
#include "typeutils.h"
|
||||
#include "plugin/device.h"
|
||||
#include "devices/device.h"
|
||||
#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h"
|
||||
|
||||
static QBluetoothUuid colorServiceUuid = QBluetoothUuid(QUuid("f815e810-456c-6761-746f-4d756e696368"));
|
||||
|
||||
@ -375,8 +375,7 @@
|
||||
|
||||
#include "devicepluginelgato.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
#include "hardware/bluetoothlowenergy/bluetoothlowenergymanager.h"
|
||||
|
||||
@ -396,25 +395,25 @@ void DevicePluginElgato::init()
|
||||
connect(m_pluginTimer, &PluginTimer::timeout, this, &DevicePluginElgato::onPluginTimer);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginElgato::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginElgato::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params)
|
||||
|
||||
if (deviceClassId != aveaDeviceClassId)
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
|
||||
if (!hardwareManager()->bluetoothLowEnergyManager()->available())
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
if (!hardwareManager()->bluetoothLowEnergyManager()->enabled())
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
BluetoothDiscoveryReply *reply = hardwareManager()->bluetoothLowEnergyManager()->discoverDevices();
|
||||
connect(reply, &BluetoothDiscoveryReply::finished, this, &DevicePluginElgato::onBluetoothDiscoveryFinished);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginElgato::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginElgato::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcElgato()) << "Setup device" << device->name() << device->params();
|
||||
|
||||
@ -428,9 +427,9 @@ DeviceManager::DeviceSetupStatus DevicePluginElgato::setupDevice(Device *device)
|
||||
AveaBulb *bulb = new AveaBulb(device, bluetoothDevice, this);
|
||||
m_bulbs.insert(device, bulb);
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
void DevicePluginElgato::postSetupDevice(Device *device)
|
||||
@ -447,7 +446,7 @@ void DevicePluginElgato::postSetupDevice(Device *device)
|
||||
bulb->bluetoothDevice()->connectDevice();
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginElgato::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginElgato::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (device->deviceClassId() == aveaDeviceClassId) {
|
||||
AveaBulb *bulb = m_bulbs.value(device);
|
||||
@ -456,22 +455,22 @@ DeviceManager::DeviceError DevicePluginElgato::executeAction(Device *device, con
|
||||
bool power = action.param(aveaPowerActionPowerParamTypeId).value().toBool();
|
||||
device->setStateValue(aveaPowerStateTypeId, power);
|
||||
if (!bulb->setPower(power))
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == aveaBrightnessActionTypeId) {
|
||||
int percentage = action.param(aveaBrightnessActionBrightnessParamTypeId).value().toInt();
|
||||
if (!bulb->setBrightness(percentage))
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == aveaColorActionTypeId) {
|
||||
QColor color = action.param(aveaColorActionColorParamTypeId).value().value<QColor>();
|
||||
color.setAlpha(0); // Alpha is white
|
||||
if (!bulb->setColor(color))
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == aveaColorTemperatureActionTypeId) {
|
||||
int ctValue = action.param(aveaColorTemperatureActionColorTemperatureParamTypeId).value().toInt();
|
||||
// normalize from 0 to 347 instead of 153 to 500
|
||||
@ -489,45 +488,45 @@ DeviceManager::DeviceError DevicePluginElgato::executeAction(Device *device, con
|
||||
color.setBlue(blue);
|
||||
color.setAlpha(255); // Alpha is white
|
||||
if (!bulb->setColor(color)) {
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
device->setStateValue(aveaColorTemperatureStateTypeId, ctValue);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == aveaWhiteActionTypeId) {
|
||||
int whiteValue = action.param(aveaWhiteActionWhiteParamTypeId).value().toInt();
|
||||
if (!bulb->setWhite(whiteValue))
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == aveaGreenActionTypeId) {
|
||||
int greenValue = action.param(aveaGreenActionGreenParamTypeId).value().toInt();
|
||||
if (!bulb->setGreen(greenValue))
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == aveaRedActionTypeId) {
|
||||
int redValue = action.param(aveaRedActionRedParamTypeId).value().toInt();
|
||||
if (!bulb->setRed(redValue))
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == aveaBlueActionTypeId) {
|
||||
int blueValue = action.param(aveaBlueActionBlueParamTypeId).value().toInt();
|
||||
if (!bulb->setBlue(blueValue))
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == aveaFadeActionTypeId) {
|
||||
int fadeValue = action.param(aveaFadeActionFadeParamTypeId).value().toInt();
|
||||
if (!bulb->setFade(fadeValue))
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginElgato::deviceRemoved(Device *device)
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
#include "aveabulb.h"
|
||||
#include "plugintimer.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h"
|
||||
|
||||
class DevicePluginElgato : public DevicePlugin
|
||||
@ -40,10 +40,10 @@ public:
|
||||
~DevicePluginElgato();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void postSetupDevice(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "devicepluginelro.h"
|
||||
#include "devicemanager.h"
|
||||
#include "plugininfo.h"
|
||||
#include "hardware/radio433/radio433.h"
|
||||
|
||||
@ -33,13 +32,13 @@ DevicePluginElro::DevicePluginElro()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginElro::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginElro::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (!hardwareManager()->radio433()->available())
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
if (action.actionTypeId() != elroSocketPowerActionTypeId)
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
|
||||
QList<int> rawData;
|
||||
QByteArray binCode;
|
||||
@ -129,10 +128,10 @@ DeviceManager::DeviceError DevicePluginElro::executeAction(Device *device, const
|
||||
qCDebug(dcElro) << "Transmitted" << pluginName() << device->name() << "power: " << action.param(elroSocketPowerActionPowerParamTypeId).value().toBool();
|
||||
} else {
|
||||
qCWarning(dcElro) << "Could not transmitt" << pluginName() << device->name() << "power: " << action.param(elroSocketPowerActionPowerParamTypeId).value().toBool();
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
void DevicePluginElro::radioData(const QList<int> &rawData)
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef DEVICEPLUGINELRO_H
|
||||
#define DEVICEPLUGINELRO_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
class DevicePluginElro : public DevicePlugin
|
||||
{
|
||||
@ -38,7 +38,7 @@ public:
|
||||
void radioData(const QList<int> &rawData);
|
||||
|
||||
public slots:
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -22,8 +22,7 @@
|
||||
|
||||
#include "deviceplugineq-3.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
#include "types/param.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
@ -54,22 +53,22 @@ void DevicePluginEQ3::init()
|
||||
connect(m_eqivaBluetoothDiscovery, &EqivaBluetoothDiscovery::finished, this, &DevicePluginEQ3::bluetoothDiscoveryDone);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginEQ3::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginEQ3::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params)
|
||||
qCDebug(dcEQ3()) << "Discover devices called";
|
||||
if(deviceClassId == cubeDeviceClassId){
|
||||
m_cubeDiscovery->detectCubes();
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
if (deviceClassId == eqivaBluetoothDeviceClassId) {
|
||||
bool ret = m_eqivaBluetoothDiscovery->startDiscovery();
|
||||
if (!ret) {
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginEQ3::startMonitoringAutoDevices()
|
||||
@ -77,7 +76,7 @@ void DevicePluginEQ3::startMonitoringAutoDevices()
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginEQ3::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginEQ3::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcEQ3) << "Setup device" << device->params();
|
||||
|
||||
@ -85,7 +84,7 @@ DeviceManager::DeviceSetupStatus DevicePluginEQ3::setupDevice(Device *device)
|
||||
foreach (MaxCube *cube, m_cubes.keys()) {
|
||||
if(cube->serialNumber() == device->paramValue(cubeDeviceSerialParamTypeId).toString()){
|
||||
qCDebug(dcEQ3) << cube->serialNumber() << " already exists...";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,7 +101,7 @@ DeviceManager::DeviceSetupStatus DevicePluginEQ3::setupDevice(Device *device)
|
||||
|
||||
cube->connectToCube();
|
||||
|
||||
return DeviceManager::DeviceSetupStatusAsync;
|
||||
return Device::DeviceSetupStatusAsync;
|
||||
}
|
||||
if(device->deviceClassId() == wallThermostateDeviceClassId){
|
||||
device->setName("Max! Wall Thermostat (" + device->paramValue(wallThermostateDeviceSerialParamTypeId).toString() + ")");
|
||||
@ -160,12 +159,12 @@ DeviceManager::DeviceSetupStatus DevicePluginEQ3::setupDevice(Device *device)
|
||||
// Command handler
|
||||
connect(eqivaDevice, &EqivaBluetooth::commandResult, this, [this](int commandId, bool success){
|
||||
if (m_commandMap.contains(commandId)) {
|
||||
emit actionExecutionFinished(m_commandMap.take(commandId), success ? DeviceManager::DeviceErrorNoError : DeviceManager::DeviceErrorHardwareFailure);
|
||||
emit actionExecutionFinished(m_commandMap.take(commandId), success ? Device::DeviceErrorNoError : Device::DeviceErrorHardwareFailure);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
void DevicePluginEQ3::deviceRemoved(Device *device)
|
||||
@ -214,7 +213,7 @@ EqivaBluetooth::Mode DevicePluginEQ3::stringToMode(const QString &string)
|
||||
return EqivaBluetooth::ModeAuto;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginEQ3::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginEQ3::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if(device->deviceClassId() == wallThermostateDeviceClassId){
|
||||
foreach (MaxCube *cube, m_cubes.keys()){
|
||||
@ -234,7 +233,7 @@ DeviceManager::DeviceError DevicePluginEQ3::executeAction(Device *device, const
|
||||
} else if (action.actionTypeId() == wallThermostateDisplayCurrentTempActionTypeId){
|
||||
cube->displayCurrentTemperature(rfAddress, roomId, action.param(wallThermostateDisplayCurrentTempActionDisplayParamTypeId).value().toBool(), action.id());
|
||||
}
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
}
|
||||
} else if (device->deviceClassId() == radiatorThermostateDeviceClassId){
|
||||
@ -253,7 +252,7 @@ DeviceManager::DeviceError DevicePluginEQ3::executeAction(Device *device, const
|
||||
} else if (action.actionTypeId() == radiatorThermostateSetEcoModeActionTypeId){
|
||||
cube->setDeviceEcoMode(rfAddress, roomId, action.id());
|
||||
}
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
}
|
||||
} else if (device->deviceClassId() == eqivaBluetoothDeviceClassId) {
|
||||
@ -273,10 +272,10 @@ DeviceManager::DeviceError DevicePluginEQ3::executeAction(Device *device, const
|
||||
qCWarning(dcEQ3()) << "An action type has not been handled!";
|
||||
}
|
||||
m_commandMap.insert(commandId, action.id());
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginEQ3::onPluginTimer()
|
||||
@ -297,7 +296,7 @@ void DevicePluginEQ3::cubeConnectionStatusChanged(const bool &connected)
|
||||
device = m_cubes.value(cube);
|
||||
device->setName("Max! Cube " + cube->serialNumber());
|
||||
device->setStateValue(cubeConnectedStateTypeId,true);
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusSuccess);
|
||||
}
|
||||
}else{
|
||||
MaxCube *cube = static_cast<MaxCube*>(sender());
|
||||
@ -305,7 +304,7 @@ void DevicePluginEQ3::cubeConnectionStatusChanged(const bool &connected)
|
||||
if (m_cubes.contains(cube)){
|
||||
device = m_cubes.value(cube);
|
||||
device->setStateValue(cubeConnectedStateTypeId,false);
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -363,9 +362,9 @@ void DevicePluginEQ3::bluetoothDiscoveryDone(const QStringList results)
|
||||
void DevicePluginEQ3::commandActionFinished(const bool &succeeded, const ActionId &actionId)
|
||||
{
|
||||
if(succeeded){
|
||||
emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(actionId, Device::DeviceErrorNoError);
|
||||
}else{
|
||||
emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorSetupFailed);
|
||||
emit actionExecutionFinished(actionId, Device::DeviceErrorSetupFailed);
|
||||
}
|
||||
}
|
||||
|
||||
@ -377,7 +376,7 @@ void DevicePluginEQ3::wallThermostatFound()
|
||||
|
||||
foreach (WallThermostat *wallThermostat, cube->wallThermostatList()) {
|
||||
bool allreadyAdded = false;
|
||||
foreach (Device *device, deviceManager()->findConfiguredDevices(wallThermostateDeviceClassId)){
|
||||
foreach (Device *device, myDevices().filterByDeviceClassId(wallThermostateDeviceClassId)){
|
||||
if(wallThermostat->serialNumber() == device->paramValue(wallThermostateDeviceSerialParamTypeId).toString()){
|
||||
allreadyAdded = true;
|
||||
break;
|
||||
@ -411,7 +410,7 @@ void DevicePluginEQ3::radiatorThermostatFound()
|
||||
|
||||
foreach (RadiatorThermostat *radiatorThermostat, cube->radiatorThermostatList()) {
|
||||
bool allreadyAdded = false;
|
||||
foreach (Device *device, deviceManager()->findConfiguredDevices(radiatorThermostateDeviceClassId)){
|
||||
foreach (Device *device, myDevices().filterByDeviceClassId(radiatorThermostateDeviceClassId)){
|
||||
if(radiatorThermostat->serialNumber() == device->paramValue(radiatorThermostateDeviceSerialParamTypeId).toString()){
|
||||
allreadyAdded = true;
|
||||
break;
|
||||
@ -452,7 +451,7 @@ void DevicePluginEQ3::wallThermostatDataUpdated()
|
||||
MaxCube *cube = static_cast<MaxCube*>(sender());
|
||||
|
||||
foreach (WallThermostat *wallThermostat, cube->wallThermostatList()) {
|
||||
foreach (Device *device, deviceManager()->findConfiguredDevices(wallThermostateDeviceClassId)){
|
||||
foreach (Device *device, myDevices().filterByDeviceClassId(wallThermostateDeviceClassId)){
|
||||
if(device->paramValue(wallThermostateDeviceSerialParamTypeId).toString() == wallThermostat->serialNumber()){
|
||||
device->setStateValue(wallThermostateComfortTemperatureStateTypeId, wallThermostat->comfortTemp());
|
||||
device->setStateValue(wallThermostateEcoTempStateTypeId, wallThermostat->ecoTemp());
|
||||
@ -479,7 +478,7 @@ void DevicePluginEQ3::radiatorThermostatDataUpdated()
|
||||
MaxCube *cube = static_cast<MaxCube*>(sender());
|
||||
|
||||
foreach (RadiatorThermostat *radiatorThermostat, cube->radiatorThermostatList()) {
|
||||
foreach (Device *device, deviceManager()->findConfiguredDevices(radiatorThermostateDeviceClassId)){
|
||||
foreach (Device *device, myDevices().filterByDeviceClassId(radiatorThermostateDeviceClassId)){
|
||||
if(device->paramValue(radiatorThermostateDeviceSerialParamTypeId).toString() == radiatorThermostat->serialNumber()){
|
||||
device->setStateValue(radiatorThermostateComfortTempStateTypeId, radiatorThermostat->comfortTemp());
|
||||
device->setStateValue(radiatorThermostateMaxSetpointTempStateTypeId, radiatorThermostat->maxSetPointTemp());
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef DEVICEPLUGINEQ3_H
|
||||
#define DEVICEPLUGINEQ3_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "maxcubediscovery.h"
|
||||
#include "plugintimer.h"
|
||||
#include "eqivabluetooth.h"
|
||||
@ -44,11 +44,11 @@ public:
|
||||
~DevicePluginEQ3();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
|
||||
void startMonitoringAutoDevices() override;
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
private:
|
||||
@ -65,7 +65,7 @@ private:
|
||||
QHash<int, ActionId> m_commandMap;
|
||||
|
||||
public slots:
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action);
|
||||
Device::DeviceError executeAction(Device *device, const Action &action);
|
||||
|
||||
private slots:
|
||||
void onPluginTimer();
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
#include "room.h"
|
||||
#include "wallthermostat.h"
|
||||
#include "radiatorthermostat.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
class MaxCube : public QTcpSocket
|
||||
{
|
||||
|
||||
@ -31,7 +31,6 @@
|
||||
* {0000fef5-0000-1000-8000-00805f9b34fb}
|
||||
*/
|
||||
#include "plugininfo.h"
|
||||
#include "devicemanager.h"
|
||||
#include "hardware/bluetoothlowenergy/bluetoothlowenergymanager.h"
|
||||
#include "devicepluginflowercare.h"
|
||||
#include "flowercare.h"
|
||||
@ -52,23 +51,23 @@ void DevicePluginFlowercare::init()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginFlowercare::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginFlowercare::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params)
|
||||
Q_UNUSED(deviceClassId)
|
||||
|
||||
if (!hardwareManager()->bluetoothLowEnergyManager()->available())
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
if (!hardwareManager()->bluetoothLowEnergyManager()->enabled())
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
BluetoothDiscoveryReply *reply = hardwareManager()->bluetoothLowEnergyManager()->discoverDevices();
|
||||
connect(reply, &BluetoothDiscoveryReply::finished, this, &DevicePluginFlowercare::onBluetoothDiscoveryFinished);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginFlowercare::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginFlowercare::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcFlowerCare) << "Setting up Flower care" << device->name() << device->params();
|
||||
|
||||
@ -87,9 +86,9 @@ DeviceManager::DeviceSetupStatus DevicePluginFlowercare::setupDevice(Device *dev
|
||||
m_reconnectTimer = hardwareManager()->pluginTimerManager()->registerTimer();
|
||||
connect(m_reconnectTimer, &PluginTimer::timeout, this, &DevicePluginFlowercare::onPluginTimer);
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
void DevicePluginFlowercare::postSetupDevice(Device *device)
|
||||
@ -114,11 +113,11 @@ void DevicePluginFlowercare::deviceRemoved(Device *device)
|
||||
}
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginFlowercare::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginFlowercare::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
Q_UNUSED(device)
|
||||
Q_UNUSED(action)
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
bool DevicePluginFlowercare::verifyExistingDevices(const QBluetoothDeviceInfo &deviceInfo)
|
||||
|
||||
@ -26,8 +26,7 @@
|
||||
|
||||
#include <QPointer>
|
||||
#include <QHash>
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "plugintimer.h"
|
||||
#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h"
|
||||
|
||||
@ -44,12 +43,12 @@ public:
|
||||
~DevicePluginFlowercare();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void postSetupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private:
|
||||
PluginTimer *m_reconnectTimer = nullptr;
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "deviceplugingenericelements.h"
|
||||
#include "devicemanager.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
#include <QDebug>
|
||||
@ -30,52 +29,52 @@ DevicePluginGenericElements::DevicePluginGenericElements()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginGenericElements::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginGenericElements::setupDevice(Device *device)
|
||||
{
|
||||
// Toggle Button
|
||||
if (device->deviceClassId() == toggleButtonDeviceClassId) {
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
// Button
|
||||
if (device->deviceClassId() == buttonDeviceClassId) {
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
// ON/OFF Button
|
||||
if (device->deviceClassId() == onOffButtonDeviceClassId) {
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginGenericElements::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginGenericElements::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
// Toggle Button
|
||||
if (device->deviceClassId() == toggleButtonDeviceClassId ) {
|
||||
if (action.actionTypeId() == toggleButtonStateActionTypeId) {
|
||||
device->setStateValue(toggleButtonStateStateTypeId, !device->stateValue(toggleButtonStateStateTypeId).toBool());
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
// Button
|
||||
if (device->deviceClassId() == buttonDeviceClassId ) {
|
||||
if (action.actionTypeId() == buttonButtonPressActionTypeId) {
|
||||
emit emitEvent(Event(buttonButtonPressedEventTypeId, device->id()));
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
// ON/OFF Button
|
||||
if (device->deviceClassId() == onOffButtonDeviceClassId ) {
|
||||
if (action.actionTypeId() == onOffButtonOnActionTypeId) {
|
||||
emit emitEvent(Event(onOffButtonOnEventTypeId, device->id()));
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == onOffButtonOffActionTypeId) {
|
||||
emit emitEvent(Event(onOffButtonOffEventTypeId, device->id()));
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef DEVICEPLUGINGENERICELEMENTS_H
|
||||
#define DEVICEPLUGINGENERICELEMENTS_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
class DevicePluginGenericElements : public DevicePlugin
|
||||
{
|
||||
@ -34,10 +34,10 @@ class DevicePluginGenericElements : public DevicePlugin
|
||||
|
||||
public:
|
||||
explicit DevicePluginGenericElements();
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
|
||||
public slots:
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -22,8 +22,7 @@
|
||||
|
||||
#include "deviceplugingpio.h"
|
||||
#include "types/param.h"
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
DevicePluginGpio::DevicePluginGpio()
|
||||
@ -31,14 +30,14 @@ DevicePluginGpio::DevicePluginGpio()
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginGpio::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginGpio::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcGpioController()) << "Setup" << device->name() << device->params();
|
||||
|
||||
// Check if GPIOs are available on this platform
|
||||
if (!Gpio::isAvailable()) {
|
||||
qCWarning(dcGpioController()) << "There are ou GPIOs on this plattform";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
// GPIO Switch
|
||||
@ -55,17 +54,17 @@ DeviceManager::DeviceSetupStatus DevicePluginGpio::setupDevice(Device *device)
|
||||
|
||||
if (!gpio->exportGpio()) {
|
||||
qCWarning(dcGpioController()) << "Could not export gpio for device" << device->name();
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
if (!gpio->setDirection(Gpio::DirectionOutput)) {
|
||||
qCWarning(dcGpioController()) << "Could not configure output gpio for device" << device->name();
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
if (!gpio->setValue(Gpio::ValueLow)) {
|
||||
qCWarning(dcGpioController()) << "Could not set gpio value for device" << device->name();
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
m_gpioDevices.insert(gpio, device);
|
||||
@ -76,7 +75,7 @@ DeviceManager::DeviceSetupStatus DevicePluginGpio::setupDevice(Device *device)
|
||||
if (device->deviceClassId() == gpioOutputBbbDeviceClassId)
|
||||
m_beagleboneBlackGpios.insert(gpio->gpioNumber(), gpio);
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == gpioInputRpiDeviceClassId || device->deviceClassId() == gpioInputBbbDeviceClassId) {
|
||||
@ -92,7 +91,7 @@ DeviceManager::DeviceSetupStatus DevicePluginGpio::setupDevice(Device *device)
|
||||
|
||||
if (!monior->enable()) {
|
||||
qCWarning(dcGpioController()) << "Could not enable gpio monitor for device" << device->name();
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
connect(monior, &GpioMonitor::valueChanged, this, &DevicePluginGpio::onGpioValueChanged);
|
||||
@ -105,24 +104,24 @@ DeviceManager::DeviceSetupStatus DevicePluginGpio::setupDevice(Device *device)
|
||||
if (device->deviceClassId() == gpioOutputBbbDeviceClassId)
|
||||
m_beagleboneBlackGpioMoniors.insert(monior->gpio()->gpioNumber(), monior);
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginGpio::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginGpio::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params)
|
||||
|
||||
// Check if GPIOs are available on this platform
|
||||
if (!Gpio::isAvailable()) {
|
||||
qCWarning(dcGpioController()) << "There are no GPIOs on this plattform";
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
// Check which board / gpio configuration
|
||||
const DeviceClass deviceClass = deviceManager()->findDeviceClass(deviceClassId);
|
||||
const DeviceClass deviceClass = supportedDevices().findById(deviceClassId);
|
||||
if (deviceClass.vendorId() == raspberryPiVendorId) {
|
||||
|
||||
// Create the list of available gpios
|
||||
@ -170,7 +169,7 @@ DeviceManager::DeviceError DevicePluginGpio::discoverDevices(const DeviceClassId
|
||||
}
|
||||
|
||||
emit devicesDiscovered(deviceClassId, deviceDescriptors);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
if (deviceClass.vendorId() == beagleboneBlackVendorId) {
|
||||
@ -213,10 +212,10 @@ DeviceManager::DeviceError DevicePluginGpio::discoverDevices(const DeviceClassId
|
||||
}
|
||||
|
||||
emit devicesDiscovered(deviceClassId, deviceDescriptors);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorVendorNotFound;
|
||||
return Device::DeviceErrorVendorNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginGpio::deviceRemoved(Device *device)
|
||||
@ -255,10 +254,10 @@ void DevicePluginGpio::deviceRemoved(Device *device)
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginGpio::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
// Get the gpio
|
||||
const DeviceClass deviceClass = deviceManager()->findDeviceClass(device->deviceClassId());
|
||||
const DeviceClass deviceClass = supportedDevices().findById(device->deviceClassId());
|
||||
Gpio *gpio = Q_NULLPTR;
|
||||
|
||||
// Find the gpio in the corresponding hash
|
||||
@ -271,7 +270,7 @@ DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const
|
||||
// Check if gpio was found
|
||||
if (!gpio) {
|
||||
qCWarning(dcGpioController()) << "Could not find gpio for executing action on" << device->name();
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
// GPIO Switch power action
|
||||
@ -286,13 +285,13 @@ DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const
|
||||
|
||||
if (!success) {
|
||||
qCWarning(dcGpioController()) << "Could not set gpio value while execute action on" << device->name();
|
||||
return DeviceManager::DeviceErrorHardwareFailure;
|
||||
return Device::DeviceErrorHardwareFailure;
|
||||
}
|
||||
|
||||
// Set the current state
|
||||
device->setStateValue(gpioOutputRpiPowerValueStateTypeId, action.param(gpioOutputRpiPowerValueActionPowerValueParamTypeId).value());
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
} else if (deviceClass.vendorId() == beagleboneBlackVendorId) {
|
||||
if (action.actionTypeId() == gpioOutputBbbPowerValueActionTypeId) {
|
||||
@ -305,17 +304,17 @@ DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const
|
||||
|
||||
if (!success) {
|
||||
qCWarning(dcGpioController()) << "Could not set gpio value while execute action on" << device->name();
|
||||
return DeviceManager::DeviceErrorHardwareFailure;
|
||||
return Device::DeviceErrorHardwareFailure;
|
||||
}
|
||||
|
||||
// Set the current state
|
||||
device->setStateValue(gpioOutputBbbPowerValueStateTypeId, action.param(gpioOutputBbbPowerValueActionPowerValueParamTypeId).value());
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
void DevicePluginGpio::postSetupDevice(Device *device)
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
#include "hardware/gpiomonitor.h"
|
||||
#include "gpiodescriptor.h"
|
||||
#include "hardware/gpiomonitor.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
class DevicePluginGpio : public DevicePlugin
|
||||
{
|
||||
@ -39,10 +39,10 @@ class DevicePluginGpio : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginGpio();
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
void postSetupDevice(Device *device);
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ DevicePluginHttpCommander::DevicePluginHttpCommander()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginHttpCommander::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginHttpCommander::setupDevice(Device *device)
|
||||
{
|
||||
qDebug(dcHttpCommander()) << "Setup device" << device->name() << device->params();
|
||||
|
||||
@ -42,30 +42,30 @@ DeviceManager::DeviceSetupStatus DevicePluginHttpCommander::setupDevice(Device *
|
||||
QUrl url = device->paramValue(httpGetCommanderDeviceUrlParamTypeId).toUrl();
|
||||
if (!url.isValid()) {
|
||||
qDebug(dcHttpCommander()) << "Given URL is not valid";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == httpPutCommanderDeviceClassId) {
|
||||
QUrl url = device->paramValue(httpPutCommanderDeviceUrlParamTypeId).toUrl();
|
||||
if (!url.isValid()) {
|
||||
qDebug(dcHttpCommander()) << "Given URL is not valid";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == httpPostCommanderDeviceClassId) {
|
||||
QUrl url = device->paramValue(httpPostCommanderDeviceUrlParamTypeId).toUrl();
|
||||
if (!url.isValid()) {
|
||||
qDebug(dcHttpCommander()) << "Given URL is not valid";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ void DevicePluginHttpCommander::postSetupDevice(Device *device)
|
||||
}
|
||||
|
||||
|
||||
DeviceManager::DeviceError DevicePluginHttpCommander::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginHttpCommander::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (device->deviceClassId() == httpPostCommanderDeviceClassId) {
|
||||
|
||||
@ -91,9 +91,9 @@ DeviceManager::DeviceError DevicePluginHttpCommander::executeAction(Device *devi
|
||||
|
||||
m_httpRequests.insert(reply, device);
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
|
||||
}
|
||||
|
||||
@ -110,10 +110,10 @@ DeviceManager::DeviceError DevicePluginHttpCommander::executeAction(Device *devi
|
||||
|
||||
m_httpRequests.insert(reply, device);
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginHttpCommander::makeGetCall(Device *device)
|
||||
|
||||
@ -24,8 +24,7 @@
|
||||
#ifndef DEVICEPLUGINHTTPCOMMANDER_H
|
||||
#define DEVICEPLUGINHTTPCOMMANDER_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "plugintimer.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
@ -41,10 +40,10 @@ class DevicePluginHttpCommander : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginHttpCommander();
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void postSetupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private:
|
||||
PluginTimer *m_pluginTimer = nullptr;
|
||||
|
||||
@ -22,8 +22,7 @@
|
||||
|
||||
#include "devicepluginintertechno.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
#include "hardware/radio433/radio433.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
@ -36,10 +35,10 @@ DevicePluginIntertechno::DevicePluginIntertechno()
|
||||
}
|
||||
|
||||
|
||||
DeviceManager::DeviceError DevicePluginIntertechno::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginIntertechno::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (!hardwareManager()->radio433()->available())
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
QList<int> rawData;
|
||||
QByteArray binCode;
|
||||
@ -121,7 +120,7 @@ DeviceManager::DeviceError DevicePluginIntertechno::executeAction(Device *device
|
||||
}
|
||||
|
||||
if (binCode.length() != 16){
|
||||
return DeviceManager::DeviceErrorInvalidParameter;
|
||||
return Device::DeviceErrorInvalidParameter;
|
||||
}
|
||||
|
||||
// =======================================
|
||||
@ -160,9 +159,9 @@ DeviceManager::DeviceError DevicePluginIntertechno::executeAction(Device *device
|
||||
qCDebug(dcIntertechno) << "transmitted" << pluginName() << device->name() << "power: " << action.param(switchSetPowerActionPowerParamTypeId).value().toBool();
|
||||
} else {
|
||||
qCWarning(dcIntertechno) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param(switchSetPowerActionPowerParamTypeId).value().toBool();
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
void DevicePluginIntertechno::radioData(const QList<int> &rawData)
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef DEVICEPLUGININTERTECHNO_H
|
||||
#define DEVICEPLUGININTERTECHNO_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
class DevicePluginIntertechno : public DevicePlugin
|
||||
{
|
||||
@ -38,7 +38,7 @@ public:
|
||||
void radioData(const QList<int> &rawData);
|
||||
|
||||
public slots:
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ void DevicePluginKeba::init()
|
||||
connect(m_pluginTimer, &PluginTimer::timeout, this, &DevicePluginKeba::updateData);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginKeba::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginKeba::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcKebaKeContact()) << "Setting up a new device:" << device->name() << device->params();
|
||||
|
||||
@ -53,7 +53,7 @@ DeviceManager::DeviceSetupStatus DevicePluginKeba::setupDevice(Device *device)
|
||||
if (!m_kebaSocket->bind(QHostAddress::AnyIPv4, 7090)) {
|
||||
qCWarning(dcKebaKeContact()) << "Cannot bind to port" << 7090;
|
||||
delete m_kebaSocket;
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
connect(m_kebaSocket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));
|
||||
qCDebug(dcKebaKeContact()) << "Create keba socket";
|
||||
@ -64,16 +64,16 @@ DeviceManager::DeviceSetupStatus DevicePluginKeba::setupDevice(Device *device)
|
||||
//Check if the IP is empty
|
||||
if (address.isNull()) {
|
||||
delete m_kebaSocket;
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
// check if IP is already added to another keba device
|
||||
if(m_kebaDevices.keys().contains(address)){
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
m_kebaDevices.insert(address, device);
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
void DevicePluginKeba::postSetupDevice(Device *device)
|
||||
@ -109,7 +109,7 @@ void DevicePluginKeba::updateData()
|
||||
}
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginKeba::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginKeba::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
qCDebug(dcKebaKeContact()) << "Execute action" << device->name() << action.actionTypeId().toString();
|
||||
|
||||
@ -140,10 +140,10 @@ DeviceManager::DeviceError DevicePluginKeba::executeAction(Device *device, const
|
||||
m_kebaSocket->writeDatagram(datagram.data(),datagram.size(), QHostAddress(device->paramValue(wallboxDeviceIpParamTypeId).toString()) , 7090);
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginKeba::readPendingDatagrams()
|
||||
|
||||
@ -22,8 +22,7 @@
|
||||
#ifndef DEVICEPLUGINKEBA_H
|
||||
#define DEVICEPLUGINKEBA_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "plugintimer.h"
|
||||
|
||||
#include <QHash>
|
||||
@ -42,12 +41,12 @@ public:
|
||||
~DevicePluginKeba();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
|
||||
void postSetupDevice(Device* device) override;
|
||||
void deviceRemoved(Device* device) override;
|
||||
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
void updateData();
|
||||
|
||||
private:
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "devicepluginkodi.h"
|
||||
#include "plugin/device.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
#include "network/upnp/upnpdiscovery.h"
|
||||
#include "platform/platformzeroconfcontroller.h"
|
||||
@ -60,7 +60,7 @@ void DevicePluginKodi::init()
|
||||
connect(m_pluginTimer, &PluginTimer::timeout, this, &DevicePluginKodi::onPluginTimer);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginKodi::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginKodi::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcKodi) << "Setup Kodi device" << device->paramValue(kodiDeviceIpParamTypeId).toString();
|
||||
Kodi *kodi= new Kodi(QHostAddress(device->paramValue(kodiDeviceIpParamTypeId).toString()), 9090, this);
|
||||
@ -127,7 +127,7 @@ DeviceManager::DeviceSetupStatus DevicePluginKodi::setupDevice(Device *device)
|
||||
|
||||
kodi->connectKodi();
|
||||
|
||||
return DeviceManager::DeviceSetupStatusAsync;
|
||||
return Device::DeviceSetupStatusAsync;
|
||||
}
|
||||
|
||||
void DevicePluginKodi::deviceRemoved(Device *device)
|
||||
@ -138,7 +138,7 @@ void DevicePluginKodi::deviceRemoved(Device *device)
|
||||
kodi->deleteLater();
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginKodi::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginKodi::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params)
|
||||
Q_UNUSED(deviceClassId)
|
||||
@ -159,17 +159,17 @@ DeviceManager::DeviceError DevicePluginKodi::discoverDevices(const DeviceClassId
|
||||
serviceBrowser->deleteLater();
|
||||
});
|
||||
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginKodi::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginKodi::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (device->deviceClassId() == kodiDeviceClassId) {
|
||||
Kodi *kodi = m_kodis.key(device);
|
||||
|
||||
// check connection state
|
||||
if (!kodi->connected()) {
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
int commandId = -1;
|
||||
@ -214,12 +214,12 @@ DeviceManager::DeviceError DevicePluginKodi::executeAction(Device *device, const
|
||||
}
|
||||
} else {
|
||||
qWarning(dcKodi()) << "Unhandled action type" << action.actionTypeId();
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
m_pendingActions.insert(commandId, action.id());
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginKodi::onPluginTimer()
|
||||
@ -263,7 +263,7 @@ void DevicePluginKodi::onActionExecuted(int actionId, bool success)
|
||||
if (!m_pendingActions.contains(actionId)) {
|
||||
return;
|
||||
}
|
||||
emit actionExecutionFinished(m_pendingActions.value(actionId), success ? DeviceManager::DeviceErrorNoError : DeviceManager::DeviceErrorInvalidParameter);
|
||||
emit actionExecutionFinished(m_pendingActions.value(actionId), success ? Device::DeviceErrorNoError : Device::DeviceErrorInvalidParameter);
|
||||
}
|
||||
|
||||
void DevicePluginKodi::versionDataReceived(const QVariantMap &data)
|
||||
@ -277,7 +277,7 @@ void DevicePluginKodi::versionDataReceived(const QVariantMap &data)
|
||||
|
||||
if (version.value("major").toInt() < 6) {
|
||||
qCWarning(dcKodi) << "incompatible api version:" << apiVersion;
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
return;
|
||||
}
|
||||
kodi->update();
|
||||
@ -292,7 +292,7 @@ void DevicePluginKodi::onSetupFinished(const QVariantMap &data)
|
||||
QString kodiVersion = QString("%1.%2 (%3)").arg(version.value("major").toString()).arg(version.value("minor").toString()).arg(version.value("tag").toString());
|
||||
qCDebug(dcKodi) << "Version:" << kodiVersion;
|
||||
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusSuccess);
|
||||
|
||||
kodi->showNotification("Connected", 2000, "info");
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef DEVICEPLUGINKODI_H
|
||||
#define DEVICEPLUGINKODI_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "plugintimer.h"
|
||||
#include "kodi.h"
|
||||
|
||||
@ -42,10 +42,10 @@ public:
|
||||
~DevicePluginKodi();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private:
|
||||
PluginTimer *m_pluginTimer;
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "devicepluginleynew.h"
|
||||
#include "devicemanager.h"
|
||||
#include "plugininfo.h"
|
||||
#include "hardware/radio433/radio433.h"
|
||||
|
||||
@ -32,21 +31,21 @@ DevicePluginLeynew::DevicePluginLeynew()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginLeynew::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginLeynew::setupDevice(Device *device)
|
||||
{
|
||||
Q_UNUSED(device);
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginLeynew::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginLeynew::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (!hardwareManager()->radio433()->available()) {
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() != rfControllerDeviceClassId) {
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
QList<int> rawData;
|
||||
@ -64,7 +63,7 @@ DeviceManager::DeviceError DevicePluginLeynew::executeAction(Device *device, con
|
||||
binCode.append("111101010101");
|
||||
} else {
|
||||
qCWarning(dcLeynew) << "Could not get id of device: invalid parameter" << device->paramValue(rfControllerDeviceIdParamTypeId);
|
||||
return DeviceManager::DeviceErrorInvalidParameter;
|
||||
return Device::DeviceErrorInvalidParameter;
|
||||
}
|
||||
|
||||
int repetitions = 12;
|
||||
@ -115,7 +114,7 @@ DeviceManager::DeviceError DevicePluginLeynew::executeAction(Device *device, con
|
||||
} else if (action.actionTypeId() == rfControllerFade7ActionTypeId) {
|
||||
binCode.append("001100000000");
|
||||
} else {
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
// =======================================
|
||||
@ -147,7 +146,7 @@ DeviceManager::DeviceError DevicePluginLeynew::executeAction(Device *device, con
|
||||
qCDebug(dcLeynew) << "Transmitted" << pluginName() << device->name() << action.id();
|
||||
}else{
|
||||
qCWarning(dcLeynew) << "Could not transmitt" << pluginName() << device->name() << action.id();
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef DEVICEPLUGINLEYNEW_H
|
||||
#define DEVICEPLUGINLEYNEW_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
class DevicePluginLeynew : public DevicePlugin
|
||||
{
|
||||
@ -35,10 +35,10 @@ class DevicePluginLeynew : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginLeynew();
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
|
||||
public slots:
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -22,8 +22,7 @@
|
||||
|
||||
#include "devicepluginlgsmarttv.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
#include "network/networkaccessmanager.h"
|
||||
#include "network/upnp/upnpdiscovery.h"
|
||||
@ -45,7 +44,7 @@ void DevicePluginLgSmartTv::init()
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginLgSmartTv::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginLgSmartTv::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params)
|
||||
Q_UNUSED(deviceClassId)
|
||||
@ -53,10 +52,10 @@ DeviceManager::DeviceError DevicePluginLgSmartTv::discoverDevices(const DeviceCl
|
||||
qCDebug(dcLgSmartTv()) << "Start discovering";
|
||||
UpnpDiscoveryReply *reply = hardwareManager()->upnpDiscovery()->discoverDevices("udap:rootservice","UDAP/2.0");
|
||||
connect(reply, &UpnpDiscoveryReply::finished, this, &DevicePluginLgSmartTv::onUpnpDiscoveryFinished);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginLgSmartTv::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginLgSmartTv::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcLgSmartTv()) << "Setup LG smart TV" << device->name() << device->params();
|
||||
QHostAddress address = QHostAddress(device->paramValue(lgSmartTvDeviceHostAddressParamTypeId).toString());
|
||||
@ -68,7 +67,7 @@ DeviceManager::DeviceSetupStatus DevicePluginLgSmartTv::setupDevice(Device *devi
|
||||
// Check if we know the key from the pairing procedure
|
||||
if (!m_tvKeys.contains(device->paramValue(lgSmartTvDeviceUuidParamTypeId).toString())) {
|
||||
qCWarning(dcLgSmartTv) << "could not find any pairing key";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
// Use the key from the pairing procedure
|
||||
QString key = m_tvKeys.value(device->paramValue(lgSmartTvDeviceUuidParamTypeId).toString());
|
||||
@ -90,7 +89,7 @@ DeviceManager::DeviceSetupStatus DevicePluginLgSmartTv::setupDevice(Device *devi
|
||||
connect(m_pluginTimer, &PluginTimer::timeout, this, &DevicePluginLgSmartTv::onPluginTimer);
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
void DevicePluginLgSmartTv::deviceRemoved(Device *device)
|
||||
@ -115,13 +114,13 @@ void DevicePluginLgSmartTv::postSetupDevice(Device *device)
|
||||
pairTvDevice(device);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginLgSmartTv::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginLgSmartTv::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
TvDevice * tvDevice = m_tvList.key(device);
|
||||
|
||||
if (!tvDevice->reachable()) {
|
||||
qCWarning(dcLgSmartTv) << "Device not reachable";
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
if (action.actionTypeId() == lgSmartTvCommandVolumeUpActionTypeId) {
|
||||
@ -215,12 +214,12 @@ DeviceManager::DeviceError DevicePluginLgSmartTv::executeAction(Device *device,
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished);
|
||||
m_asyncActions.insert(reply, action.id());
|
||||
} else {
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginLgSmartTv::displayPin(const PairingTransactionId &pairingTransactionId, const DeviceDescriptor &deviceDescriptor)
|
||||
Device::DeviceError DevicePluginLgSmartTv::displayPin(const PairingTransactionId &pairingTransactionId, const DeviceDescriptor &deviceDescriptor)
|
||||
{
|
||||
Q_UNUSED(pairingTransactionId)
|
||||
|
||||
@ -231,10 +230,10 @@ DeviceManager::DeviceError DevicePluginLgSmartTv::displayPin(const PairingTransa
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished);
|
||||
|
||||
m_showPinReply.append(reply);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginLgSmartTv::confirmPairing(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms, const QString &secret)
|
||||
Device::DeviceSetupStatus DevicePluginLgSmartTv::confirmPairing(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms, const QString &secret)
|
||||
{
|
||||
Q_UNUSED(deviceClassId)
|
||||
|
||||
@ -247,7 +246,7 @@ DeviceManager::DeviceSetupStatus DevicePluginLgSmartTv::confirmPairing(const Pai
|
||||
m_setupPairingTv.insert(reply, pairingTransactionId);
|
||||
m_tvKeys.insert(params.paramValue(lgSmartTvDeviceUuidParamTypeId).toString(), secret);
|
||||
|
||||
return DeviceManager::DeviceSetupStatusAsync;
|
||||
return Device::DeviceSetupStatusAsync;
|
||||
}
|
||||
|
||||
void DevicePluginLgSmartTv::pairTvDevice(Device *device)
|
||||
@ -350,7 +349,7 @@ void DevicePluginLgSmartTv::onNetworkManagerReplyFinished()
|
||||
PairingTransactionId pairingTransactionId = m_setupPairingTv.take(reply);
|
||||
if(status != 200) {
|
||||
qCWarning(dcLgSmartTv) << "pair TV request error:" << status << reply->errorString();
|
||||
emit pairingFinished(pairingTransactionId, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit pairingFinished(pairingTransactionId, Device::DeviceSetupStatusFailure);
|
||||
} else {
|
||||
// End pairing before calling setupDevice, which will always try to pair
|
||||
QPair<QNetworkRequest, QByteArray> request = TvDevice::createEndPairingRequest(reply->request().url());
|
||||
@ -362,9 +361,9 @@ void DevicePluginLgSmartTv::onNetworkManagerReplyFinished()
|
||||
PairingTransactionId pairingTransactionId = m_setupEndPairingTv.take(reply);
|
||||
if(status != 200) {
|
||||
qCWarning(dcLgSmartTv) << "end pairing TV request error:" << status << reply->errorString();
|
||||
emit pairingFinished(pairingTransactionId, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit pairingFinished(pairingTransactionId, Device::DeviceSetupStatusFailure);
|
||||
} else {
|
||||
emit pairingFinished(pairingTransactionId, DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit pairingFinished(pairingTransactionId, Device::DeviceSetupStatusSuccess);
|
||||
}
|
||||
} else if (m_asyncSetup.keys().contains(reply)) {
|
||||
Device *device = m_asyncSetup.take(reply);
|
||||
@ -420,10 +419,10 @@ void DevicePluginLgSmartTv::onNetworkManagerReplyFinished()
|
||||
} else if (m_asyncActions.keys().contains(reply)) {
|
||||
ActionId actionId = m_asyncActions.value(reply);
|
||||
if(status != 200) {
|
||||
emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorHardwareNotAvailable);
|
||||
emit actionExecutionFinished(actionId, Device::DeviceErrorHardwareNotAvailable);
|
||||
qCWarning(dcLgSmartTv) << "Action request error:" << status << reply->errorString();
|
||||
} else {
|
||||
emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(actionId, Device::DeviceErrorNoError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
#include "tvdevice.h"
|
||||
#include "plugintimer.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "network/upnp/upnpdevicedescriptor.h"
|
||||
|
||||
class DevicePluginLgSmartTv : public DevicePlugin
|
||||
@ -40,14 +40,14 @@ public:
|
||||
~DevicePluginLgSmartTv();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
void postSetupDevice(Device *device) override;
|
||||
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
DeviceManager::DeviceError displayPin(const PairingTransactionId &pairingTransactionId, const DeviceDescriptor &deviceDescriptor) override;
|
||||
DeviceManager::DeviceSetupStatus confirmPairing(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms, const QString &secret) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError displayPin(const PairingTransactionId &pairingTransactionId, const DeviceDescriptor &deviceDescriptor) override;
|
||||
Device::DeviceSetupStatus confirmPairing(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms, const QString &secret) override;
|
||||
|
||||
private:
|
||||
PluginTimer *m_pluginTimer = nullptr;
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QXmlStreamAttributes>
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "tveventhandler.h"
|
||||
|
||||
class TvDevice : public QObject
|
||||
|
||||
@ -22,8 +22,7 @@
|
||||
|
||||
#include "devicepluginmailnotification.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
#include <QDebug>
|
||||
@ -39,7 +38,7 @@ DevicePluginMailNotification::~DevicePluginMailNotification()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginMailNotification::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginMailNotification::setupDevice(Device *device)
|
||||
{
|
||||
// Custom mail
|
||||
if(device->deviceClassId() == customMailDeviceClassId) {
|
||||
@ -56,7 +55,7 @@ DeviceManager::DeviceSetupStatus DevicePluginMailNotification::setupDevice(Devic
|
||||
} else if(device->paramValue(customMailDeviceAuthenticationParamTypeId).toString() == "LOGIN") {
|
||||
smtpClient->setAuthenticationMethod(SmtpClient::AuthenticationMethodLogin);
|
||||
} else {
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
if(device->paramValue(customMailDeviceEncryptionParamTypeId).toString() == "NONE") {
|
||||
@ -66,7 +65,7 @@ DeviceManager::DeviceSetupStatus DevicePluginMailNotification::setupDevice(Devic
|
||||
} else if(device->paramValue(customMailDeviceEncryptionParamTypeId).toString() == "TLS") {
|
||||
smtpClient->setEncryptionType(SmtpClient::EncryptionTypeTLS);
|
||||
} else {
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
QString recipientsString = device->paramValue(customMailDeviceCustomRecipientParamTypeId).toString();
|
||||
@ -81,29 +80,29 @@ DeviceManager::DeviceSetupStatus DevicePluginMailNotification::setupDevice(Devic
|
||||
|
||||
smtpClient->testLogin();
|
||||
|
||||
return DeviceManager::DeviceSetupStatusAsync;
|
||||
return Device::DeviceSetupStatusAsync;
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginMailNotification::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginMailNotification::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (device->deviceClassId() == customMailDeviceClassId) {
|
||||
if(action.actionTypeId() == customMailNotifyActionTypeId) {
|
||||
SmtpClient *smtpClient = m_clients.key(device);
|
||||
if (!smtpClient) {
|
||||
qCWarning(dcMailNotification()) << "Could not find SMTP client for " << device;
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
smtpClient->sendMail(action.param(customMailNotifyActionTitleParamTypeId).value().toString(),
|
||||
action.param(customMailNotifyActionBodyParamTypeId).value().toString(),
|
||||
action.id());
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginMailNotification::deviceRemoved(Device *device)
|
||||
@ -119,10 +118,10 @@ void DevicePluginMailNotification::testLoginFinished(const bool &success)
|
||||
Device *device = m_clients.value(smtpClient);
|
||||
if (success) {
|
||||
qCDebug(dcMailNotification()) << "Email login test successfull";
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusSuccess);
|
||||
} else {
|
||||
qCWarning(dcMailNotification()) << "Email login test failed";
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
if(m_clients.contains(smtpClient)) {
|
||||
m_clients.remove(smtpClient);
|
||||
}
|
||||
@ -134,9 +133,9 @@ void DevicePluginMailNotification::sendMailFinished(const bool &success, const A
|
||||
{
|
||||
if (success) {
|
||||
qCDebug(dcMailNotification()) << "Email sent successfully";
|
||||
emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(actionId, Device::DeviceErrorNoError);
|
||||
} else {
|
||||
qCWarning(dcMailNotification()) << "Email sending failed";
|
||||
emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorDeviceNotFound);
|
||||
emit actionExecutionFinished(actionId, Device::DeviceErrorDeviceNotFound);
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef DEVICEPLUGINMAILNOTIFICATION_H
|
||||
#define DEVICEPLUGINMAILNOTIFICATION_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "smtpclient.h"
|
||||
|
||||
class DevicePluginMailNotification : public DevicePlugin
|
||||
@ -37,8 +37,8 @@ public:
|
||||
explicit DevicePluginMailNotification();
|
||||
~DevicePluginMailNotification();
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
#include <QStringList>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcSmtpClient)
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "devicepluginmqttclient.h"
|
||||
#include "plugin/device.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
#include "network/mqtt/mqttprovider.h"
|
||||
|
||||
@ -32,7 +32,7 @@ DevicePluginMqttClient::DevicePluginMqttClient()
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginMqttClient::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginMqttClient::setupDevice(Device *device)
|
||||
{
|
||||
MqttClient *client = nullptr;
|
||||
if (device->deviceClassId() == internalMqttClientDeviceClassId) {
|
||||
@ -50,7 +50,7 @@ DeviceManager::DeviceSetupStatus DevicePluginMqttClient::setupDevice(Device *dev
|
||||
});
|
||||
connect(client, &MqttClient::subscribeResult, this, [this, device](quint16 packetId, const Mqtt::SubscribeReturnCodes returnCodes){
|
||||
Q_UNUSED(packetId)
|
||||
emit deviceSetupFinished(device, returnCodes.first() == Mqtt::SubscribeReturnCodeFailure ? DeviceManager::DeviceSetupStatusFailure : DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit deviceSetupFinished(device, returnCodes.first() == Mqtt::SubscribeReturnCodeFailure ? Device::DeviceSetupStatusFailure : Device::DeviceSetupStatusSuccess);
|
||||
});
|
||||
connect(client, &MqttClient::publishReceived, this, &DevicePluginMqttClient::publishReceived);
|
||||
connect(client, &MqttClient::published, this, &DevicePluginMqttClient::published);
|
||||
@ -59,11 +59,11 @@ DeviceManager::DeviceSetupStatus DevicePluginMqttClient::setupDevice(Device *dev
|
||||
subscribe(device);
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusAsync;
|
||||
return Device::DeviceSetupStatusAsync;
|
||||
}
|
||||
|
||||
|
||||
DeviceManager::DeviceError DevicePluginMqttClient::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginMqttClient::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
ParamTypeId topicParamTypeId = internalMqttClientTriggerActionTopicParamTypeId;
|
||||
ParamTypeId payloadParamTypeId = internalMqttClientTriggerActionDataParamTypeId;
|
||||
@ -80,7 +80,7 @@ DeviceManager::DeviceError DevicePluginMqttClient::executeAction(Device *device,
|
||||
MqttClient *client = m_clients.value(device);
|
||||
if (!client) {
|
||||
qCWarning(dcMqttclient) << "No valid MQTT client for device" << device->name();
|
||||
return DeviceManager::DeviceErrorDeviceNotFound;
|
||||
return Device::DeviceErrorDeviceNotFound;
|
||||
}
|
||||
Mqtt::QoS qos = Mqtt::QoS0;
|
||||
switch (action.param(qosParamTypeId).value().toInt()) {
|
||||
@ -100,7 +100,7 @@ DeviceManager::DeviceError DevicePluginMqttClient::executeAction(Device *device,
|
||||
action.param(retainParamTypeId).value().toBool());
|
||||
m_pendingPublishes.insert(packetId, action);
|
||||
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
void DevicePluginMqttClient::subscribe(Device *device)
|
||||
@ -146,7 +146,7 @@ void DevicePluginMqttClient::published(quint16 packetId)
|
||||
return;
|
||||
}
|
||||
|
||||
emit actionExecutionFinished(m_pendingPublishes.take(packetId).id(), DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(m_pendingPublishes.take(packetId).id(), Device::DeviceErrorNoError);
|
||||
}
|
||||
|
||||
void DevicePluginMqttClient::deviceRemoved(Device *device)
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef DEVICEPLUGINMQTTCLIENT_H
|
||||
#define DEVICEPLUGINMQTTCLIENT_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QDebug>
|
||||
@ -40,10 +40,10 @@ class DevicePluginMqttClient: public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginMqttClient();
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private slots:
|
||||
void subscribe(Device *device);
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "devicepluginnetatmo.h"
|
||||
#include "plugin/device.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
#include "network/networkaccessmanager.h"
|
||||
|
||||
@ -44,7 +44,7 @@ void DevicePluginNetatmo::init()
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device)
|
||||
{
|
||||
if (device->deviceClassId() == netatmoConnectionDeviceClassId) {
|
||||
qCDebug(dcNetatmo) << "Setup netatmo connection" << device->name() << device->params();
|
||||
@ -65,7 +65,7 @@ DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device
|
||||
connect(authentication, &OAuth2::authenticationChanged, this, &DevicePluginNetatmo::onAuthenticationChanged);
|
||||
|
||||
authentication->startAuthentication();
|
||||
return DeviceManager::DeviceSetupStatusAsync;
|
||||
return Device::DeviceSetupStatusAsync;
|
||||
|
||||
} else if (device->deviceClassId() == indoorDeviceClassId) {
|
||||
qCDebug(dcNetatmo) << "Setup netatmo indoor base station" << device->params();
|
||||
@ -76,7 +76,7 @@ DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device
|
||||
m_indoorDevices.insert(indoor, device);
|
||||
connect(indoor, SIGNAL(statesChanged()), this, SLOT(onIndoorStatesChanged()));
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
} else if (device->deviceClassId() == outdoorDeviceClassId) {
|
||||
qCDebug(dcNetatmo) << "Setup netatmo outdoor module" << device->params();
|
||||
NetatmoOutdoorModule *outdoor = new NetatmoOutdoorModule(device->paramValue(outdoorDeviceNameParamTypeId).toString(),
|
||||
@ -87,9 +87,9 @@ DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device
|
||||
m_outdoorDevices.insert(outdoor, device);
|
||||
connect(outdoor, SIGNAL(statesChanged()), this, SLOT(onOutdoorStatesChanged()));
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
void DevicePluginNetatmo::deviceRemoved(Device *device)
|
||||
@ -129,12 +129,12 @@ void DevicePluginNetatmo::postSetupDevice(Device *device)
|
||||
}
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginNetatmo::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginNetatmo::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
Q_UNUSED(device)
|
||||
Q_UNUSED(action)
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
void DevicePluginNetatmo::refreshData(Device *device, const QString &token)
|
||||
@ -291,11 +291,11 @@ void DevicePluginNetatmo::onAuthenticationChanged()
|
||||
if (m_asyncSetups.contains(device)) {
|
||||
m_asyncSetups.removeAll(device);
|
||||
if (authentication->authenticated()) {
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusSuccess);
|
||||
refreshData(device, authentication->token());
|
||||
} else {
|
||||
authentication->deleteLater();
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
#define DEVICEPLUGINNETATMO_H
|
||||
|
||||
#include "plugintimer.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "network/oauth2.h"
|
||||
#include "netatmobasestation.h"
|
||||
#include "netatmooutdoormodule.h"
|
||||
@ -43,12 +43,12 @@ public:
|
||||
~DevicePluginNetatmo();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
void postSetupDevice(Device *device) override;
|
||||
|
||||
public slots:
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private:
|
||||
PluginTimer *m_pluginTimer = nullptr;
|
||||
|
||||
@ -23,8 +23,7 @@
|
||||
|
||||
#include "devicepluginnetworkdetector.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
#include <QDebug>
|
||||
@ -50,7 +49,7 @@ void DevicePluginNetworkDetector::init()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginNetworkDetector::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginNetworkDetector::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcNetworkDetector()) << "Setup" << device->name() << device->params();
|
||||
DeviceMonitor *monitor = new DeviceMonitor(device->name(),
|
||||
@ -81,25 +80,25 @@ DeviceManager::DeviceSetupStatus DevicePluginNetworkDetector::setupDevice(Device
|
||||
m_broadcastPing->run();
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginNetworkDetector::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginNetworkDetector::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params)
|
||||
|
||||
|
||||
if (deviceClassId != networkDeviceDeviceClassId)
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
|
||||
if (m_discovery->isRunning()) {
|
||||
qCWarning(dcNetworkDetector()) << "Network discovery already running";
|
||||
return DeviceManager::DeviceErrorDeviceInUse;
|
||||
return Device::DeviceErrorDeviceInUse;
|
||||
}
|
||||
|
||||
m_discovery->discoverHosts(25);
|
||||
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
void DevicePluginNetworkDetector::deviceRemoved(Device *device)
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
#ifndef DEVICEPLUGINNETWORKDETECTOR_H
|
||||
#define DEVICEPLUGINNETWORKDETECTOR_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "host.h"
|
||||
#include "discovery.h"
|
||||
#include "plugintimer.h"
|
||||
@ -48,8 +48,8 @@ public:
|
||||
|
||||
void init() override;
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
|
||||
|
||||
@ -21,8 +21,7 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "devicepluginopenweathermap.h"
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
#include <QDebug>
|
||||
@ -62,10 +61,10 @@ void DevicePluginOpenweathermap::init()
|
||||
connect(m_pluginTimer, &PluginTimer::timeout, this, &DevicePluginOpenweathermap::onPluginTimer);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginOpenweathermap::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginOpenweathermap::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
if (deviceClassId != openweathermapDeviceClassId) {
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
QString location = params.paramValue(openweathermapDiscoveryLocationParamTypeId).toString();
|
||||
@ -76,26 +75,26 @@ DeviceManager::DeviceError DevicePluginOpenweathermap::discoverDevices(const Dev
|
||||
} else {
|
||||
search(location);
|
||||
}
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginOpenweathermap::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginOpenweathermap::setupDevice(Device *device)
|
||||
{
|
||||
if (device->deviceClassId() != openweathermapDeviceClassId)
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
|
||||
update(device);
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginOpenweathermap::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginOpenweathermap::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if(action.actionTypeId() == openweathermapRefreshWeatherActionTypeId){
|
||||
update(device);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginOpenweathermap::deviceRemoved(Device *device)
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
#define DEVICEPLUGINOPENWEATHERMAP_H
|
||||
|
||||
#include "plugintimer.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "network/networkaccessmanager.h"
|
||||
|
||||
#include <QTimer>
|
||||
@ -42,9 +42,9 @@ public:
|
||||
~DevicePluginOpenweathermap();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
*/
|
||||
|
||||
#include "devicepluginosdomotics.h"
|
||||
#include "plugin/device.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
#include "network/networkaccessmanager.h"
|
||||
|
||||
@ -67,7 +67,7 @@ void DevicePluginOsdomotics::init()
|
||||
connect(m_pluginTimer, &PluginTimer::timeout, this, &DevicePluginOsdomotics::onPluginTimer);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginOsdomotics::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginOsdomotics::setupDevice(Device *device)
|
||||
{
|
||||
if (device->deviceClassId() == rplRouterDeviceClassId) {
|
||||
qCDebug(dcOsdomotics) << "Setup RPL router" << device->paramValue(rplRouterDeviceRplHostParamTypeId).toString();
|
||||
@ -75,7 +75,7 @@ DeviceManager::DeviceSetupStatus DevicePluginOsdomotics::setupDevice(Device *dev
|
||||
|
||||
if (address.isNull()) {
|
||||
qCWarning(dcOsdomotics) << "Got invalid address" << device->paramValue(rplRouterDeviceRplHostParamTypeId).toString();
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
QUrl url;
|
||||
@ -86,13 +86,13 @@ DeviceManager::DeviceSetupStatus DevicePluginOsdomotics::setupDevice(Device *dev
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginOsdomotics::onNetworkReplyFinished);
|
||||
m_asyncSetup.insert(reply, device);
|
||||
|
||||
return DeviceManager::DeviceSetupStatusAsync;
|
||||
return Device::DeviceSetupStatusAsync;
|
||||
} else if (device->deviceClassId() == merkurNodeDeviceClassId) {
|
||||
qCDebug(dcOsdomotics) << "Setup Merkur node" << device->paramValue(merkurNodeDeviceHostParamTypeId).toString();
|
||||
device->setParentId(DeviceId(device->paramValue(merkurNodeDeviceRouterParamTypeId).toString()));
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
void DevicePluginOsdomotics::deviceRemoved(Device *device)
|
||||
@ -105,7 +105,7 @@ void DevicePluginOsdomotics::postSetupDevice(Device *device)
|
||||
updateNode(device);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginOsdomotics::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginOsdomotics::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (device->deviceClassId() == merkurNodeDeviceClassId) {
|
||||
if (action.actionTypeId() == merkurNodeToggleLedActionTypeId) {
|
||||
@ -122,17 +122,17 @@ DeviceManager::DeviceError DevicePluginOsdomotics::executeAction(Device *device,
|
||||
if (reply->error() != CoapReply::NoError) {
|
||||
qCWarning(dcOsdomotics) << "CoAP reply finished with error" << reply->errorString();
|
||||
reply->deleteLater();
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
}
|
||||
|
||||
m_toggleLightRequests.insert(reply, action);
|
||||
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginOsdomotics::scanNodes(Device *device)
|
||||
@ -243,7 +243,7 @@ void DevicePluginOsdomotics::onNetworkReplyFinished()
|
||||
// check HTTP status code
|
||||
if (status != 200) {
|
||||
qCWarning(dcOsdomotics) << "Setup reply HTTP error:" << reply->errorString();
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
reply->deleteLater();
|
||||
return;
|
||||
}
|
||||
@ -251,14 +251,14 @@ void DevicePluginOsdomotics::onNetworkReplyFinished()
|
||||
QByteArray data = reply->readAll();
|
||||
parseNodes(device, data);
|
||||
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusSuccess);
|
||||
} else if (m_asyncNodeRescans.contains(reply)) {
|
||||
Device *device = m_asyncSetup.take(reply);
|
||||
|
||||
// check HTTP status code
|
||||
if (status != 200) {
|
||||
qCWarning(dcOsdomotics) << "Setup reply HTTP error:" << reply->errorString();
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
reply->deleteLater();
|
||||
return;
|
||||
}
|
||||
@ -296,11 +296,11 @@ void DevicePluginOsdomotics::coapReplyFinished(CoapReply *reply)
|
||||
if (reply->error() != CoapReply::NoError) {
|
||||
qCWarning(dcOsdomotics) << "CoAP toggle reply finished with error" << reply->errorString();
|
||||
reply->deleteLater();
|
||||
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorHardwareFailure);
|
||||
emit actionExecutionFinished(action.id(), Device::DeviceErrorHardwareFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(action.id(), Device::DeviceErrorNoError);
|
||||
} else if (m_updateRequests.contains(reply)) {
|
||||
Device *device = m_updateRequests.take(reply);
|
||||
if (reply->error() != CoapReply::NoError) {
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef DEVICEPLUGINOSDOMOTICS_H
|
||||
#define DEVICEPLUGINOSDOMOTICS_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QDebug>
|
||||
@ -43,10 +43,10 @@ public:
|
||||
~DevicePluginOsdomotics();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
void postSetupDevice(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private:
|
||||
PluginTimer *m_pluginTimer = nullptr;
|
||||
|
||||
@ -24,8 +24,7 @@
|
||||
|
||||
#include "devicepluginphilipshue.h"
|
||||
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/device.h"
|
||||
#include "devices/device.h"
|
||||
#include "types/param.h"
|
||||
#include "plugininfo.h"
|
||||
#include "network/upnp/upnpdiscovery.h"
|
||||
@ -78,7 +77,7 @@ void DevicePluginPhilipsHue::init()
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginPhilipsHue::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginPhilipsHue::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params)
|
||||
Q_UNUSED(deviceClassId)
|
||||
@ -165,10 +164,10 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::discoverDevices(const DeviceC
|
||||
finishDiscovery(discovery);
|
||||
});
|
||||
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *device)
|
||||
{
|
||||
// Update the name on the bridge if the user changes the device name
|
||||
connect(device, &Device::nameChanged, this, &DevicePluginPhilipsHue::onDeviceNameChanged);
|
||||
@ -187,7 +186,7 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev
|
||||
m_bridges.insert(b, device);
|
||||
device->setStateValue(bridgeConnectedStateTypeId, true);
|
||||
discoverBridgeDevices(b);
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,7 +202,7 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev
|
||||
m_bridges.insert(bridge, device);
|
||||
|
||||
discoverBridgeDevices(bridge);
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
// Hue color light
|
||||
@ -224,7 +223,7 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev
|
||||
|
||||
refreshLight(device);
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
// Hue color temperature light
|
||||
@ -245,7 +244,7 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev
|
||||
|
||||
refreshLight(device);
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
// Hue white light
|
||||
@ -266,7 +265,7 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev
|
||||
m_lights.insert(hueLight, device);
|
||||
refreshLight(device);
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
// Hue remote
|
||||
@ -286,7 +285,7 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev
|
||||
connect(hueRemote, &HueRemote::buttonPressed, this, &DevicePluginPhilipsHue::onRemoteButtonEvent);
|
||||
|
||||
m_remotes.insert(hueRemote, device);
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
// Hue tap
|
||||
@ -300,14 +299,47 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev
|
||||
connect(hueTap, &HueRemote::buttonPressed, this, &DevicePluginPhilipsHue::onRemoteButtonEvent);
|
||||
|
||||
m_remotes.insert(hueTap, device);
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
// Hue Motion sensor
|
||||
if (device->deviceClassId() == motionSensorDeviceClassId) {
|
||||
qCDebug(dcPhilipsHue) << "Setup Hue motion sensor" << device->params();
|
||||
|
||||
HueIndoorSensor *motionSensor = new HueIndoorSensor(this);
|
||||
motionSensor->setTimeout(device->setting(motionSensorSettingsTimeoutParamTypeId).toUInt());
|
||||
motionSensor->setUuid(device->paramValue(motionSensorDeviceUuidParamTypeId).toString());
|
||||
motionSensor->setModelId(device->paramValue(motionSensorDeviceModelIdParamTypeId).toString());
|
||||
motionSensor->setTemperatureSensorId(device->paramValue(motionSensorDeviceSensorIdTemperatureParamTypeId).toInt());
|
||||
motionSensor->setTemperatureSensorUuid(device->paramValue(motionSensorDeviceSensorUuidTemperatureParamTypeId).toString());
|
||||
motionSensor->setPresenceSensorId(device->paramValue(motionSensorDeviceSensorIdPresenceParamTypeId).toInt());
|
||||
motionSensor->setPresenceSensorUuid(device->paramValue(motionSensorDeviceSensorUuidPresenceParamTypeId).toString());
|
||||
motionSensor->setLightSensorId(device->paramValue(motionSensorDeviceSensorIdLightParamTypeId).toInt());
|
||||
motionSensor->setLightSensorUuid(device->paramValue(motionSensorDeviceSensorUuidLightParamTypeId).toString());
|
||||
|
||||
connect(motionSensor, &HueMotionSensor::reachableChanged, this, &DevicePluginPhilipsHue::onMotionSensorReachableChanged);
|
||||
connect(motionSensor, &HueMotionSensor::batteryLevelChanged, this, &DevicePluginPhilipsHue::onMotionSensorBatteryLevelChanged);
|
||||
connect(motionSensor, &HueMotionSensor::temperatureChanged, this, &DevicePluginPhilipsHue::onMotionSensorTemperatureChanged);
|
||||
connect(motionSensor, &HueMotionSensor::presenceChanged, this, &DevicePluginPhilipsHue::onMotionSensorPresenceChanged);
|
||||
connect(motionSensor, &HueMotionSensor::lightIntensityChanged, this, &DevicePluginPhilipsHue::onMotionSensorLightIntensityChanged);
|
||||
|
||||
connect(device, &Device::settingChanged, motionSensor, [motionSensor](const ParamTypeId ¶mTypeId, const QVariant &value){
|
||||
if (paramTypeId == motionSensorSettingsTimeoutParamTypeId) {
|
||||
motionSensor->setTimeout(value.toUInt());
|
||||
}
|
||||
});
|
||||
|
||||
m_motionSensors.insert(motionSensor, device);
|
||||
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
// Hue Outdoor sensor
|
||||
if (device->deviceClassId() == outdoorSensorDeviceClassId) {
|
||||
qCDebug(dcPhilipsHue) << "Setup Hue Outdoor sensor" << device->params();
|
||||
|
||||
HueOutdoorSensor *outdoorSensor = new HueOutdoorSensor(this);
|
||||
HueMotionSensor *outdoorSensor = new HueOutdoorSensor(this);
|
||||
outdoorSensor->setTimeout(device->setting(outdoorSensorSettingsTimeoutParamTypeId).toUInt());
|
||||
outdoorSensor->setUuid(device->paramValue(outdoorSensorDeviceUuidParamTypeId).toString());
|
||||
outdoorSensor->setModelId(device->paramValue(outdoorSensorDeviceModelIdParamTypeId).toString());
|
||||
outdoorSensor->setTemperatureSensorId(device->paramValue(outdoorSensorDeviceSensorIdTemperatureParamTypeId).toInt());
|
||||
@ -317,20 +349,26 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev
|
||||
outdoorSensor->setLightSensorId(device->paramValue(outdoorSensorDeviceSensorIdLightParamTypeId).toInt());
|
||||
outdoorSensor->setLightSensorUuid(device->paramValue(outdoorSensorDeviceSensorUuidLightParamTypeId).toString());
|
||||
|
||||
connect(outdoorSensor, &HueOutdoorSensor::reachableChanged, this, &DevicePluginPhilipsHue::onOutdoorSensorReachableChanged);
|
||||
connect(outdoorSensor, &HueOutdoorSensor::batteryLevelChanged, this, &DevicePluginPhilipsHue::onOutdoorSensorBatteryLevelChanged);
|
||||
connect(outdoorSensor, &HueOutdoorSensor::temperatureChanged, this, &DevicePluginPhilipsHue::onOutdoorSensorTemperatureChanged);
|
||||
connect(outdoorSensor, &HueOutdoorSensor::presenceChanged, this, &DevicePluginPhilipsHue::onOutdoorSensorPresenceChanged);
|
||||
connect(outdoorSensor, &HueOutdoorSensor::lightIntensityChanged, this, &DevicePluginPhilipsHue::onOutdoorSensorLightIntensityChanged);
|
||||
connect(outdoorSensor, &HueMotionSensor::reachableChanged, this, &DevicePluginPhilipsHue::onMotionSensorReachableChanged);
|
||||
connect(outdoorSensor, &HueMotionSensor::batteryLevelChanged, this, &DevicePluginPhilipsHue::onMotionSensorBatteryLevelChanged);
|
||||
connect(outdoorSensor, &HueMotionSensor::temperatureChanged, this, &DevicePluginPhilipsHue::onMotionSensorTemperatureChanged);
|
||||
connect(outdoorSensor, &HueMotionSensor::presenceChanged, this, &DevicePluginPhilipsHue::onMotionSensorPresenceChanged);
|
||||
connect(outdoorSensor, &HueMotionSensor::lightIntensityChanged, this, &DevicePluginPhilipsHue::onMotionSensorLightIntensityChanged);
|
||||
|
||||
m_outdoorSensors.insert(outdoorSensor, device);
|
||||
connect(device, &Device::settingChanged, outdoorSensor, [outdoorSensor](const ParamTypeId ¶mTypeId, const QVariant &value){
|
||||
if (paramTypeId == outdoorSensorSettingsTimeoutParamTypeId) {
|
||||
outdoorSensor->setTimeout(value.toUInt());
|
||||
}
|
||||
});
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
m_motionSensors.insert(outdoorSensor, device);
|
||||
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
qCWarning(dcPhilipsHue()) << "Unhandled setupDevice call" << device->deviceClassId();
|
||||
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
void DevicePluginPhilipsHue::deviceRemoved(Device *device)
|
||||
@ -365,19 +403,19 @@ void DevicePluginPhilipsHue::deviceRemoved(Device *device)
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == outdoorSensorDeviceClassId) {
|
||||
HueOutdoorSensor *outdoorSensor = m_outdoorSensors.key(device);
|
||||
m_outdoorSensors.remove(outdoorSensor);
|
||||
HueMotionSensor *outdoorSensor = m_motionSensors.key(device);
|
||||
m_motionSensors.remove(outdoorSensor);
|
||||
outdoorSensor->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::confirmPairing(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms, const QString &secret)
|
||||
Device::DeviceSetupStatus DevicePluginPhilipsHue::confirmPairing(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms, const QString &secret)
|
||||
{
|
||||
Q_UNUSED(secret)
|
||||
|
||||
qCDebug(dcPhilipsHue()) << "Confirming pairing for transactionId" << pairingTransactionId;
|
||||
if (deviceClassId != bridgeDeviceClassId)
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
|
||||
PairingInfo *pairingInfo = new PairingInfo(this);
|
||||
pairingInfo->setPairingTransactionId(pairingTransactionId);
|
||||
@ -395,7 +433,7 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::confirmPairing(const Pa
|
||||
|
||||
m_pairingRequests.insert(reply, pairingInfo);
|
||||
|
||||
return DeviceManager::DeviceSetupStatusAsync;
|
||||
return Device::DeviceSetupStatusAsync;
|
||||
}
|
||||
|
||||
void DevicePluginPhilipsHue::networkManagerReplyReady()
|
||||
@ -520,7 +558,7 @@ void DevicePluginPhilipsHue::networkManagerReplyReady()
|
||||
if (status != 200 || reply->error() != QNetworkReply::NoError) {
|
||||
qCWarning(dcPhilipsHue) << "Execute Hue Light action request error:" << status << reply->errorString();
|
||||
bridgeReachableChanged(actionInfo.first, false);
|
||||
emit actionExecutionFinished(actionInfo.second, DeviceManager::DeviceErrorHardwareNotAvailable);
|
||||
emit actionExecutionFinished(actionInfo.second, Device::DeviceErrorHardwareNotAvailable);
|
||||
return;
|
||||
}
|
||||
processActionResponse(actionInfo.first, actionInfo.second, reply->readAll());
|
||||
@ -578,7 +616,7 @@ void DevicePluginPhilipsHue::finishDiscovery(DevicePluginPhilipsHue::DiscoveryJo
|
||||
delete job;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginPhilipsHue::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
qCDebug(dcPhilipsHue) << "Execute action" << action.actionTypeId() << action.params();
|
||||
|
||||
@ -588,7 +626,7 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device,
|
||||
|
||||
if (!light->reachable()) {
|
||||
qCWarning(dcPhilipsHue) << "Light" << light->name() << "not reachable";
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
if (action.actionTypeId() == colorLightPowerActionTypeId) {
|
||||
@ -596,39 +634,39 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device,
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
||||
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
} else if (action.actionTypeId() == colorLightColorActionTypeId) {
|
||||
QPair<QNetworkRequest, QByteArray> request = light->createSetColorRequest(action.param(colorLightColorActionColorParamTypeId).value().value<QColor>());
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
||||
m_asyncActions.insert(reply,QPair<Device *, ActionId>(device, action.id()));
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
} else if (action.actionTypeId() == colorLightBrightnessActionTypeId) {
|
||||
QPair<QNetworkRequest, QByteArray> request = light->createSetBrightnessRequest(percentageToBrightness(action.param(colorLightBrightnessActionBrightnessParamTypeId).value().toInt()));
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
||||
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
} else if (action.actionTypeId() == colorLightEffectActionTypeId) {
|
||||
QPair<QNetworkRequest, QByteArray> request = light->createSetEffectRequest(action.param(colorLightEffectActionEffectParamTypeId).value().toString());
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
||||
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
} else if (action.actionTypeId() == colorLightAlertActionTypeId) {
|
||||
QPair<QNetworkRequest, QByteArray> request = light->createFlashRequest(action.param(colorLightAlertActionAlertParamTypeId).value().toString());
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
||||
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
} else if (action.actionTypeId() == colorLightColorTemperatureActionTypeId) {
|
||||
QPair<QNetworkRequest, QByteArray> request = light->createSetTemperatureRequest(action.param(colorLightColorTemperatureActionColorTemperatureParamTypeId).value().toInt());
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
||||
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
// Color temperature light
|
||||
@ -637,7 +675,7 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device,
|
||||
|
||||
if (!light->reachable()) {
|
||||
qCWarning(dcPhilipsHue) << "Light" << light->name() << "not reachable";
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
if (action.actionTypeId() == colorTemperatureLightPowerActionTypeId) {
|
||||
@ -645,27 +683,27 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device,
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
||||
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
} else if (action.actionTypeId() == colorTemperatureLightBrightnessActionTypeId) {
|
||||
QPair<QNetworkRequest, QByteArray> request = light->createSetBrightnessRequest(percentageToBrightness(action.param(colorTemperatureLightBrightnessActionBrightnessParamTypeId).value().toInt()));
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
||||
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
} else if (action.actionTypeId() == colorTemperatureLightAlertActionTypeId) {
|
||||
QPair<QNetworkRequest, QByteArray> request = light->createFlashRequest(action.param(colorTemperatureLightAlertActionAlertParamTypeId).value().toString());
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
||||
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
} else if (action.actionTypeId() == colorTemperatureLightColorTemperatureActionTypeId) {
|
||||
QPair<QNetworkRequest, QByteArray> request = light->createSetTemperatureRequest(action.param(colorTemperatureLightColorTemperatureActionColorTemperatureParamTypeId).value().toInt());
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
||||
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
// Dimmable light
|
||||
@ -674,7 +712,7 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device,
|
||||
|
||||
if (!light->reachable()) {
|
||||
qCWarning(dcPhilipsHue) << "Light" << light->name() << "not reachable";
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
if (action.actionTypeId() == dimmableLightPowerActionTypeId) {
|
||||
@ -682,21 +720,21 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device,
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
||||
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
} else if (action.actionTypeId() == dimmableLightBrightnessActionTypeId) {
|
||||
QPair<QNetworkRequest, QByteArray> request = light->createSetBrightnessRequest(percentageToBrightness(action.param(dimmableLightBrightnessActionBrightnessParamTypeId).value().toInt()));
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
||||
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
} else if (action.actionTypeId() == dimmableLightAlertActionTypeId) {
|
||||
QPair<QNetworkRequest, QByteArray> request = light->createFlashRequest(action.param(dimmableLightAlertActionAlertParamTypeId).value().toString());
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
||||
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
// Hue bridge
|
||||
@ -704,28 +742,28 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device,
|
||||
HueBridge *bridge = m_bridges.key(device);
|
||||
if (!device->stateValue(bridgeConnectedStateTypeId).toBool()) {
|
||||
qCWarning(dcPhilipsHue) << "Bridge" << bridge->hostAddress().toString() << "not reachable";
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
if (action.actionTypeId() == bridgeSearchNewDevicesActionTypeId) {
|
||||
searchNewDevices(bridge, action.param(bridgeSearchNewDevicesActionSerialParamTypeId).value().toString());
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == bridgeCheckForUpdatesActionTypeId) {
|
||||
QPair<QNetworkRequest, QByteArray> request = bridge->createCheckUpdatesRequest();
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
||||
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
} else if (action.actionTypeId() == bridgeUpgradeActionTypeId) {
|
||||
QPair<QNetworkRequest, QByteArray> request = bridge->createUpgradeRequest();
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
|
||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
||||
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginPhilipsHue::lightStateChanged()
|
||||
@ -837,41 +875,41 @@ void DevicePluginPhilipsHue::onRemoteButtonEvent(int buttonCode)
|
||||
emitEvent(Event(id, m_remotes.value(remote)->id(), ParamList() << param));
|
||||
}
|
||||
|
||||
void DevicePluginPhilipsHue::onOutdoorSensorReachableChanged(bool reachable)
|
||||
void DevicePluginPhilipsHue::onMotionSensorReachableChanged(bool reachable)
|
||||
{
|
||||
HueOutdoorSensor *sensor = static_cast<HueOutdoorSensor *>(sender());
|
||||
Device *sensorDevice = m_outdoorSensors.value(sensor);
|
||||
sensorDevice->setStateValue(outdoorSensorConnectedStateTypeId, reachable);
|
||||
HueMotionSensor *sensor = static_cast<HueMotionSensor *>(sender());
|
||||
Device *sensorDevice = m_motionSensors.value(sensor);
|
||||
sensorDevice->setStateValue(sensor->connectedStateTypeId(), reachable);
|
||||
}
|
||||
|
||||
void DevicePluginPhilipsHue::onOutdoorSensorBatteryLevelChanged(int batteryLevel)
|
||||
void DevicePluginPhilipsHue::onMotionSensorBatteryLevelChanged(int batteryLevel)
|
||||
{
|
||||
HueOutdoorSensor *sensor = static_cast<HueOutdoorSensor *>(sender());
|
||||
Device *sensorDevice = m_outdoorSensors.value(sensor);
|
||||
sensorDevice->setStateValue(outdoorSensorBatteryLevelStateTypeId, batteryLevel);
|
||||
sensorDevice->setStateValue(outdoorSensorBatteryCriticalStateTypeId, (batteryLevel < 5));
|
||||
HueMotionSensor *sensor = static_cast<HueMotionSensor *>(sender());
|
||||
Device *sensorDevice = m_motionSensors.value(sensor);
|
||||
sensorDevice->setStateValue(sensor->batteryLevelStateTypeId(), batteryLevel);
|
||||
sensorDevice->setStateValue(sensor->batteryCriticalStateTypeId(), (batteryLevel < 5));
|
||||
}
|
||||
|
||||
void DevicePluginPhilipsHue::onOutdoorSensorTemperatureChanged(double temperature)
|
||||
void DevicePluginPhilipsHue::onMotionSensorTemperatureChanged(double temperature)
|
||||
{
|
||||
HueOutdoorSensor *sensor = static_cast<HueOutdoorSensor *>(sender());
|
||||
Device *sensorDevice = m_outdoorSensors.value(sensor);
|
||||
sensorDevice->setStateValue(outdoorSensorTemperatureStateTypeId, temperature);
|
||||
HueMotionSensor *sensor = static_cast<HueMotionSensor *>(sender());
|
||||
Device *sensorDevice = m_motionSensors.value(sensor);
|
||||
sensorDevice->setStateValue(sensor->temperatureStateTypeId(), temperature);
|
||||
}
|
||||
|
||||
void DevicePluginPhilipsHue::onOutdoorSensorPresenceChanged(bool presence)
|
||||
void DevicePluginPhilipsHue::onMotionSensorPresenceChanged(bool presence)
|
||||
{
|
||||
HueOutdoorSensor *sensor = static_cast<HueOutdoorSensor *>(sender());
|
||||
Device *sensorDevice = m_outdoorSensors.value(sensor);
|
||||
sensorDevice->setStateValue(outdoorSensorIsPresentStateTypeId, presence);
|
||||
if (presence) sensorDevice->setStateValue(outdoorSensorLastSeenTimeStateTypeId, QDateTime::currentDateTime().toTime_t());
|
||||
HueMotionSensor *sensor = static_cast<HueMotionSensor *>(sender());
|
||||
Device *sensorDevice = m_motionSensors.value(sensor);
|
||||
sensorDevice->setStateValue(sensor->isPresentStateTypeId(), presence);
|
||||
if (presence) sensorDevice->setStateValue(sensor->lastSeenTimeStateTypeId(), QDateTime::currentDateTime().toTime_t());
|
||||
}
|
||||
|
||||
void DevicePluginPhilipsHue::onOutdoorSensorLightIntensityChanged(double lightIntensity)
|
||||
void DevicePluginPhilipsHue::onMotionSensorLightIntensityChanged(double lightIntensity)
|
||||
{
|
||||
HueOutdoorSensor *sensor = static_cast<HueOutdoorSensor *>(sender());
|
||||
Device *sensorDevice = m_outdoorSensors.value(sensor);
|
||||
sensorDevice->setStateValue(outdoorSensorLightIntensityStateTypeId, lightIntensity);
|
||||
HueMotionSensor *sensor = static_cast<HueMotionSensor *>(sender());
|
||||
Device *sensorDevice = m_motionSensors.value(sensor);
|
||||
sensorDevice->setStateValue(sensor->lightIntensityStateTypeId(), lightIntensity);
|
||||
}
|
||||
|
||||
void DevicePluginPhilipsHue::refreshLight(Device *device)
|
||||
@ -1084,7 +1122,7 @@ void DevicePluginPhilipsHue::processBridgeSensorDiscoveryResponse(Device *device
|
||||
|
||||
// Create sensors if not already added
|
||||
QVariantMap sensorsMap = jsonDoc.toVariant().toMap();
|
||||
QHash<QString, HueOutdoorSensor *> outdoorSensors;
|
||||
QHash<QString, HueMotionSensor *> motionSensors;
|
||||
foreach (const QString &sensorId, sensorsMap.keys()) {
|
||||
|
||||
QVariantMap sensorMap = sensorsMap.value(sensorId).toMap();
|
||||
@ -1113,7 +1151,8 @@ void DevicePluginPhilipsHue::processBridgeSensorDiscoveryResponse(Device *device
|
||||
descriptor.setParams(params);
|
||||
emit autoDevicesAppeared(tapDeviceClassId, {descriptor});
|
||||
qCDebug(dcPhilipsHue()) << "Found hue tap:" << sensorMap << tapDeviceClassId;
|
||||
} else if (model == "SML002") {
|
||||
|
||||
} else if (model == "SML001" || model == "SML002") {
|
||||
// Get the base uuid from this sensor
|
||||
QString baseUuid = HueDevice::getBaseUuid(uuid);
|
||||
|
||||
@ -1121,52 +1160,69 @@ void DevicePluginPhilipsHue::processBridgeSensorDiscoveryResponse(Device *device
|
||||
if (sensorMap.value("type").toString() == "ZLLTemperature") {
|
||||
qCDebug(dcPhilipsHue()) << "Found temperature sensor from OurdoorSensor:" << baseUuid << sensorMap;
|
||||
// Check if we haven outdoor sensor for this temperature sensor
|
||||
if (outdoorSensors.keys().contains(baseUuid)) {
|
||||
HueOutdoorSensor *outdoorSensor = outdoorSensors.value(baseUuid);
|
||||
outdoorSensor->setTemperatureSensorUuid(uuid);
|
||||
outdoorSensor->setTemperatureSensorId(sensorId.toInt());
|
||||
if (motionSensors.contains(baseUuid)) {
|
||||
HueMotionSensor *motionSensor = motionSensors.value(baseUuid);
|
||||
motionSensor->setTemperatureSensorUuid(uuid);
|
||||
motionSensor->setTemperatureSensorId(sensorId.toInt());
|
||||
} else {
|
||||
// Create an outdoor sensor
|
||||
HueOutdoorSensor *outdoorSensor = new HueOutdoorSensor(this);
|
||||
outdoorSensor->setModelId(model);
|
||||
outdoorSensor->setUuid(baseUuid);
|
||||
outdoorSensor->setTemperatureSensorUuid(uuid);
|
||||
outdoorSensor->setTemperatureSensorId(sensorId.toInt());
|
||||
outdoorSensors.insert(baseUuid, outdoorSensor);
|
||||
HueMotionSensor *motionSensor = nullptr;
|
||||
if (model == "SML001") {
|
||||
motionSensor = new HueIndoorSensor(this);
|
||||
} else {
|
||||
motionSensor = new HueOutdoorSensor(this);
|
||||
}
|
||||
motionSensor->setModelId(model);
|
||||
motionSensor->setUuid(baseUuid);
|
||||
motionSensor->setTemperatureSensorUuid(uuid);
|
||||
motionSensor->setTemperatureSensorId(sensorId.toInt());
|
||||
motionSensors.insert(baseUuid, motionSensor);
|
||||
}
|
||||
}
|
||||
|
||||
if (sensorMap.value("type").toString() == "ZLLPresence") {
|
||||
qCDebug(dcPhilipsHue()) << "Found presence sensor from OurdoorSensor:" << baseUuid << sensorMap;
|
||||
// Check if we haven outdoor sensor for this presence sensor
|
||||
if (outdoorSensors.keys().contains(baseUuid)) {
|
||||
HueOutdoorSensor *outdoorSensor = outdoorSensors.value(baseUuid);
|
||||
outdoorSensor->setPresenceSensorUuid(uuid);
|
||||
outdoorSensor->setPresenceSensorId(sensorId.toInt());
|
||||
if (motionSensors.contains(baseUuid)) {
|
||||
HueMotionSensor *motionSensor = motionSensors.value(baseUuid);
|
||||
motionSensor->setPresenceSensorUuid(uuid);
|
||||
motionSensor->setPresenceSensorId(sensorId.toInt());
|
||||
} else {
|
||||
// Create an outdoor sensor
|
||||
HueOutdoorSensor *outdoorSensor = new HueOutdoorSensor(this);
|
||||
outdoorSensor->setUuid(baseUuid);
|
||||
outdoorSensor->setPresenceSensorUuid(uuid);
|
||||
outdoorSensor->setPresenceSensorId(sensorId.toInt());
|
||||
outdoorSensors.insert(baseUuid, outdoorSensor);
|
||||
HueMotionSensor *motionSensor = nullptr;
|
||||
if (model == "SML001") {
|
||||
motionSensor = new HueIndoorSensor(this);
|
||||
} else {
|
||||
motionSensor = new HueOutdoorSensor(this);
|
||||
}
|
||||
motionSensor->setModelId(model);
|
||||
motionSensor->setUuid(baseUuid);
|
||||
motionSensor->setPresenceSensorUuid(uuid);
|
||||
motionSensor->setPresenceSensorId(sensorId.toInt());
|
||||
motionSensors.insert(baseUuid, motionSensor);
|
||||
}
|
||||
}
|
||||
|
||||
if (sensorMap.value("type").toString() == "ZLLLightLevel") {
|
||||
qCDebug(dcPhilipsHue()) << "Found light sensor from OurdoorSensor:" << sensorMap;
|
||||
// Check if we haven outdoor sensor for this light sensor
|
||||
if (outdoorSensors.keys().contains(baseUuid)) {
|
||||
HueOutdoorSensor *outdoorSensor = outdoorSensors.value(baseUuid);
|
||||
outdoorSensor->setLightSensorUuid(uuid);
|
||||
outdoorSensor->setLightSensorId(sensorId.toInt());
|
||||
if (motionSensors.contains(baseUuid)) {
|
||||
HueMotionSensor *motionSensor = motionSensors.value(baseUuid);
|
||||
motionSensor->setLightSensorUuid(uuid);
|
||||
motionSensor->setLightSensorId(sensorId.toInt());
|
||||
} else {
|
||||
// Create an outdoor sensor
|
||||
HueOutdoorSensor *outdoorSensor = new HueOutdoorSensor(this);
|
||||
outdoorSensor->setUuid(baseUuid);
|
||||
outdoorSensor->setLightSensorUuid(uuid);
|
||||
outdoorSensor->setLightSensorId(sensorId.toInt());
|
||||
outdoorSensors.insert(baseUuid, outdoorSensor);
|
||||
HueMotionSensor *motionSensor = nullptr;
|
||||
if (model == "SML001") {
|
||||
motionSensor = new HueIndoorSensor(this);
|
||||
} else {
|
||||
motionSensor = new HueOutdoorSensor(this);
|
||||
}
|
||||
motionSensor->setModelId(model);
|
||||
motionSensor->setUuid(baseUuid);
|
||||
motionSensor->setLightSensorUuid(uuid);
|
||||
motionSensor->setLightSensorId(sensorId.toInt());
|
||||
motionSensors.insert(baseUuid, motionSensor);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1175,28 +1231,43 @@ void DevicePluginPhilipsHue::processBridgeSensorDiscoveryResponse(Device *device
|
||||
}
|
||||
|
||||
// Create outdoor sensors if there are any new sensors found
|
||||
foreach (HueOutdoorSensor *outdoorSensor, outdoorSensors.values()) {
|
||||
QString baseUuid = outdoorSensors.key(outdoorSensor);
|
||||
if (outdoorSensor->isValid()) {
|
||||
DeviceDescriptor descriptor(outdoorSensorDeviceClassId, "Philips Hue Outdoor sensor", baseUuid, device->id());
|
||||
ParamList params;
|
||||
params.append(Param(outdoorSensorDeviceUuidParamTypeId, outdoorSensor->uuid()));
|
||||
params.append(Param(outdoorSensorDeviceModelIdParamTypeId, outdoorSensor->modelId()));
|
||||
params.append(Param(outdoorSensorDeviceSensorUuidTemperatureParamTypeId, outdoorSensor->temperatureSensorUuid()));
|
||||
params.append(Param(outdoorSensorDeviceSensorIdTemperatureParamTypeId, outdoorSensor->temperatureSensorId()));
|
||||
params.append(Param(outdoorSensorDeviceSensorUuidPresenceParamTypeId, outdoorSensor->presenceSensorUuid()));
|
||||
params.append(Param(outdoorSensorDeviceSensorIdPresenceParamTypeId, outdoorSensor->presenceSensorId()));
|
||||
params.append(Param(outdoorSensorDeviceSensorUuidLightParamTypeId, outdoorSensor->lightSensorUuid()));
|
||||
params.append(Param(outdoorSensorDeviceSensorIdLightParamTypeId, outdoorSensor->lightSensorId()));
|
||||
descriptor.setParams(params);
|
||||
|
||||
qCDebug(dcPhilipsHue()) << "Found new Outdoor sensor" << baseUuid << outdoorSensorDeviceClassId;
|
||||
emit autoDevicesAppeared(outdoorSensorDeviceClassId, {descriptor});
|
||||
foreach (HueMotionSensor *motionSensor, motionSensors.values()) {
|
||||
QString baseUuid = motionSensors.key(motionSensor);
|
||||
if (motionSensor->isValid()) {
|
||||
if (motionSensor->modelId() == "SML001") {
|
||||
DeviceDescriptor descriptor(motionSensorDeviceClassId, tr("Philips Hue Motion sensor"), baseUuid, device->id());
|
||||
ParamList params;
|
||||
params.append(Param(motionSensorDeviceUuidParamTypeId, motionSensor->uuid()));
|
||||
params.append(Param(motionSensorDeviceModelIdParamTypeId, motionSensor->modelId()));
|
||||
params.append(Param(motionSensorDeviceSensorUuidTemperatureParamTypeId, motionSensor->temperatureSensorUuid()));
|
||||
params.append(Param(motionSensorDeviceSensorIdTemperatureParamTypeId, motionSensor->temperatureSensorId()));
|
||||
params.append(Param(motionSensorDeviceSensorUuidPresenceParamTypeId, motionSensor->presenceSensorUuid()));
|
||||
params.append(Param(motionSensorDeviceSensorIdPresenceParamTypeId, motionSensor->presenceSensorId()));
|
||||
params.append(Param(motionSensorDeviceSensorUuidLightParamTypeId, motionSensor->lightSensorUuid()));
|
||||
params.append(Param(motionSensorDeviceSensorIdLightParamTypeId, motionSensor->lightSensorId()));
|
||||
descriptor.setParams(params);
|
||||
qCDebug(dcPhilipsHue()) << "Found new motion sensor" << baseUuid << outdoorSensorDeviceClassId;
|
||||
emit autoDevicesAppeared(motionSensorDeviceClassId, {descriptor});
|
||||
} else if (motionSensor->modelId() == "SML002") {
|
||||
DeviceDescriptor descriptor(outdoorSensorDeviceClassId, tr("Philips Hue Outdoor sensor"), baseUuid, device->id());
|
||||
ParamList params;
|
||||
params.append(Param(outdoorSensorDeviceUuidParamTypeId, motionSensor->uuid()));
|
||||
params.append(Param(outdoorSensorDeviceModelIdParamTypeId, motionSensor->modelId()));
|
||||
params.append(Param(outdoorSensorDeviceSensorUuidTemperatureParamTypeId, motionSensor->temperatureSensorUuid()));
|
||||
params.append(Param(outdoorSensorDeviceSensorIdTemperatureParamTypeId, motionSensor->temperatureSensorId()));
|
||||
params.append(Param(outdoorSensorDeviceSensorUuidPresenceParamTypeId, motionSensor->presenceSensorUuid()));
|
||||
params.append(Param(outdoorSensorDeviceSensorIdPresenceParamTypeId, motionSensor->presenceSensorId()));
|
||||
params.append(Param(outdoorSensorDeviceSensorUuidLightParamTypeId, motionSensor->lightSensorUuid()));
|
||||
params.append(Param(outdoorSensorDeviceSensorIdLightParamTypeId, motionSensor->lightSensorId()));
|
||||
descriptor.setParams(params);
|
||||
qCDebug(dcPhilipsHue()) << "Found new outdoor sensor" << baseUuid << outdoorSensorDeviceClassId;
|
||||
emit autoDevicesAppeared(outdoorSensorDeviceClassId, {descriptor});
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up
|
||||
outdoorSensors.remove(baseUuid);
|
||||
outdoorSensor->deleteLater();
|
||||
motionSensors.remove(baseUuid);
|
||||
motionSensor->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1334,9 +1405,9 @@ void DevicePluginPhilipsHue::processSensorsRefreshResponse(Device *device, const
|
||||
}
|
||||
|
||||
// Outdoor sensors
|
||||
foreach (HueOutdoorSensor *outdoorSensor, m_outdoorSensors.keys()) {
|
||||
if (outdoorSensor->hasSensor(sensorId.toInt()) && m_outdoorSensors.value(outdoorSensor)->parentId() == device->id()) {
|
||||
outdoorSensor->updateStates(sensorMap);
|
||||
foreach (HueMotionSensor *motionSensor, m_motionSensors.keys()) {
|
||||
if (motionSensor->hasSensor(sensorId.toInt()) && m_motionSensors.value(motionSensor)->parentId() == device->id()) {
|
||||
motionSensor->updateStates(sensorMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1350,7 +1421,7 @@ void DevicePluginPhilipsHue::processSetNameResponse(Device *device, const QByteA
|
||||
// check JSON error
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCWarning(dcPhilipsHue) << "Hue Bridge json error in response" << error.errorString();
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1361,7 +1432,7 @@ void DevicePluginPhilipsHue::processSetNameResponse(Device *device, const QByteA
|
||||
} else {
|
||||
qCWarning(dcPhilipsHue) << "Failed to set name of Hue: Invalid error message format";
|
||||
}
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1378,7 +1449,7 @@ void DevicePluginPhilipsHue::processPairingResponse(PairingInfo *pairingInfo, co
|
||||
// check JSON error
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCWarning(dcPhilipsHue) << "Hue Bridge json error in response" << error.errorString();
|
||||
emit pairingFinished(pairingInfo->pairingTransactionId(), DeviceManager::DeviceSetupStatusFailure);
|
||||
emit pairingFinished(pairingInfo->pairingTransactionId(), Device::DeviceSetupStatusFailure);
|
||||
pairingInfo->deleteLater();
|
||||
return;
|
||||
}
|
||||
@ -1390,7 +1461,7 @@ void DevicePluginPhilipsHue::processPairingResponse(PairingInfo *pairingInfo, co
|
||||
} else {
|
||||
qCWarning(dcPhilipsHue) << "Failed to pair Hue Bridge: Invalid error message format";
|
||||
}
|
||||
emit pairingFinished(pairingInfo->pairingTransactionId(), DeviceManager::DeviceSetupStatusFailure);
|
||||
emit pairingFinished(pairingInfo->pairingTransactionId(), Device::DeviceSetupStatusFailure);
|
||||
pairingInfo->deleteLater();
|
||||
return;
|
||||
}
|
||||
@ -1401,7 +1472,7 @@ void DevicePluginPhilipsHue::processPairingResponse(PairingInfo *pairingInfo, co
|
||||
|
||||
if (pairingInfo->apiKey().isEmpty()) {
|
||||
qCWarning(dcPhilipsHue) << "Failed to pair Hue Bridge: did not get any key from the bridge";
|
||||
emit pairingFinished(pairingInfo->pairingTransactionId(), DeviceManager::DeviceSetupStatusFailure);
|
||||
emit pairingFinished(pairingInfo->pairingTransactionId(), Device::DeviceSetupStatusFailure);
|
||||
pairingInfo->deleteLater();
|
||||
return;
|
||||
}
|
||||
@ -1422,7 +1493,7 @@ void DevicePluginPhilipsHue::processInformationResponse(PairingInfo *pairingInfo
|
||||
// check JSON error
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCWarning(dcPhilipsHue) << "Hue Bridge json error in response" << error.errorString();
|
||||
emit pairingFinished(pairingInfo->pairingTransactionId(), DeviceManager::DeviceSetupStatusFailure);
|
||||
emit pairingFinished(pairingInfo->pairingTransactionId(), Device::DeviceSetupStatusFailure);
|
||||
pairingInfo->deleteLater();
|
||||
return;
|
||||
}
|
||||
@ -1432,7 +1503,7 @@ void DevicePluginPhilipsHue::processInformationResponse(PairingInfo *pairingInfo
|
||||
// check response error
|
||||
if (response.contains("error")) {
|
||||
qCWarning(dcPhilipsHue) << "Failed to get information from Hue Bridge:" << response.value("error").toMap().value("description").toString();
|
||||
emit pairingFinished(pairingInfo->pairingTransactionId(), DeviceManager::DeviceSetupStatusFailure);
|
||||
emit pairingFinished(pairingInfo->pairingTransactionId(), Device::DeviceSetupStatusFailure);
|
||||
pairingInfo->deleteLater();
|
||||
return;
|
||||
}
|
||||
@ -1450,7 +1521,7 @@ void DevicePluginPhilipsHue::processInformationResponse(PairingInfo *pairingInfo
|
||||
|
||||
m_unconfiguredBridges.append(bridge);
|
||||
|
||||
emit pairingFinished(pairingInfo->pairingTransactionId(), DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit pairingFinished(pairingInfo->pairingTransactionId(), Device::DeviceSetupStatusSuccess);
|
||||
pairingInfo->deleteLater();
|
||||
}
|
||||
|
||||
@ -1462,7 +1533,7 @@ void DevicePluginPhilipsHue::processActionResponse(Device *device, const ActionI
|
||||
// check JSON error
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCWarning(dcPhilipsHue) << "Hue Bridge json error in response" << error.errorString();
|
||||
emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorHardwareFailure);
|
||||
emit actionExecutionFinished(actionId, Device::DeviceErrorHardwareFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1473,14 +1544,14 @@ void DevicePluginPhilipsHue::processActionResponse(Device *device, const ActionI
|
||||
} else {
|
||||
qCWarning(dcPhilipsHue) << "Failed to execute Hue action: Invalid error message format";
|
||||
}
|
||||
emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorHardwareFailure);
|
||||
emit actionExecutionFinished(actionId, Device::DeviceErrorHardwareFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() != bridgeDeviceClassId)
|
||||
m_lights.key(device)->processActionResponse(jsonDoc.toVariant().toList());
|
||||
|
||||
emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(actionId, Device::DeviceErrorNoError);
|
||||
}
|
||||
|
||||
void DevicePluginPhilipsHue::bridgeReachableChanged(Device *device, const bool &reachable)
|
||||
@ -1516,12 +1587,10 @@ void DevicePluginPhilipsHue::bridgeReachableChanged(Device *device, const bool &
|
||||
}
|
||||
}
|
||||
|
||||
foreach (HueOutdoorSensor *outdoorSensor, m_outdoorSensors.keys()) {
|
||||
if (m_outdoorSensors.value(outdoorSensor)->parentId() == device->id()) {
|
||||
outdoorSensor->setReachable(false);
|
||||
if (m_outdoorSensors.value(outdoorSensor)->deviceClassId() == outdoorSensorDeviceClassId) {
|
||||
m_outdoorSensors.value(outdoorSensor)->setStateValue(outdoorSensorConnectedStateTypeId, false);
|
||||
}
|
||||
foreach (HueMotionSensor *motionSensor, m_motionSensors.keys()) {
|
||||
if (m_motionSensors.value(motionSensor)->parentId() == device->id()) {
|
||||
motionSensor->setReachable(false);
|
||||
m_motionSensors.value(motionSensor)->setStateValue(motionSensor->connectedStateTypeId(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1588,6 +1657,16 @@ bool DevicePluginPhilipsHue::sensorAlreadyAdded(const QString &uuid)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Motion sensor consits out of 3 sensors
|
||||
if (device->deviceClassId() == motionSensorDeviceClassId) {
|
||||
if (device->paramValue(motionSensorDeviceSensorUuidLightParamTypeId).toString() == uuid) {
|
||||
return true;
|
||||
} else if (device->paramValue(motionSensorDeviceSensorUuidPresenceParamTypeId).toString() == uuid) {
|
||||
return true;
|
||||
} else if (device->paramValue(motionSensorDeviceSensorUuidTemperatureParamTypeId).toString() == uuid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -24,13 +24,15 @@
|
||||
#ifndef DEVICEPLUGINPHILIPSHUE_H
|
||||
#define DEVICEPLUGINPHILIPSHUE_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "huebridge.h"
|
||||
#include "huelight.h"
|
||||
#include "hueremote.h"
|
||||
#include "pairinginfo.h"
|
||||
#include "huemotionsensor.h"
|
||||
#include "huemotionsensor.h"
|
||||
|
||||
#include "plugintimer.h"
|
||||
#include "hueoutdoorsensor.h"
|
||||
#include "network/networkaccessmanager.h"
|
||||
#include "network/upnp/upnpdiscovery.h"
|
||||
|
||||
@ -48,25 +50,25 @@ public:
|
||||
~DevicePluginPhilipsHue();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
DeviceManager::DeviceSetupStatus confirmPairing(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms, const QString &secret) override;
|
||||
Device::DeviceSetupStatus confirmPairing(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms, const QString &secret) override;
|
||||
|
||||
public slots:
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action);
|
||||
Device::DeviceError executeAction(Device *device, const Action &action);
|
||||
|
||||
private slots:
|
||||
void lightStateChanged();
|
||||
void remoteStateChanged();
|
||||
void onRemoteButtonEvent(int buttonCode);
|
||||
|
||||
// Outdoor sensor
|
||||
void onOutdoorSensorReachableChanged(bool reachable);
|
||||
void onOutdoorSensorBatteryLevelChanged(int batteryLevel);
|
||||
void onOutdoorSensorTemperatureChanged(double temperature);
|
||||
void onOutdoorSensorPresenceChanged(bool presence);
|
||||
void onOutdoorSensorLightIntensityChanged(double lightIntensity);
|
||||
// Motion sensor
|
||||
void onMotionSensorReachableChanged(bool reachable);
|
||||
void onMotionSensorBatteryLevelChanged(int batteryLevel);
|
||||
void onMotionSensorTemperatureChanged(double temperature);
|
||||
void onMotionSensorPresenceChanged(bool presence);
|
||||
void onMotionSensorLightIntensityChanged(double lightIntensity);
|
||||
|
||||
private slots:
|
||||
void networkManagerReplyReady();
|
||||
@ -105,7 +107,7 @@ private:
|
||||
QHash<HueBridge *, Device *> m_bridges;
|
||||
QHash<HueLight *, Device *> m_lights;
|
||||
QHash<HueRemote *, Device *> m_remotes;
|
||||
QHash<HueOutdoorSensor *, Device *> m_outdoorSensors;
|
||||
QHash<HueMotionSensor *, Device *> m_motionSensors;
|
||||
|
||||
void refreshLight(Device *device);
|
||||
void refreshBridge(Device *device);
|
||||
|
||||
@ -671,6 +671,18 @@
|
||||
"readOnly": true
|
||||
}
|
||||
],
|
||||
"settingsTypes": [
|
||||
{
|
||||
"id": "21d461b2-b4dd-4a70-b3d5-aaedc88605a4",
|
||||
"name": "timeout",
|
||||
"displayName": "Time period",
|
||||
"type": "uint",
|
||||
"unit": "Seconds",
|
||||
"defaultValue": 10,
|
||||
"minValue": 10
|
||||
}
|
||||
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "9fe43e6b-3c29-43a9-bb96-3b80eacc10db",
|
||||
@ -735,6 +747,147 @@
|
||||
"defaultValue": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "25b79fff-4b88-4af8-b06c-2fe246238790",
|
||||
"name": "motionSensor",
|
||||
"displayName": "Hue Motion Sensor",
|
||||
"interfaces": ["presencesensor", "temperaturesensor", "lightsensor", "batterylevel", "connectable"],
|
||||
"createMethods": ["auto"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "9cb488b7-a76f-4389-a6b5-b36250246f2b",
|
||||
"name": "modelId",
|
||||
"displayName": "Model id",
|
||||
"type" : "QString",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "3e9aad4c-1dff-42c0-bbd4-cdd8635c01a7",
|
||||
"name": "uuid",
|
||||
"displayName": "Uuid",
|
||||
"type" : "QString",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "c9e81e29-f8d4-4370-ada2-f48b32def1fe",
|
||||
"name": "sensorIdTemperature",
|
||||
"displayName": "Temperature sensor id",
|
||||
"type" : "int",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "aa29b5f1-5589-4fa9-bbd4-8869723c037c",
|
||||
"name": "sensorUuidTemperature",
|
||||
"displayName": "Temperature sensor uuid",
|
||||
"type" : "QString",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "337b2c6c-e3bf-495c-943c-b45fa08add37",
|
||||
"name": "sensorIdPresence",
|
||||
"displayName": "Presence sensor id",
|
||||
"type" : "int",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "3829bddb-e722-4724-be36-3a8402738581",
|
||||
"name": "sensorUuidPresence",
|
||||
"displayName": "Presence sensor uuid",
|
||||
"type" : "QString",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "04fba73e-730e-437a-b6f2-10df21296af5",
|
||||
"name": "sensorIdLight",
|
||||
"displayName": "Light sensor id",
|
||||
"type" : "int",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "171cc2e7-7a95-4116-986c-66d75e3e23eb",
|
||||
"name": "sensorUuidLight",
|
||||
"displayName": "Light sensor uuid",
|
||||
"type" : "QString",
|
||||
"readOnly": true
|
||||
}
|
||||
],
|
||||
"settingsTypes": [
|
||||
{
|
||||
"id": "beedc4af-c107-4c53-be25-fd01a349fd35",
|
||||
"name": "timeout",
|
||||
"displayName": "Time period",
|
||||
"type": "uint",
|
||||
"unit": "Seconds",
|
||||
"defaultValue": 10,
|
||||
"minValue": 10
|
||||
}
|
||||
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "19c28b69-a9c2-4908-8255-7681f72c2d92",
|
||||
"name": "connected",
|
||||
"displayName": "Reachable",
|
||||
"displayNameEvent": "Reachable changed",
|
||||
"defaultValue": false,
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"id": "ac463b30-24af-4352-84da-19a3ffc906bd",
|
||||
"name": "batteryLevel",
|
||||
"displayName": "Battery",
|
||||
"displayNameEvent": "Battery changed",
|
||||
"type": "int",
|
||||
"unit": "Percentage",
|
||||
"defaultValue": 0,
|
||||
"minValue": 0,
|
||||
"maxValue": 100
|
||||
},
|
||||
{
|
||||
"id": "d7c4e143-6f03-411e-a12e-dd22806270fd",
|
||||
"name": "batteryCritical",
|
||||
"displayName": "Battery critical",
|
||||
"displayNameEvent": "Battery critical changed",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "63ee79f7-702b-48c1-86cf-8ddebb78bae6",
|
||||
"name": "temperature",
|
||||
"displayName": "Temperature",
|
||||
"displayNameEvent": "Temperature changed",
|
||||
"unit": "DegreeCelsius",
|
||||
"type": "double",
|
||||
"defaultValue": 0
|
||||
},
|
||||
{
|
||||
"id": "064f48c1-f86d-4a0a-bdae-3420123dff3f",
|
||||
"name": "lightIntensity",
|
||||
"displayName": "Ambient light",
|
||||
"displayNameEvent": "Ambient light changed",
|
||||
"unit": "Lux",
|
||||
"type": "double",
|
||||
"defaultValue": 0
|
||||
},
|
||||
{
|
||||
"id": "e38ee39c-c77f-40b5-b122-4efc411da0ed",
|
||||
"name": "isPresent",
|
||||
"displayName": "Person is present",
|
||||
"displayNameEvent": "Person is present changed",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "ef2e564e-2443-448f-bcd9-f85a1126ee6a",
|
||||
"name": "lastSeenTime",
|
||||
"displayName": "Last seen time",
|
||||
"displayNameEvent": "Last seen time changed",
|
||||
"type": "int",
|
||||
"unit": "UnixTime",
|
||||
"defaultValue": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ class HueDevice : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HueDevice(QObject *parent = 0);
|
||||
explicit HueDevice(QObject *parent = nullptr);
|
||||
|
||||
int id() const;
|
||||
void setId(const int &id);
|
||||
|
||||
@ -20,106 +20,109 @@
|
||||
* *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "hueoutdoorsensor.h"
|
||||
#include "huemotionsensor.h"
|
||||
#include "extern-plugininfo.h"
|
||||
|
||||
HueOutdoorSensor::HueOutdoorSensor(QObject *parent) :
|
||||
HueMotionSensor::HueMotionSensor(QObject *parent) :
|
||||
HueDevice(parent)
|
||||
{
|
||||
|
||||
m_timeout.setInterval(10000);
|
||||
connect(&m_timeout, &QTimer::timeout, this, [this](){
|
||||
if (m_presence) {
|
||||
qCDebug(dcPhilipsHue) << "Motion sensor timeout reached" << m_timeout.interval();
|
||||
m_presence = false;
|
||||
emit presenceChanged(m_presence);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QString HueOutdoorSensor::uuid() const
|
||||
void HueMotionSensor::setTimeout(int timeout)
|
||||
{
|
||||
return m_uuid;
|
||||
// The sensor keeps emitting presence = true for 10 secs, let's subtract that time from the timeout to compensate
|
||||
m_timeout.setInterval((timeout - 9)* 1000);
|
||||
}
|
||||
|
||||
void HueOutdoorSensor::setUuid(const QString &uuid)
|
||||
{
|
||||
m_uuid = uuid;
|
||||
}
|
||||
|
||||
int HueOutdoorSensor::temperatureSensorId() const
|
||||
int HueMotionSensor::temperatureSensorId() const
|
||||
{
|
||||
return m_temperatureSensorId;
|
||||
}
|
||||
|
||||
void HueOutdoorSensor::setTemperatureSensorId(int sensorId)
|
||||
void HueMotionSensor::setTemperatureSensorId(int sensorId)
|
||||
{
|
||||
m_temperatureSensorId = sensorId;
|
||||
}
|
||||
|
||||
QString HueOutdoorSensor::temperatureSensorUuid() const
|
||||
QString HueMotionSensor::temperatureSensorUuid() const
|
||||
{
|
||||
return m_temperatureSensorUuid;
|
||||
}
|
||||
|
||||
void HueOutdoorSensor::setTemperatureSensorUuid(const QString &temperatureSensorUuid)
|
||||
void HueMotionSensor::setTemperatureSensorUuid(const QString &temperatureSensorUuid)
|
||||
{
|
||||
m_temperatureSensorUuid = temperatureSensorUuid;
|
||||
}
|
||||
|
||||
int HueOutdoorSensor::presenceSensorId() const
|
||||
int HueMotionSensor::presenceSensorId() const
|
||||
{
|
||||
return m_presenceSensorId;
|
||||
}
|
||||
|
||||
void HueOutdoorSensor::setPresenceSensorId(int sensorId)
|
||||
void HueMotionSensor::setPresenceSensorId(int sensorId)
|
||||
{
|
||||
m_presenceSensorId = sensorId;
|
||||
}
|
||||
|
||||
QString HueOutdoorSensor::presenceSensorUuid() const
|
||||
QString HueMotionSensor::presenceSensorUuid() const
|
||||
{
|
||||
return m_presenceSensorUuid;
|
||||
}
|
||||
|
||||
void HueOutdoorSensor::setPresenceSensorUuid(const QString &presenceSensorUuid)
|
||||
void HueMotionSensor::setPresenceSensorUuid(const QString &presenceSensorUuid)
|
||||
{
|
||||
m_presenceSensorUuid = presenceSensorUuid;
|
||||
}
|
||||
|
||||
int HueOutdoorSensor::lightSensorId() const
|
||||
int HueMotionSensor::lightSensorId() const
|
||||
{
|
||||
return m_lightSensorId;
|
||||
}
|
||||
|
||||
void HueOutdoorSensor::setLightSensorId(int sensorId)
|
||||
void HueMotionSensor::setLightSensorId(int sensorId)
|
||||
{
|
||||
m_lightSensorId = sensorId;
|
||||
}
|
||||
|
||||
QString HueOutdoorSensor::lightSensorUuid() const
|
||||
QString HueMotionSensor::lightSensorUuid() const
|
||||
{
|
||||
return m_lightSensorUuid;
|
||||
}
|
||||
|
||||
void HueOutdoorSensor::setLightSensorUuid(const QString &lightSensorUuid)
|
||||
void HueMotionSensor::setLightSensorUuid(const QString &lightSensorUuid)
|
||||
{
|
||||
m_lightSensorUuid = lightSensorUuid;
|
||||
}
|
||||
|
||||
double HueOutdoorSensor::temperature() const
|
||||
double HueMotionSensor::temperature() const
|
||||
{
|
||||
return m_temperature;
|
||||
}
|
||||
|
||||
double HueOutdoorSensor::lightIntensity() const
|
||||
double HueMotionSensor::lightIntensity() const
|
||||
{
|
||||
return m_lightIntensity;
|
||||
}
|
||||
|
||||
bool HueOutdoorSensor::present() const
|
||||
bool HueMotionSensor::present() const
|
||||
{
|
||||
return m_presence;
|
||||
}
|
||||
|
||||
int HueOutdoorSensor::batteryLevel() const
|
||||
int HueMotionSensor::batteryLevel() const
|
||||
{
|
||||
return m_batteryLevel;
|
||||
}
|
||||
|
||||
void HueOutdoorSensor::updateStates(const QVariantMap &sensorMap)
|
||||
void HueMotionSensor::updateStates(const QVariantMap &sensorMap)
|
||||
{
|
||||
//qCDebug(dcPhilipsHue()) << "Outdoor sensor: Process sensor map" << qUtf8Printable(QJsonDocument::fromVariant(sensorMap).toJson(QJsonDocument::Indented));
|
||||
|
||||
@ -144,17 +147,21 @@ void HueOutdoorSensor::updateStates(const QVariantMap &sensorMap)
|
||||
if (m_temperature != temperature) {
|
||||
m_temperature = temperature;
|
||||
emit temperatureChanged(m_temperature);
|
||||
qCDebug(dcPhilipsHue) << "Outdoor sensor temperature changed" << m_temperature;
|
||||
qCDebug(dcPhilipsHue) << "Motion sensor temperature changed" << m_temperature;
|
||||
}
|
||||
}
|
||||
|
||||
// If presence sensor
|
||||
if (sensorMap.value("uniqueid").toString() == m_presenceSensorUuid) {
|
||||
bool presence = stateMap.value("presence", false).toBool();
|
||||
if (m_presence != presence) {
|
||||
m_presence = presence;
|
||||
emit presenceChanged(m_presence);
|
||||
qCDebug(dcPhilipsHue) << "Outdoor sensor presence changed" << presence;
|
||||
if (presence) {
|
||||
if (!m_presence) {
|
||||
m_presence = true;
|
||||
emit presenceChanged(m_presence);
|
||||
qCDebug(dcPhilipsHue) << "Motion sensor presence changed" << presence;
|
||||
}
|
||||
qCDebug(dcPhilipsHue) << "Motion sensor restarting timeout" << m_timeout.interval();
|
||||
m_timeout.start();
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,17 +176,17 @@ void HueOutdoorSensor::updateStates(const QVariantMap &sensorMap)
|
||||
}
|
||||
}
|
||||
|
||||
bool HueOutdoorSensor::isValid()
|
||||
bool HueMotionSensor::isValid()
|
||||
{
|
||||
return !m_temperatureSensorUuid.isEmpty() && !m_presenceSensorUuid.isEmpty() && !m_lightSensorUuid.isEmpty();
|
||||
}
|
||||
|
||||
bool HueOutdoorSensor::hasSensor(int sensorId)
|
||||
bool HueMotionSensor::hasSensor(int sensorId)
|
||||
{
|
||||
return m_temperatureSensorId == sensorId || m_presenceSensorId == sensorId || m_lightSensorId == sensorId;
|
||||
}
|
||||
|
||||
bool HueOutdoorSensor::hasSensor(const QString &sensorUuid)
|
||||
bool HueMotionSensor::hasSensor(const QString &sensorUuid)
|
||||
{
|
||||
return m_temperatureSensorUuid == sensorUuid || m_presenceSensorUuid == sensorUuid || m_lightSensorUuid == sensorUuid;
|
||||
}
|
||||
@ -20,21 +20,23 @@
|
||||
* *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#ifndef HUEOUTDOORSENSOR_H
|
||||
#define HUEOUTDOORSENSOR_H
|
||||
#ifndef HUEMOTIONSENSOR_H
|
||||
#define HUEMOTIONSENSOR_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
|
||||
#include "extern-plugininfo.h"
|
||||
#include "huedevice.h"
|
||||
|
||||
class HueOutdoorSensor : public HueDevice
|
||||
class HueMotionSensor : public HueDevice
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HueOutdoorSensor(QObject *parent = nullptr);
|
||||
explicit HueMotionSensor(QObject *parent = nullptr);
|
||||
virtual ~HueMotionSensor() = default;
|
||||
|
||||
QString uuid() const;
|
||||
void setUuid(const QString &uuid);
|
||||
void setTimeout(int timeout);
|
||||
|
||||
int temperatureSensorId() const;
|
||||
void setTemperatureSensorId(int sensorId);
|
||||
@ -65,10 +67,16 @@ public:
|
||||
bool hasSensor(int sensorId);
|
||||
bool hasSensor(const QString &sensorUuid);
|
||||
|
||||
virtual StateTypeId connectedStateTypeId() const = 0;
|
||||
virtual StateTypeId temperatureStateTypeId() const = 0;
|
||||
virtual StateTypeId lightIntensityStateTypeId() const = 0;
|
||||
virtual StateTypeId isPresentStateTypeId() const = 0;
|
||||
virtual StateTypeId lastSeenTimeStateTypeId() const = 0;
|
||||
virtual StateTypeId batteryLevelStateTypeId() const = 0;
|
||||
virtual StateTypeId batteryCriticalStateTypeId() const = 0;
|
||||
|
||||
private:
|
||||
// Params
|
||||
QString m_uuid;
|
||||
|
||||
int m_temperatureSensorId;
|
||||
QString m_temperatureSensorUuid;
|
||||
|
||||
@ -78,6 +86,8 @@ private:
|
||||
int m_lightSensorId;
|
||||
QString m_lightSensorUuid;
|
||||
|
||||
QTimer m_timeout;
|
||||
|
||||
// States
|
||||
QString m_lastUpdate;
|
||||
double m_temperature = 0;
|
||||
@ -93,4 +103,36 @@ signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // HUEOUTDOORSENSOR_H
|
||||
class HueIndoorSensor: public HueMotionSensor
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HueIndoorSensor(QObject *parent = nullptr): HueMotionSensor(parent) {}
|
||||
|
||||
StateTypeId connectedStateTypeId() const override { return motionSensorConnectedStateTypeId; }
|
||||
StateTypeId temperatureStateTypeId() const override { return motionSensorTemperatureStateTypeId; }
|
||||
StateTypeId lightIntensityStateTypeId() const override { return motionSensorLightIntensityStateTypeId; }
|
||||
StateTypeId isPresentStateTypeId() const override { return motionSensorIsPresentStateTypeId; }
|
||||
StateTypeId lastSeenTimeStateTypeId() const override { return motionSensorLastSeenTimeStateTypeId; }
|
||||
StateTypeId batteryLevelStateTypeId() const override { return motionSensorBatteryLevelStateTypeId; }
|
||||
StateTypeId batteryCriticalStateTypeId() const override { return motionSensorBatteryCriticalStateTypeId; }
|
||||
|
||||
};
|
||||
|
||||
class HueOutdoorSensor: public HueMotionSensor
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HueOutdoorSensor(QObject *parent = nullptr): HueMotionSensor(parent) {}
|
||||
|
||||
StateTypeId connectedStateTypeId() const override { return outdoorSensorTemperatureStateTypeId; }
|
||||
StateTypeId temperatureStateTypeId() const override { return outdoorSensorTemperatureStateTypeId; }
|
||||
StateTypeId lightIntensityStateTypeId() const override { return outdoorSensorLightIntensityStateTypeId; }
|
||||
StateTypeId isPresentStateTypeId() const override { return outdoorSensorIsPresentStateTypeId; }
|
||||
StateTypeId lastSeenTimeStateTypeId() const override { return outdoorSensorLastSeenTimeStateTypeId; }
|
||||
StateTypeId batteryLevelStateTypeId() const override { return outdoorSensorBatteryLevelStateTypeId; }
|
||||
StateTypeId batteryCriticalStateTypeId() const override { return outdoorSensorBatteryCriticalStateTypeId; }
|
||||
|
||||
};
|
||||
|
||||
#endif // HUEMOTIONSENSOR_H
|
||||
@ -10,10 +10,10 @@ SOURCES += \
|
||||
#light.cpp \
|
||||
huebridge.cpp \
|
||||
huelight.cpp \
|
||||
huemotionsensor.cpp \
|
||||
pairinginfo.cpp \
|
||||
hueremote.cpp \
|
||||
huedevice.cpp \
|
||||
hueoutdoorsensor.cpp
|
||||
huedevice.cpp
|
||||
|
||||
HEADERS += \
|
||||
devicepluginphilipshue.h \
|
||||
@ -22,10 +22,10 @@ HEADERS += \
|
||||
#lightinterface.h \
|
||||
huebridge.h \
|
||||
huelight.h \
|
||||
huemotionsensor.h \
|
||||
pairinginfo.h \
|
||||
hueremote.h \
|
||||
huedevice.h \
|
||||
hueoutdoorsensor.h
|
||||
huedevice.h
|
||||
|
||||
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ DevicePluginPushbullet::~DevicePluginPushbullet()
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginPushbullet::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginPushbullet::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcPushbullet()) << "Setting up Pushbullet device" << device->name() << device->id().toString();
|
||||
|
||||
@ -48,7 +48,7 @@ DeviceManager::DeviceSetupStatus DevicePluginPushbullet::setupDevice(Device *dev
|
||||
connect(reply, &QNetworkReply::finished, device, [this, reply, device]() {
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
qCWarning(dcPushbullet()) << "Error fetching user profile:" << reply->errorString() << reply->error();
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -59,25 +59,25 @@ DeviceManager::DeviceSetupStatus DevicePluginPushbullet::setupDevice(Device *dev
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCWarning(dcPushbullet()) << "Error parsing reply from Pushbullet:" << error.errorString();
|
||||
qCWarning(dcPushbullet()) << qUtf8Printable(data);
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
QVariantMap replyMap = jsonDoc.toVariant().toMap();
|
||||
if (!replyMap.value("active").toBool()) {
|
||||
qCWarning(dcPushbullet()) << "Pushbullet account seems to be deactivated.";
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
qCDebug(dcPushbullet()) << "Pushbullet device" << device->name() << device->id().toString() << "setup complete";
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusSuccess);
|
||||
});
|
||||
|
||||
return DeviceManager::DeviceSetupStatusAsync;
|
||||
return Device::DeviceSetupStatusAsync;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginPushbullet::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginPushbullet::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
qCDebug(dcPushbullet()) << "Executing action" << action.actionTypeId() << "for device" << device->name() << device->id().toString();
|
||||
|
||||
@ -94,7 +94,7 @@ DeviceManager::DeviceError DevicePluginPushbullet::executeAction(Device *device,
|
||||
connect(reply, &QNetworkReply::finished, device, [this, reply, device, action]{
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
qCWarning(dcPushbullet()) << "Push message sending failed for" << device->name() << device->id() << reply->errorString() << reply->error();
|
||||
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorHardwareNotAvailable);
|
||||
emit actionExecutionFinished(action.id(), Device::DeviceErrorHardwareNotAvailable);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -105,27 +105,27 @@ DeviceManager::DeviceError DevicePluginPushbullet::executeAction(Device *device,
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCWarning(dcPushbullet()) << "Error reading reply from Pushbullet for" << device->name() << device->id().toString() << error.errorString();
|
||||
qCWarning(dcPushbullet()) << qUtf8Printable(data);
|
||||
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorHardwareFailure);
|
||||
emit actionExecutionFinished(action.id(), Device::DeviceErrorHardwareFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
QVariantMap replyMap = jsonDoc.toVariant().toMap();
|
||||
if (!replyMap.value("active").toBool()) {
|
||||
qCWarning(dcPushbullet()) << "Error sending message. The account seems to be deactivated" << device->name() << device->id().toString();
|
||||
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorHardwareFailure);
|
||||
emit actionExecutionFinished(action.id(), Device::DeviceErrorHardwareFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
if (replyMap.value("dismissed", true).toBool()) {
|
||||
qCWarning(dcPushbullet()) << "Error sending message. The message has been dismissed by the server" << device->name() << device->id().toString();
|
||||
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorHardwareFailure);
|
||||
emit actionExecutionFinished(action.id(), Device::DeviceErrorHardwareFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
qCDebug(dcPushbullet()) << "Message sent successfully";
|
||||
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(action.id(), Device::DeviceErrorNoError);
|
||||
});
|
||||
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef DEVICEPLUGINPUSHBULLET_H
|
||||
#define DEVICEPLUGINPUSHBULLET_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
class DevicePluginPushbullet: public DevicePlugin
|
||||
{
|
||||
@ -36,8 +36,8 @@ public:
|
||||
explicit DevicePluginPushbullet(QObject *parent = nullptr);
|
||||
~DevicePluginPushbullet() override;
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -38,18 +38,18 @@ void DevicePluginRemoteSsh::init()
|
||||
connect(m_pluginTimer, &PluginTimer::timeout, this, &DevicePluginRemoteSsh::onPluginTimeout);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginRemoteSsh::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginRemoteSsh::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcRemoteSsh()) << "Setup" << device->name() << device->params();
|
||||
|
||||
if (device->deviceClassId() == reverseSshDeviceClassId) {
|
||||
m_identityFilePath = QString("%1/.ssh/id_rsa_guh").arg(QDir::homePath());
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginRemoteSsh::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginRemoteSsh::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (device->deviceClassId() == reverseSshDeviceClassId ) {
|
||||
|
||||
@ -59,26 +59,26 @@ DeviceManager::DeviceError DevicePluginRemoteSsh::executeAction(Device *device,
|
||||
QProcess *process = startReverseSSHProcess(device);
|
||||
m_reverseSSHProcess.insert(process, device);
|
||||
m_startingProcess.insert(process, action.id());
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
} else {
|
||||
QProcess *process = m_reverseSSHProcess.key(device);
|
||||
|
||||
// Check if the application is running...
|
||||
if (!process)
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
|
||||
if (process->state() == QProcess::NotRunning)
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
|
||||
process->kill();
|
||||
m_killingProcess.insert(process, action.id());
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
|
||||
@ -179,7 +179,7 @@ void DevicePluginRemoteSsh::processStateChanged(QProcess::ProcessState state)
|
||||
case QProcess::Running:
|
||||
device->setStateValue(reverseSshConnectedStateTypeId, true);
|
||||
if (m_startingProcess.contains(process)) {
|
||||
emit actionExecutionFinished(m_startingProcess.value(process), DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(m_startingProcess.value(process), Device::DeviceErrorNoError);
|
||||
m_startingProcess.remove(process);
|
||||
}
|
||||
break;
|
||||
@ -189,12 +189,12 @@ void DevicePluginRemoteSsh::processStateChanged(QProcess::ProcessState state)
|
||||
device->setStateValue(reverseSshConnectedStateTypeId, false);
|
||||
|
||||
if (m_startingProcess.contains(process)) {
|
||||
emit actionExecutionFinished(m_startingProcess.value(process), DeviceManager::DeviceErrorInvalidParameter);
|
||||
emit actionExecutionFinished(m_startingProcess.value(process), Device::DeviceErrorInvalidParameter);
|
||||
m_startingProcess.remove(process);
|
||||
}
|
||||
|
||||
if (m_killingProcess.contains(process)) {
|
||||
emit actionExecutionFinished(m_killingProcess.value(process), DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(m_killingProcess.value(process), Device::DeviceErrorNoError);
|
||||
m_reverseSSHProcess.remove(process);
|
||||
m_killingProcess.remove(process);
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
#define DEVICEPLUGINREMOTESSH_H
|
||||
|
||||
#include "plugintimer.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
@ -40,9 +40,9 @@ public:
|
||||
explicit DevicePluginRemoteSsh();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private:
|
||||
QHash<QProcess *, Device *> m_reverseSSHProcess;
|
||||
|
||||
@ -21,8 +21,7 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "devicepluginsenic.h"
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
#include "hardware/bluetoothlowenergy/bluetoothlowenergymanager.h"
|
||||
|
||||
@ -37,26 +36,26 @@ void DevicePluginSenic::init()
|
||||
connect(m_reconnectTimer, &PluginTimer::timeout, this, &DevicePluginSenic::onReconnectTimeout);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginSenic::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginSenic::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params)
|
||||
|
||||
if (deviceClassId != nuimoDeviceClassId)
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
|
||||
if (!hardwareManager()->bluetoothLowEnergyManager()->available())
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
if (!hardwareManager()->bluetoothLowEnergyManager()->enabled())
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
BluetoothDiscoveryReply *reply = hardwareManager()->bluetoothLowEnergyManager()->discoverDevices();
|
||||
connect(reply, &BluetoothDiscoveryReply::finished, this, &DevicePluginSenic::onBluetoothDiscoveryFinished);
|
||||
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginSenic::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginSenic::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcSenic()) << "Setup device" << device->name() << device->params();
|
||||
|
||||
@ -75,17 +74,17 @@ DeviceManager::DeviceSetupStatus DevicePluginSenic::setupDevice(Device *device)
|
||||
m_nuimos.insert(nuimo, device);
|
||||
nuimo->bluetoothDevice()->connectDevice();
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginSenic::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginSenic::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
QPointer<Nuimo> nuimo = m_nuimos.key(device);
|
||||
if (nuimo.isNull())
|
||||
return DeviceManager::DeviceErrorHardwareFailure;
|
||||
return Device::DeviceErrorHardwareFailure;
|
||||
|
||||
if (!nuimo->bluetoothDevice()->connected()) {
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
if (action.actionTypeId() == nuimoShowLogoActionTypeId) {
|
||||
@ -109,10 +108,10 @@ DeviceManager::DeviceError DevicePluginSenic::executeAction(Device *device, cons
|
||||
if (action.param(nuimoShowLogoActionLogoParamTypeId).value().toString() == "Heart")
|
||||
nuimo->showImage(Nuimo::MatrixTypeHeart);
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginSenic::deviceRemoved(Device *device)
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
#define DEVICEPLUGINSENIC_H
|
||||
|
||||
#include "plugintimer.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h"
|
||||
|
||||
#include "nuimo.h"
|
||||
@ -40,9 +40,9 @@ public:
|
||||
explicit DevicePluginSenic();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
#include <QBluetoothUuid>
|
||||
|
||||
#include "typeutils.h"
|
||||
#include "plugin/device.h"
|
||||
#include "devices/device.h"
|
||||
#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h"
|
||||
|
||||
class Nuimo : public QObject
|
||||
|
||||
@ -28,7 +28,7 @@ DevicePluginSerialPortCommander::DevicePluginSerialPortCommander()
|
||||
}
|
||||
|
||||
|
||||
DeviceManager::DeviceError DevicePluginSerialPortCommander::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginSerialPortCommander::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params)
|
||||
// Create the list of available serial interfaces
|
||||
@ -51,11 +51,11 @@ DeviceManager::DeviceError DevicePluginSerialPortCommander::discoverDevices(cons
|
||||
deviceDescriptors.append(deviceDescriptor);
|
||||
}
|
||||
emit devicesDiscovered(deviceClassId, deviceDescriptors);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginSerialPortCommander::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginSerialPortCommander::setupDevice(Device *device)
|
||||
{
|
||||
if(!m_reconnectTimer) {
|
||||
m_reconnectTimer = new QTimer(this);
|
||||
@ -69,7 +69,7 @@ DeviceManager::DeviceSetupStatus DevicePluginSerialPortCommander::setupDevice(De
|
||||
QString interface = device->paramValue(serialPortCommanderDeviceSerialPortParamTypeId).toString();
|
||||
QSerialPort *serialPort = new QSerialPort(interface, this);
|
||||
if(!serialPort)
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
|
||||
serialPort->setBaudRate(device->paramValue(serialPortCommanderDeviceBaudRateParamTypeId).toInt());
|
||||
serialPort->setDataBits(QSerialPort::DataBits(device->paramValue(serialPortCommanderDeviceDataBitsParamTypeId).toInt()));
|
||||
@ -99,7 +99,7 @@ DeviceManager::DeviceSetupStatus DevicePluginSerialPortCommander::setupDevice(De
|
||||
if (!serialPort->open(QIODevice::ReadWrite)) {
|
||||
qCWarning(dcSerialPortCommander()) << "Could not open serial port" << interface << serialPort->errorString();
|
||||
serialPort->deleteLater();
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
connect(serialPort, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(onSerialError(QSerialPort::SerialPortError)));
|
||||
@ -112,11 +112,11 @@ DeviceManager::DeviceSetupStatus DevicePluginSerialPortCommander::setupDevice(De
|
||||
m_serialPorts.insert(device, serialPort);
|
||||
device->setStateValue(serialPortCommanderConnectedStateTypeId, true);
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
|
||||
DeviceManager::DeviceError DevicePluginSerialPortCommander::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginSerialPortCommander::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (device->deviceClassId() == serialPortCommanderDeviceClassId ) {
|
||||
|
||||
@ -125,13 +125,13 @@ DeviceManager::DeviceError DevicePluginSerialPortCommander::executeAction(Device
|
||||
QSerialPort *serialPort = m_serialPorts.value(device);
|
||||
qint64 size = serialPort->write(action.param(serialPortCommanderTriggerActionOutputDataParamTypeId).value().toByteArray());
|
||||
if(size != action.param(serialPortCommanderTriggerActionOutputDataParamTypeId).value().toByteArray().length()) {
|
||||
return DeviceManager::DeviceErrorHardwareFailure;
|
||||
return Device::DeviceErrorHardwareFailure;
|
||||
}
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -23,8 +23,7 @@
|
||||
#ifndef DEVICEPLUGINSERIALPORTCOMMANDER_H
|
||||
#define DEVICEPLUGINSERIALPORTCOMMANDER_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QSerialPort>
|
||||
@ -40,10 +39,10 @@ class DevicePluginSerialPortCommander : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginSerialPortCommander();
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private:
|
||||
QTimer *m_reconnectTimer = nullptr;
|
||||
|
||||
@ -52,7 +52,7 @@ void DevicePluginSimulation::init()
|
||||
connect(m_pluginTimer5Min, &PluginTimer::timeout, this, &DevicePluginSimulation::onPluginTimer5Minutes);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginSimulation::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginSimulation::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcSimulation()) << "Set up device" << device->name();
|
||||
if (device->deviceClassId() == garageGateDeviceClassId ||
|
||||
@ -67,7 +67,7 @@ DeviceManager::DeviceSetupStatus DevicePluginSimulation::setupDevice(Device *dev
|
||||
if (device->deviceClassId() == fingerPrintSensorDeviceClassId && device->stateValue(fingerPrintSensorUsersStateTypeId).toStringList().count() > 0) {
|
||||
m_simulationTimers.value(device)->start(10000);
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
void DevicePluginSimulation::deviceRemoved(Device *device)
|
||||
@ -80,7 +80,7 @@ void DevicePluginSimulation::deviceRemoved(Device *device)
|
||||
}
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginSimulation::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
// Check the DeviceClassId for "Simple Button"
|
||||
if (device->deviceClassId() == simpleButtonDeviceClassId ) {
|
||||
@ -93,9 +93,9 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
Event event(simpleButtonPressedEventTypeId, device->id());
|
||||
emit emitEvent(event);
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
// Check the DeviceClassId for "Alternative Button"
|
||||
@ -113,9 +113,9 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
// Set the "power" state
|
||||
device->setStateValue(alternativeButtonPowerStateTypeId, power);
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == heatingDeviceClassId) {
|
||||
@ -128,7 +128,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
bool power = powerParam.value().toBool();
|
||||
qCDebug(dcSimulation()) << "Set power" << power << "for heating device" << device->name();
|
||||
device->setStateValue(heatingPowerStateTypeId, power);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
|
||||
} else if (action.actionTypeId() == heatingPercentageActionTypeId) {
|
||||
|
||||
@ -139,9 +139,9 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
qCDebug(dcSimulation()) << "Set target temperature percentage" << percentage << "for heating device" << device->name();
|
||||
|
||||
device->setStateValue(heatingPercentageStateTypeId, percentage);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == thermostatDeviceClassId) {
|
||||
@ -152,7 +152,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
}
|
||||
qCDebug(dcSimulation()) << "Set power" << power << "for thermostat device" << device->name();
|
||||
device->setStateValue(thermostatPowerStateTypeId, power);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == thermostatBoostActionTypeId) {
|
||||
bool boost = action.param(thermostatBoostActionBoostParamTypeId).value().toBool();
|
||||
@ -162,7 +162,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
qCDebug(dcSimulation()) << "Set boost" << boost << "for thermostat device" << device->name();
|
||||
device->setStateValue(thermostatBoostStateTypeId, boost);
|
||||
m_simulationTimers.value(device)->start(5 * 60 * 1000);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == thermostatTargetTemperatureActionTypeId) {
|
||||
if (!device->stateValue(thermostatPowerStateTypeId).toBool()) {
|
||||
@ -171,7 +171,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
double targetTemp = action.param(thermostatTargetTemperatureActionTargetTemperatureParamTypeId).value().toDouble();
|
||||
qCDebug(dcSimulation()) << "Set targetTemp" << targetTemp << "for thermostat device" << device->name();
|
||||
device->setStateValue(thermostatTargetTemperatureStateTypeId, targetTemp);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
qCDebug(dcSimulation()) << "Set power" << power << "for heating device" << device->name();
|
||||
|
||||
device->setStateValue(evChargerPowerStateTypeId, power);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
|
||||
} else if(action.actionTypeId() == evChargerMaxChargingCurrentActionTypeId){
|
||||
// get the param value
|
||||
@ -193,9 +193,9 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
uint maxCharge = maxChargeParam.value().toInt();
|
||||
qCDebug(dcSimulation()) << "Set maximum charging current to" << maxCharge << "for EV Charger device" << device->name();
|
||||
device->setStateValue(evChargerMaxChargingCurrentStateTypeId, maxCharge);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
if(device->deviceClassId() == socketDeviceClassId){
|
||||
@ -207,9 +207,9 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
// Set the "power" state
|
||||
qCDebug(dcSimulation()) << "Set power" << power << "for socket device" << device->name();
|
||||
device->setStateValue(socketPowerStateTypeId, power);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
if(device->deviceClassId() == colorBulbDeviceClassId){
|
||||
@ -218,28 +218,28 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
int brightness = action.param(colorBulbBrightnessActionBrightnessParamTypeId).value().toInt();
|
||||
qCDebug(dcSimulation()) << "Set brightness" << brightness << "for color bulb device" << device->name();
|
||||
device->setStateValue(colorBulbBrightnessStateTypeId, brightness);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
|
||||
} else if (action.actionTypeId() == colorBulbColorTemperatureActionTypeId){
|
||||
int temperature = action.param(colorBulbColorTemperatureActionColorTemperatureParamTypeId).value().toInt();
|
||||
qCDebug(dcSimulation()) << "Set color temperature" << temperature << "for color bulb device" << device->name();
|
||||
device->setStateValue(colorBulbColorTemperatureStateTypeId, temperature);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
|
||||
} else if (action.actionTypeId() == colorBulbColorActionTypeId) {
|
||||
QColor color = action.param(colorBulbColorActionColorParamTypeId).value().value<QColor>();
|
||||
qCDebug(dcSimulation()) << "Set color" << color << "for color bulb device" << device->name();
|
||||
device->setStateValue(colorBulbColorStateTypeId, color);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
|
||||
} else if (action.actionTypeId() == colorBulbPowerActionTypeId) {
|
||||
bool power = action.param(colorBulbPowerActionPowerParamTypeId).value().toBool();
|
||||
qCDebug(dcSimulation()) << "Set power" << power << "for color bulb device" << device->name();
|
||||
device->setStateValue(colorBulbPowerStateTypeId, power);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == heatingRodDeviceClassId) {
|
||||
@ -248,15 +248,15 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
bool power = action.param(heatingRodPowerActionPowerParamTypeId).value().toBool();
|
||||
qCDebug(dcSimulation()) << "Set power" << power << "for heating rod device" << device->name();
|
||||
device->setStateValue(heatingRodPowerStateTypeId, power);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == heatingRodPercentageActionTypeId) {
|
||||
int percentage = action.param(heatingRodPercentageActionPercentageParamTypeId).value().toInt();
|
||||
qCDebug(dcSimulation()) << "Set percentage" << percentage << "for heating rod device" << device->name();
|
||||
device->setStateValue(heatingRodPercentageStateTypeId, percentage);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == batteryDeviceClassId) {
|
||||
@ -265,64 +265,64 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
device->setStateValue(batteryMaxChargingStateTypeId, maxCharging);
|
||||
qCDebug(dcSimulation()) << "Set max charging power" << maxCharging << "for battery device" << device->name();
|
||||
device->setStateValue(batteryChargingStateTypeId, maxCharging);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == waterValveDeviceClassId) {
|
||||
if (action.actionTypeId() == waterValvePowerActionTypeId) {
|
||||
bool power = action.param(waterValvePowerActionPowerParamTypeId).value().toBool();
|
||||
device->setStateValue(waterValvePowerStateTypeId, power);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == garageGateDeviceClassId) {
|
||||
if (action.actionTypeId() == garageGateOpenActionTypeId) {
|
||||
if (device->stateValue(garageGateStateStateTypeId).toString() == "opening") {
|
||||
qCDebug(dcSimulation()) << "Garage gate already opening.";
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (device->stateValue(garageGateStateStateTypeId).toString() == "open" &&
|
||||
!device->stateValue(garageGateIntermediatePositionStateTypeId).toBool()) {
|
||||
qCDebug(dcSimulation()) << "Garage gate already open.";
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
device->setStateValue(garageGateStateStateTypeId, "opening");
|
||||
device->setStateValue(garageGateIntermediatePositionStateTypeId, true);
|
||||
m_simulationTimers.value(device)->start(5000);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == garageGateCloseActionTypeId) {
|
||||
if (device->stateValue(garageGateStateStateTypeId).toString() == "closing") {
|
||||
qCDebug(dcSimulation()) << "Garage gate already closing.";
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (device->stateValue(garageGateStateStateTypeId).toString() == "closed" &&
|
||||
!device->stateValue(garageGateIntermediatePositionStateTypeId).toBool()) {
|
||||
qCDebug(dcSimulation()) << "Garage gate already closed.";
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
device->setStateValue(garageGateStateStateTypeId, "closing");
|
||||
device->setStateValue(garageGateIntermediatePositionStateTypeId, true);
|
||||
m_simulationTimers.value(device)->start(5000);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == garageGateStopActionTypeId) {
|
||||
if (device->stateValue(garageGateStateStateTypeId).toString() == "opening" ||
|
||||
device->stateValue(garageGateStateStateTypeId).toString() == "closing") {
|
||||
device->setStateValue(garageGateStateStateTypeId, "open");
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
qCDebug(dcSimulation()) << "Garage gate not moving";
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == garageGatePowerActionTypeId) {
|
||||
bool power = action.param(garageGatePowerActionPowerParamTypeId).value().toBool();
|
||||
device->setStateValue(garageGatePowerStateTypeId, power);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
}
|
||||
|
||||
@ -332,27 +332,27 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
m_simulationTimers.value(device)->setProperty("targetValue", 0);
|
||||
m_simulationTimers.value(device)->start(500);
|
||||
device->setStateValue(rollerShutterMovingStateTypeId, true);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == rollerShutterCloseActionTypeId) {
|
||||
qCDebug(dcSimulation()) << "Closing roller shutter";
|
||||
m_simulationTimers.value(device)->setProperty("targetValue", 100);
|
||||
m_simulationTimers.value(device)->start(500);
|
||||
device->setStateValue(rollerShutterMovingStateTypeId, true);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == rollerShutterStopActionTypeId) {
|
||||
qCDebug(dcSimulation()) << "Stopping roller shutter";
|
||||
m_simulationTimers.value(device)->stop();
|
||||
device->setStateValue(rollerShutterMovingStateTypeId, false);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == rollerShutterPercentageActionTypeId) {
|
||||
qCDebug(dcSimulation()) << "Setting awning to" << action.param(rollerShutterPercentageActionPercentageParamTypeId);
|
||||
m_simulationTimers.value(device)->setProperty("targetValue", action.param(rollerShutterPercentageActionPercentageParamTypeId).value());
|
||||
m_simulationTimers.value(device)->start(500);
|
||||
device->setStateValue(rollerShutterMovingStateTypeId, true);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,27 +362,27 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
m_simulationTimers.value(device)->setProperty("targetValue", 100);
|
||||
m_simulationTimers.value(device)->start(500);
|
||||
device->setStateValue(extendedAwningMovingStateTypeId, true);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == extendedAwningCloseActionTypeId) {
|
||||
qCDebug(dcSimulation()) << "Closing awning";
|
||||
m_simulationTimers.value(device)->setProperty("targetValue", 0);
|
||||
m_simulationTimers.value(device)->start(500);
|
||||
device->setStateValue(extendedAwningMovingStateTypeId, true);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == extendedAwningStopActionTypeId) {
|
||||
qCDebug(dcSimulation()) << "Stopping awning";
|
||||
m_simulationTimers.value(device)->stop();
|
||||
device->setStateValue(extendedAwningMovingStateTypeId, false);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == extendedAwningPercentageActionTypeId) {
|
||||
qCDebug(dcSimulation()) << "Setting awning to" << action.param(extendedAwningPercentageActionPercentageParamTypeId);
|
||||
m_simulationTimers.value(device)->setProperty("targetValue", action.param(extendedAwningPercentageActionPercentageParamTypeId).value());
|
||||
m_simulationTimers.value(device)->start(500);
|
||||
device->setStateValue(extendedAwningMovingStateTypeId, true);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
}
|
||||
|
||||
@ -395,13 +395,13 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
settings.beginGroup(device->id().toString());
|
||||
QStringList usedFingers = settings.value(username).toStringList();
|
||||
if (users.contains(username) && usedFingers.contains(finger)) {
|
||||
return DeviceManager::DeviceErrorDuplicateUuid;
|
||||
return Device::DeviceErrorDuplicateUuid;
|
||||
}
|
||||
QTimer::singleShot(5000, this, [this, action, device, username, finger]() {
|
||||
if (username.toLower().trimmed() == "john") {
|
||||
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorHardwareFailure);
|
||||
emit actionExecutionFinished(action.id(), Device::DeviceErrorHardwareFailure);
|
||||
} else {
|
||||
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(action.id(), Device::DeviceErrorNoError);
|
||||
QStringList users = device->stateValue(fingerPrintSensorUsersStateTypeId).toStringList();
|
||||
if (!users.contains(username)) {
|
||||
users.append(username);
|
||||
@ -417,35 +417,35 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
settings.endGroup();
|
||||
}
|
||||
});
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
if (action.actionTypeId() == fingerPrintSensorRemoveUserActionTypeId) {
|
||||
QStringList users = device->stateValue(fingerPrintSensorUsersStateTypeId).toStringList();
|
||||
QString username = action.params().first().value().toString();
|
||||
if (!users.contains(username)) {
|
||||
return DeviceManager::DeviceErrorInvalidParameter;
|
||||
return Device::DeviceErrorInvalidParameter;
|
||||
}
|
||||
users.removeAll(username);
|
||||
device->setStateValue(fingerPrintSensorUsersStateTypeId, users);
|
||||
if (users.count() == 0) {
|
||||
m_simulationTimers.value(device)->stop();
|
||||
}
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == simpleBlindDeviceClassId) {
|
||||
if (action.actionTypeId() == simpleBlindOpenActionTypeId) {
|
||||
qCDebug(dcSimulation()) << "Opening simple blind";
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == simpleBlindCloseActionTypeId) {
|
||||
qCDebug(dcSimulation()) << "Closing simple blind";
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == simpleBlindStopActionTypeId) {
|
||||
qCDebug(dcSimulation()) << "Stopping simple blind";
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
}
|
||||
|
||||
@ -455,33 +455,33 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
||||
m_simulationTimers.value(device)->setProperty("targetValue", 0);
|
||||
m_simulationTimers.value(device)->start(500);
|
||||
device->setStateValue(extendedBlindMovingStateTypeId, true);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == extendedBlindCloseActionTypeId) {
|
||||
qCDebug(dcSimulation()) << "Closing extended blind";
|
||||
m_simulationTimers.value(device)->setProperty("targetValue", 100);
|
||||
m_simulationTimers.value(device)->start(500);
|
||||
device->setStateValue(extendedBlindMovingStateTypeId, true);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == extendedBlindStopActionTypeId) {
|
||||
qCDebug(dcSimulation()) << "Stopping extended blind";
|
||||
m_simulationTimers.value(device)->stop();
|
||||
device->setStateValue(extendedBlindMovingStateTypeId, false);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == extendedBlindPercentageActionTypeId) {
|
||||
qCDebug(dcSimulation()) << "Setting extended blind to" << action.param(extendedBlindPercentageActionPercentageParamTypeId);
|
||||
m_simulationTimers.value(device)->setProperty("targetValue", action.param(extendedBlindPercentageActionPercentageParamTypeId).value());
|
||||
m_simulationTimers.value(device)->start(500);
|
||||
device->setStateValue(extendedBlindMovingStateTypeId, true);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
}
|
||||
|
||||
qCWarning(dcSimulation()) << "Unhandled device class" << device->deviceClassId() << "for device" << device->name();
|
||||
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
int DevicePluginSimulation::generateRandomIntValue(int min, int max)
|
||||
|
||||
@ -22,8 +22,7 @@
|
||||
#ifndef DEVICEPLUGINSIMMULATION_H
|
||||
#define DEVICEPLUGINSIMMULATION_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "plugintimer.h"
|
||||
|
||||
#include <QDateTime>
|
||||
@ -41,9 +40,9 @@ public:
|
||||
~DevicePluginSimulation();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private:
|
||||
PluginTimer *m_pluginTimer20Seconds = nullptr;
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "devicepluginsnapd.h"
|
||||
#include "plugin/device.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
#include "network/networkaccessmanager.h"
|
||||
|
||||
@ -103,7 +103,7 @@ void DevicePluginSnapd::deviceRemoved(Device *device)
|
||||
}
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginSnapd::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginSnapd::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcSnapd()) << "Setup" << device->name() << device->params();
|
||||
|
||||
@ -122,59 +122,59 @@ DeviceManager::DeviceSetupStatus DevicePluginSnapd::setupDevice(Device *device)
|
||||
m_snapDevices.insert(device->paramValue(snapDeviceIdParamTypeId).toString(), device);
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginSnapd::executeAction(Device *device, const Action &action) {
|
||||
Device::DeviceError DevicePluginSnapd::executeAction(Device *device, const Action &action) {
|
||||
|
||||
if (device->deviceClassId() == snapdControlDeviceClassId) {
|
||||
|
||||
if (!m_snapdControl) {
|
||||
qCDebug(dcSnapd()) << "There is currently no snapd controller.";
|
||||
return DeviceManager::DeviceErrorHardwareFailure;
|
||||
return Device::DeviceErrorHardwareFailure;
|
||||
}
|
||||
|
||||
if (!m_snapdControl->connected()) {
|
||||
qCDebug(dcSnapd()) << "Snapd controller not connected to to backend.";
|
||||
return DeviceManager::DeviceErrorHardwareFailure;
|
||||
return Device::DeviceErrorHardwareFailure;
|
||||
}
|
||||
|
||||
if (action.actionTypeId() == snapdControlStartUpdateActionTypeId) {
|
||||
m_snapdControl->snapRefresh();
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == snapdControlCheckUpdatesActionTypeId) {
|
||||
m_snapdControl->checkForUpdates();
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
|
||||
} else if (device->deviceClassId() == snapDeviceClassId) {
|
||||
|
||||
if (!m_snapdControl) {
|
||||
qCDebug(dcSnapd()) << "There is currently no snapd controller.";
|
||||
return DeviceManager::DeviceErrorHardwareFailure;
|
||||
return Device::DeviceErrorHardwareFailure;
|
||||
}
|
||||
|
||||
if (!m_snapdControl->connected()) {
|
||||
qCDebug(dcSnapd()) << "Snapd controller not connected to the backend.";
|
||||
return DeviceManager::DeviceErrorHardwareFailure;
|
||||
return Device::DeviceErrorHardwareFailure;
|
||||
}
|
||||
|
||||
if (action.actionTypeId() == snapChannelActionTypeId) {
|
||||
QString snapName = device->paramValue(snapDeviceNameParamTypeId).toString();
|
||||
m_snapdControl->changeSnapChannel(snapName, action.param(snapChannelActionChannelParamTypeId).value().toString());
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == snapRevertActionTypeId) {
|
||||
QString snapName = device->paramValue(snapDeviceNameParamTypeId).toString();
|
||||
m_snapdControl->snapRevert(snapName);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginSnapd::onPluginConfigurationChanged(const ParamTypeId ¶mTypeId, const QVariant &value)
|
||||
|
||||
@ -23,8 +23,7 @@
|
||||
#ifndef DEVICEPLUGINSNAPD_H
|
||||
#define DEVICEPLUGINSNAPD_H
|
||||
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "plugintimer.h"
|
||||
|
||||
#include <QDebug>
|
||||
@ -49,8 +48,8 @@ public:
|
||||
void postSetupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private:
|
||||
SnapdControl *m_snapdControl = nullptr;
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
#include <QObject>
|
||||
#include <QLocalSocket>
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devices/device.h"
|
||||
#include "snapdconnection.h"
|
||||
|
||||
class SnapdControl : public QObject
|
||||
|
||||
@ -71,7 +71,7 @@ void DevicePluginTasmota::init()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginTasmota::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginTasmota::setupDevice(Device *device)
|
||||
{
|
||||
if (m_ipAddressParamTypeMap.contains(device->deviceClassId())) {
|
||||
ParamTypeId ipAddressParamTypeId = m_ipAddressParamTypeMap.value(device->deviceClassId());
|
||||
@ -79,12 +79,12 @@ DeviceManager::DeviceSetupStatus DevicePluginTasmota::setupDevice(Device *device
|
||||
QHostAddress deviceAddress = QHostAddress(device->paramValue(ipAddressParamTypeId).toString());
|
||||
if (deviceAddress.isNull()) {
|
||||
qCWarning(dcTasmota) << "Not a valid IP address given for IP address parameter";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
MqttChannel *channel = hardwareManager()->mqttProvider()->createChannel(device->id(), deviceAddress);
|
||||
if (!channel) {
|
||||
qCWarning(dcTasmota) << "Failed to create MQTT channel.";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
QUrl url(QString("http://%1/cm").arg(deviceAddress.toString()));
|
||||
@ -115,7 +115,7 @@ DeviceManager::DeviceSetupStatus DevicePluginTasmota::setupDevice(Device *device
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
qCDebug(dcTasmota) << "Sonoff device setup call failed:" << reply->error() << reply->errorString() << reply->readAll();
|
||||
hardwareManager()->mqttProvider()->releaseChannel(channel);
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusFailure);
|
||||
return;
|
||||
}
|
||||
m_mqttChannels.insert(device, channel);
|
||||
@ -124,7 +124,7 @@ DeviceManager::DeviceSetupStatus DevicePluginTasmota::setupDevice(Device *device
|
||||
connect(channel, &MqttChannel::publishReceived, this, &DevicePluginTasmota::onPublishReceived);
|
||||
|
||||
qCDebug(dcTasmota) << "Sonoff setup complete";
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusSuccess);
|
||||
|
||||
foreach (Device *child, myDevices()) {
|
||||
if (child->parentId() == device->id()) {
|
||||
@ -184,18 +184,18 @@ DeviceManager::DeviceSetupStatus DevicePluginTasmota::setupDevice(Device *device
|
||||
emit autoDevicesAppeared(tasmotaShutterDeviceClassId, deviceDescriptors);
|
||||
}
|
||||
});
|
||||
return DeviceManager::DeviceSetupStatusAsync;
|
||||
return Device::DeviceSetupStatusAsync;
|
||||
}
|
||||
|
||||
if (m_connectedStateTypeMap.contains(device->deviceClassId())) {
|
||||
Device* parentDevice = myDevices().findById(device->parentId());
|
||||
StateTypeId connectedStateTypeId = m_connectedStateTypeMap.value(device->deviceClassId());
|
||||
device->setStateValue(m_connectedStateTypeMap.value(device->deviceClassId()), parentDevice->stateValue(connectedStateTypeId));
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
qCWarning(dcTasmota) << "Unhandled DeviceClass in setupDevice" << device->deviceClassId();
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
void DevicePluginTasmota::deviceRemoved(Device *device)
|
||||
@ -208,7 +208,7 @@ void DevicePluginTasmota::deviceRemoved(Device *device)
|
||||
}
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginTasmota::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginTasmota::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (m_powerStateTypeMap.contains(device->deviceClassId())) {
|
||||
Device *parentDev = myDevices().findById(device->parentId());
|
||||
@ -218,7 +218,7 @@ DeviceManager::DeviceError DevicePluginTasmota::executeAction(Device *device, co
|
||||
qCDebug(dcTasmota) << "Publishing:" << channel->topicPrefix() + "/sonoff/cmnd/" + device->paramValue(channelParamTypeId).toString() << (action.param(powerActionParamTypeId).value().toBool() ? "ON" : "OFF");
|
||||
channel->publish(channel->topicPrefix() + "/sonoff/cmnd/" + device->paramValue(channelParamTypeId).toString().toLower(), action.param(powerActionParamTypeId).value().toBool() ? "ON" : "OFF");
|
||||
device->setStateValue(m_powerStateTypeMap.value(device->deviceClassId()), action.param(powerActionParamTypeId).value().toBool());
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (device->deviceClassId() == tasmotaShutterDeviceClassId) {
|
||||
Device *parentDev = myDevices().findById(device->parentId());
|
||||
@ -241,10 +241,10 @@ DeviceManager::DeviceError DevicePluginTasmota::executeAction(Device *device, co
|
||||
qCDebug(dcTasmota) << "Publishing:" << channel->topicPrefix() + "/sonoff/cmnd/" + device->paramValue(closingChannelParamTypeId).toString() << "OFF";
|
||||
channel->publish(channel->topicPrefix() + "/sonoff/cmnd/" + device->paramValue(closingChannelParamTypeId).toString().toLower(), "OFF");
|
||||
}
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
qCWarning(dcTasmota) << "Unhandled execute action call for device" << device;
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginTasmota::onClientConnected(MqttChannel *channel)
|
||||
|
||||
@ -21,8 +21,7 @@
|
||||
#ifndef DEVICEPLUGINTASMOTA_H
|
||||
#define DEVICEPLUGINTASMOTA_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
class MqttChannel;
|
||||
|
||||
@ -39,9 +38,9 @@ public:
|
||||
~DevicePluginTasmota();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private slots:
|
||||
void onClientConnected(MqttChannel *channel);
|
||||
|
||||
@ -26,7 +26,7 @@ DevicePluginTcpCommander::DevicePluginTcpCommander()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginTcpCommander::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginTcpCommander::setupDevice(Device *device)
|
||||
{
|
||||
if (device->deviceClassId() == tcpOutputDeviceClassId) {
|
||||
QTcpSocket *tcpSocket = new QTcpSocket(this);
|
||||
@ -34,7 +34,7 @@ DeviceManager::DeviceSetupStatus DevicePluginTcpCommander::setupDevice(Device *d
|
||||
connect(tcpSocket, &QTcpSocket::connected, this, &DevicePluginTcpCommander::onTcpSocketConnected);
|
||||
connect(tcpSocket, &QTcpSocket::disconnected, this, &DevicePluginTcpCommander::onTcpSocketDisconnected);
|
||||
connect(tcpSocket, &QTcpSocket::bytesWritten, this, &DevicePluginTcpCommander::onTcpSocketBytesWritten);
|
||||
return DeviceManager::DeviceSetupStatusAsync;
|
||||
return Device::DeviceSetupStatusAsync;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == tcpInputDeviceClassId) {
|
||||
@ -45,17 +45,17 @@ DeviceManager::DeviceSetupStatus DevicePluginTcpCommander::setupDevice(Device *d
|
||||
m_tcpServer.insert(tcpServer, device);
|
||||
connect(tcpServer, &TcpServer::connected, this, &DevicePluginTcpCommander::onTcpServerConnected);
|
||||
connect(tcpServer, &TcpServer::disconnected, this, &DevicePluginTcpCommander::onTcpServerDisconnected);
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
} else {
|
||||
tcpServer->deleteLater();
|
||||
qDebug(dcTCPCommander()) << "Could not open TCP Server";
|
||||
}
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
|
||||
DeviceManager::DeviceError DevicePluginTcpCommander::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginTcpCommander::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (device->deviceClassId() == tcpOutputDeviceClassId) {
|
||||
|
||||
@ -64,11 +64,11 @@ DeviceManager::DeviceError DevicePluginTcpCommander::executeAction(Device *devic
|
||||
QHostAddress address= QHostAddress(device->paramValue(tcpOutputDeviceIpv4addressParamTypeId).toString());
|
||||
QTcpSocket *tcpSocket = m_tcpSockets.key(device);
|
||||
tcpSocket->connectToHost(address, port);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
|
||||
@ -96,7 +96,7 @@ void DevicePluginTcpCommander::onTcpSocketConnected()
|
||||
if (device->deviceClassId() == tcpOutputDeviceClassId) {
|
||||
if (!device->setupComplete()) {
|
||||
qDebug(dcTCPCommander()) << device->name() << "Setup finished" ;
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusSuccess);
|
||||
} else {
|
||||
QByteArray data = device->paramValue(tcpOutputTriggerActionOutputDataAreaParamTypeId).toByteArray();
|
||||
tcpSocket->write(data);
|
||||
@ -106,7 +106,7 @@ void DevicePluginTcpCommander::onTcpSocketConnected()
|
||||
if (device->deviceClassId() == tcpInputDeviceClassId) {
|
||||
if (!device->setupComplete()) {
|
||||
qDebug(dcTCPCommander()) << device->name() << "Setup finished" ;
|
||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess);
|
||||
emit deviceSetupFinished(device, Device::DeviceSetupStatusSuccess);
|
||||
}
|
||||
device->setStateValue(tcpInputConnectedStateTypeId, true);
|
||||
}
|
||||
|
||||
@ -21,8 +21,7 @@
|
||||
#ifndef DEVICEPLUGINDEVTCPCOMMANDER_H
|
||||
#define DEVICEPLUGINDEVTCPCOMMANDER_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include "tcpserver.h"
|
||||
|
||||
class DevicePluginTcpCommander : public DevicePlugin
|
||||
@ -35,11 +34,11 @@ class DevicePluginTcpCommander : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginTcpCommander();
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private:
|
||||
QHash<QTcpSocket *, Device *> m_tcpSockets;
|
||||
|
||||
@ -39,13 +39,13 @@ DevicePluginTexasInstruments::~DevicePluginTexasInstruments()
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginTexasInstruments::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginTexasInstruments::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params)
|
||||
Q_ASSERT_X(deviceClassId == sensorTagDeviceClassId, "DevicePluginTexasInstruments", "Unhandled DeviceClassId!");
|
||||
|
||||
if (!hardwareManager()->bluetoothLowEnergyManager()->available() || !hardwareManager()->bluetoothLowEnergyManager()->enabled()) {
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
BluetoothDiscoveryReply *reply = hardwareManager()->bluetoothLowEnergyManager()->discoverDevices();
|
||||
@ -85,10 +85,10 @@ DeviceManager::DeviceError DevicePluginTexasInstruments::discoverDevices(const D
|
||||
|
||||
emit devicesDiscovered(sensorTagDeviceClassId, deviceDescriptors);
|
||||
});
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginTexasInstruments::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginTexasInstruments::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcTexasInstruments()) << "Setting up Multi Sensor" << device->name() << device->params();
|
||||
|
||||
@ -111,7 +111,7 @@ DeviceManager::DeviceSetupStatus DevicePluginTexasInstruments::setupDevice(Devic
|
||||
});
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
void DevicePluginTexasInstruments::postSetupDevice(Device *device)
|
||||
@ -150,72 +150,72 @@ void DevicePluginTexasInstruments::deviceRemoved(Device *device)
|
||||
}
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginTexasInstruments::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginTexasInstruments::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
SensorTag *sensorTag = m_sensorTags.value(device);
|
||||
if (action.actionTypeId() == sensorTagBuzzerActionTypeId) {
|
||||
sensorTag->setBuzzerPower(action.param(sensorTagBuzzerActionBuzzerParamTypeId).value().toBool());
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == sensorTagGreenLedActionTypeId) {
|
||||
sensorTag->setGreenLedPower(action.param(sensorTagGreenLedActionGreenLedParamTypeId).value().toBool());
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == sensorTagRedLedActionTypeId) {
|
||||
sensorTag->setRedLedPower(action.param(sensorTagRedLedActionRedLedParamTypeId).value().toBool());
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == sensorTagBuzzerImpulseActionTypeId) {
|
||||
sensorTag->buzzerImpulse();
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == sensorTagTemperatureSensorEnabledActionTypeId) {
|
||||
bool enabled = action.param(sensorTagTemperatureSensorEnabledActionTemperatureSensorEnabledParamTypeId).value().toBool();
|
||||
device->setStateValue(sensorTagTemperatureSensorEnabledStateTypeId, enabled);
|
||||
sensorTag->setTemperatureSensorEnabled(enabled);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == sensorTagHumiditySensorEnabledActionTypeId) {
|
||||
bool enabled = action.param(sensorTagHumiditySensorEnabledActionHumiditySensorEnabledParamTypeId).value().toBool();
|
||||
device->setStateValue(sensorTagHumiditySensorEnabledStateTypeId, enabled);
|
||||
sensorTag->setHumiditySensorEnabled(enabled);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == sensorTagPressureSensorEnabledActionTypeId) {
|
||||
bool enabled = action.param(sensorTagPressureSensorEnabledActionPressureSensorEnabledParamTypeId).value().toBool();
|
||||
device->setStateValue(sensorTagPressureSensorEnabledStateTypeId, enabled);
|
||||
sensorTag->setPressureSensorEnabled(enabled);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == sensorTagOpticalSensorEnabledActionTypeId) {
|
||||
bool enabled = action.param(sensorTagOpticalSensorEnabledActionOpticalSensorEnabledParamTypeId).value().toBool();
|
||||
device->setStateValue(sensorTagOpticalSensorEnabledStateTypeId, enabled);
|
||||
sensorTag->setOpticalSensorEnabled(enabled);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == sensorTagAccelerometerEnabledActionTypeId) {
|
||||
bool enabled = action.param(sensorTagAccelerometerEnabledActionAccelerometerEnabledParamTypeId).value().toBool();
|
||||
device->setStateValue(sensorTagAccelerometerEnabledStateTypeId, enabled);
|
||||
sensorTag->setAccelerometerEnabled(enabled);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == sensorTagGyroscopeEnabledActionTypeId) {
|
||||
bool enabled = action.param(sensorTagGyroscopeEnabledActionGyroscopeEnabledParamTypeId).value().toBool();
|
||||
device->setStateValue(sensorTagGyroscopeEnabledStateTypeId, enabled);
|
||||
sensorTag->setGyroscopeEnabled(enabled);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == sensorTagMagnetometerEnabledActionTypeId) {
|
||||
bool enabled = action.param(sensorTagMagnetometerEnabledActionMagnetometerEnabledParamTypeId).value().toBool();
|
||||
device->setStateValue(sensorTagMagnetometerEnabledStateTypeId, enabled);
|
||||
sensorTag->setMagnetometerEnabled(enabled);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == sensorTagMeasurementPeriodActionTypeId) {
|
||||
int period = action.param(sensorTagMeasurementPeriodActionMeasurementPeriodParamTypeId).value().toInt();
|
||||
device->setStateValue(sensorTagMeasurementPeriodStateTypeId, period);
|
||||
sensorTag->setMeasurementPeriod(period);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == sensorTagMeasurementPeriodMovementActionTypeId) {
|
||||
int period = action.param(sensorTagMeasurementPeriodMovementActionMeasurementPeriodMovementParamTypeId).value().toInt();
|
||||
device->setStateValue(sensorTagMeasurementPeriodMovementStateTypeId, period);
|
||||
sensorTag->setMeasurementPeriodMovement(period);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == sensorTagMovementSensitivityActionTypeId) {
|
||||
int sensitivity = action.param(sensorTagMovementSensitivityActionMovementSensitivityParamTypeId).value().toInt();
|
||||
device->setStateValue(sensorTagMovementSensitivityStateTypeId, sensitivity);
|
||||
sensorTag->setMovementSensitivity(sensitivity);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
class SensorTag;
|
||||
|
||||
@ -41,11 +41,11 @@ public:
|
||||
explicit DevicePluginTexasInstruments(QObject *parent = nullptr);
|
||||
~DevicePluginTexasInstruments() override;
|
||||
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void postSetupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private:
|
||||
QHash<Device*, SensorTag*> m_sensorTags;
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
#include <QFile>
|
||||
#include <QObject>
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devices/device.h"
|
||||
#include "extern-plugininfo.h"
|
||||
|
||||
#include "sensorfilter.h"
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devices/device.h"
|
||||
#include "extern-plugininfo.h"
|
||||
#include "sensordataprocessor.h"
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "devicepluginudpcommander.h"
|
||||
#include "plugin/device.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
DevicePluginUdpCommander::DevicePluginUdpCommander()
|
||||
@ -30,7 +30,7 @@ DevicePluginUdpCommander::DevicePluginUdpCommander()
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginUdpCommander::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginUdpCommander::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcUdpCommander()) << "Setup device" << device->name() << device->params();
|
||||
|
||||
@ -40,25 +40,25 @@ DeviceManager::DeviceSetupStatus DevicePluginUdpCommander::setupDevice(Device *d
|
||||
if (!udpSocket->bind(QHostAddress::Any, port, QUdpSocket::ShareAddress)) {
|
||||
qCWarning(dcUdpCommander()) << device->name() << "cannot bind to port" << port;
|
||||
delete udpSocket;
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
qCDebug(dcUdpCommander()) << "Listening on port" << port;
|
||||
|
||||
connect(udpSocket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));
|
||||
m_receiverList.insert(udpSocket, device);
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
} else if (device->deviceClassId() == udpCommanderDeviceClassId) {
|
||||
QUdpSocket *udpSocket = new QUdpSocket(this);
|
||||
m_commanderList.insert(udpSocket, device);
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
|
||||
DeviceManager::DeviceError DevicePluginUdpCommander::executeAction(Device *device, const Action &action) {
|
||||
Device::DeviceError DevicePluginUdpCommander::executeAction(Device *device, const Action &action) {
|
||||
|
||||
if (device->deviceClassId() == udpCommanderDeviceClassId) {
|
||||
if (action.actionTypeId() == udpCommanderTriggerActionTypeId) {
|
||||
@ -69,11 +69,11 @@ DeviceManager::DeviceError DevicePluginUdpCommander::executeAction(Device *devic
|
||||
qDebug(dcUdpCommander()) << "Send UDP datagram:" << data << "address:" << address.toIPv4Address() << "port:" << port;
|
||||
udpSocket->writeDatagram(data, address, port);
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginUdpCommander::deviceRemoved(Device *device)
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
#ifndef DEVICEPLUGINUDPCOMMANDER_H
|
||||
#define DEVICEPLUGINUDPCOMMANDER_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QDebug>
|
||||
@ -39,10 +39,10 @@ class DevicePluginUdpCommander : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginUdpCommander();
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private:
|
||||
QHash<QUdpSocket *, Device *> m_receiverList;
|
||||
|
||||
@ -39,7 +39,7 @@ void DevicePluginUniPi::init()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginUniPi::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginUniPi::setupDevice(Device *device)
|
||||
{
|
||||
connectToEvok();
|
||||
|
||||
@ -51,33 +51,33 @@ DeviceManager::DeviceSetupStatus DevicePluginUniPi::setupDevice(Device *device)
|
||||
if (device->deviceClassId() == relayOutputDeviceClassId) {
|
||||
|
||||
m_usedRelais.insert(device->paramValue(relayOutputDeviceNumberParamTypeId).toString(), device);
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == digitalOutputDeviceClassId) {
|
||||
|
||||
m_usedDigitalOutputs.insert(device->paramValue(digitalOutputDeviceNumberParamTypeId).toString(), device);
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == digitalInputDeviceClassId) {
|
||||
|
||||
m_usedDigitalInputs.insert(device->paramValue(digitalInputDeviceNumberParamTypeId).toString(), device);
|
||||
requestAllData();
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == analogInputDeviceClassId) {
|
||||
|
||||
m_usedAnalogInputs.insert(device->paramValue(analogInputDeviceInputNumberParamTypeId).toString(), device);
|
||||
requestAllData();
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == analogOutputDeviceClassId) {
|
||||
|
||||
m_usedAnalogOutputs.insert(device->paramValue(analogOutputDeviceOutputNumberParamTypeId).toString(), device);
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == blindDeviceClassId) {
|
||||
@ -94,7 +94,7 @@ DeviceManager::DeviceSetupStatus DevicePluginUniPi::setupDevice(Device *device)
|
||||
m_usedDigitalOutputs.insert(device->paramValue(blindDeviceOutputCloseParamTypeId).toString(), device);
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == lightDeviceClassId) {
|
||||
@ -104,7 +104,7 @@ DeviceManager::DeviceSetupStatus DevicePluginUniPi::setupDevice(Device *device)
|
||||
} else if (device->paramValue(lightDeviceOutputParamTypeId) == GpioType::DigitalOutput) {
|
||||
m_usedDigitalOutputs.insert(device->paramValue(lightDeviceOutputParamTypeId).toString(), device);
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == dimmerSwitchDeviceClassId) {
|
||||
@ -116,20 +116,20 @@ DeviceManager::DeviceSetupStatus DevicePluginUniPi::setupDevice(Device *device)
|
||||
connect(dimmerSwitch, &DimmerSwitch::doublePressed, this, &DevicePluginUniPi::onDimmerSwitchDoublePressed);
|
||||
connect(dimmerSwitch, &DimmerSwitch::dimValueChanged, this, &DevicePluginUniPi::onDimmerSwitchDimValueChanged);
|
||||
m_dimmerSwitches.insert(dimmerSwitch, device);
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == temperatureSensorDeviceClassId) {
|
||||
|
||||
m_usedTemperatureSensors.insert(device->paramValue(temperatureSensorDeviceAddressParamTypeId).toString(), device);
|
||||
requestAllData();
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginUniPi::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginUniPi::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params);
|
||||
qSort(m_relais);
|
||||
@ -138,7 +138,7 @@ DeviceManager::DeviceError DevicePluginUniPi::discoverDevices(const DeviceClassI
|
||||
qSort(m_analogInputs);
|
||||
qSort(m_analogOutputs);
|
||||
|
||||
const DeviceClass deviceClass = deviceManager()->findDeviceClass(deviceClassId);
|
||||
const DeviceClass deviceClass = supportedDevices().findById(deviceClassId);
|
||||
if (deviceClass.vendorId() == unipiVendorId) {
|
||||
|
||||
if (deviceClassId == relayOutputDeviceClassId) {
|
||||
@ -167,7 +167,7 @@ DeviceManager::DeviceError DevicePluginUniPi::discoverDevices(const DeviceClassI
|
||||
deviceDescriptors.append(descriptor);
|
||||
}
|
||||
emit devicesDiscovered(deviceClassId, deviceDescriptors);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
if (deviceClassId == digitalOutputDeviceClassId) {
|
||||
@ -187,7 +187,7 @@ DeviceManager::DeviceError DevicePluginUniPi::discoverDevices(const DeviceClassI
|
||||
deviceDescriptors.append(descriptor);
|
||||
}
|
||||
emit devicesDiscovered(deviceClassId, deviceDescriptors);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
if (deviceClassId == digitalInputDeviceClassId) {
|
||||
@ -207,7 +207,7 @@ DeviceManager::DeviceError DevicePluginUniPi::discoverDevices(const DeviceClassI
|
||||
deviceDescriptors.append(descriptor);
|
||||
}
|
||||
emit devicesDiscovered(deviceClassId, deviceDescriptors);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
if (deviceClassId == analogInputDeviceClassId) {
|
||||
@ -227,7 +227,7 @@ DeviceManager::DeviceError DevicePluginUniPi::discoverDevices(const DeviceClassI
|
||||
deviceDescriptors.append(descriptor);
|
||||
}
|
||||
emit devicesDiscovered(deviceClassId, deviceDescriptors);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
if (deviceClassId == analogOutputDeviceClassId) {
|
||||
@ -247,7 +247,7 @@ DeviceManager::DeviceError DevicePluginUniPi::discoverDevices(const DeviceClassI
|
||||
deviceDescriptors.append(descriptor);
|
||||
}
|
||||
emit devicesDiscovered(deviceClassId, deviceDescriptors);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
if (deviceClassId == blindDeviceClassId) {
|
||||
@ -308,7 +308,7 @@ DeviceManager::DeviceError DevicePluginUniPi::discoverDevices(const DeviceClassI
|
||||
}
|
||||
|
||||
emit devicesDiscovered(deviceClassId, deviceDescriptors);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
if (deviceClassId == lightDeviceClassId) {
|
||||
@ -344,7 +344,7 @@ DeviceManager::DeviceError DevicePluginUniPi::discoverDevices(const DeviceClassI
|
||||
deviceDescriptors.append(descriptor);
|
||||
}
|
||||
emit devicesDiscovered(deviceClassId, deviceDescriptors);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
if (deviceClassId == dimmerSwitchDeviceClassId) {
|
||||
@ -364,7 +364,7 @@ DeviceManager::DeviceError DevicePluginUniPi::discoverDevices(const DeviceClassI
|
||||
deviceDescriptors.append(descriptor);
|
||||
}
|
||||
emit devicesDiscovered(deviceClassId, deviceDescriptors);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
if (deviceClassId == temperatureSensorDeviceClassId) {
|
||||
@ -384,10 +384,10 @@ DeviceManager::DeviceError DevicePluginUniPi::discoverDevices(const DeviceClassI
|
||||
deviceDescriptors.append(descriptor);
|
||||
}
|
||||
emit devicesDiscovered(deviceClassId, deviceDescriptors);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginUniPi::setOutput(const QString &circuit, bool value)
|
||||
@ -472,10 +472,10 @@ void DevicePluginUniPi::deviceRemoved(Device *device)
|
||||
}
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginUniPi::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginUniPi::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (m_webSocket->state() != QAbstractSocket::ConnectedState)
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
if (device->deviceClassId() == relayOutputDeviceClassId) {
|
||||
|
||||
@ -484,9 +484,9 @@ DeviceManager::DeviceError DevicePluginUniPi::executeAction(Device *device, cons
|
||||
int stateValue = action.param(relayOutputPowerActionPowerParamTypeId).value().toInt();
|
||||
setOutput(relayNumber, stateValue);
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == digitalOutputDeviceClassId) {
|
||||
@ -495,9 +495,9 @@ DeviceManager::DeviceError DevicePluginUniPi::executeAction(Device *device, cons
|
||||
bool stateValue = action.param(digitalOutputPowerActionPowerParamTypeId).value().toBool();
|
||||
setOutput(digitalOutputNumber, stateValue);
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == analogOutputDeviceClassId) {
|
||||
@ -516,9 +516,9 @@ DeviceManager::DeviceError DevicePluginUniPi::executeAction(Device *device, cons
|
||||
QByteArray bytes = doc.toJson(QJsonDocument::Compact);
|
||||
qCDebug(dcUniPi()) << "Send command" << bytes;
|
||||
m_webSocket->sendTextMessage(bytes);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == blindDeviceClassId) {
|
||||
@ -529,21 +529,21 @@ DeviceManager::DeviceError DevicePluginUniPi::executeAction(Device *device, cons
|
||||
|
||||
setOutput(circuitOpen, false);
|
||||
setOutput(circuitClose, true);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == blindOpenActionTypeId) {
|
||||
|
||||
setOutput(circuitClose, false);
|
||||
setOutput(circuitOpen, true);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == blindStopActionTypeId) {
|
||||
setOutput(circuitOpen, false);
|
||||
setOutput(circuitClose, false);
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == lightDeviceClassId) {
|
||||
@ -552,10 +552,10 @@ DeviceManager::DeviceError DevicePluginUniPi::executeAction(Device *device, cons
|
||||
bool stateValue = action.param(lightPowerActionPowerParamTypeId).value().toBool();
|
||||
|
||||
setOutput(circuit, stateValue);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -24,8 +24,7 @@
|
||||
#ifndef DEVICEPLUGINUNIPI_H
|
||||
#define DEVICEPLUGINUNIPI_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
#include <QtWebSockets/QtWebSockets>
|
||||
#include "plugintimer.h"
|
||||
#include "dimmerswitch.h"
|
||||
@ -43,10 +42,10 @@ public:
|
||||
~DevicePluginUniPi();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "devicepluginunitec.h"
|
||||
#include "devicemanager.h"
|
||||
#include "plugininfo.h"
|
||||
#include "hardwaremanager.h"
|
||||
#include "hardware/radio433/radio433.h"
|
||||
@ -33,32 +32,32 @@ DevicePluginUnitec::DevicePluginUnitec()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginUnitec::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginUnitec::setupDevice(Device *device)
|
||||
{
|
||||
if (device->deviceClassId() != switchDeviceClassId) {
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
foreach (Device* d, myDevices()) {
|
||||
if (d->paramValue(switchDeviceChannelParamTypeId).toString() == device->paramValue(switchDeviceChannelParamTypeId).toString()) {
|
||||
qCWarning(dcUnitec) << "Unitec switch with channel " << device->paramValue(switchDeviceChannelParamTypeId).toString() << "already added.";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginUnitec::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginUnitec::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (!hardwareManager()->radio433()->available())
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
|
||||
QList<int> rawData;
|
||||
QByteArray binCode;
|
||||
|
||||
if (action.actionTypeId() != switchPowerActionTypeId) {
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
// Bin codes for buttons
|
||||
@ -105,8 +104,8 @@ DeviceManager::DeviceError DevicePluginUnitec::executeAction(Device *device, con
|
||||
qCDebug(dcUnitec) << "transmitted" << pluginName() << device->name() << "power: " << action.param(switchPowerActionPowerParamTypeId).value().toBool();
|
||||
}else{
|
||||
qCWarning(dcUnitec) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param(switchPowerActionPowerParamTypeId).value().toBool();
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef DEVICEPLUGINUNITEC_H
|
||||
#define DEVICEPLUGINUNITEC_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
class DevicePluginUnitec : public DevicePlugin
|
||||
{
|
||||
@ -35,10 +35,10 @@ class DevicePluginUnitec : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginUnitec();
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
|
||||
public slots:
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -22,8 +22,7 @@
|
||||
|
||||
#include "devicepluginwakeonlan.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
#include <QDebug>
|
||||
@ -34,13 +33,13 @@ DevicePluginWakeOnLan::DevicePluginWakeOnLan()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginWakeOnLan::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginWakeOnLan::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if(action.actionTypeId() == wolTriggerActionTypeId){
|
||||
qCDebug(dcWakeOnLan) << "Wake up" << device->name();
|
||||
wakeup(device->paramValue(wolDeviceMacParamTypeId).toString());
|
||||
}
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
void DevicePluginWakeOnLan::wakeup(QString mac)
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef DEVICEPLUGINWAKEONLAN_H
|
||||
#define DEVICEPLUGINWAKEONLAN_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
@ -37,7 +37,7 @@ class DevicePluginWakeOnLan : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginWakeOnLan();
|
||||
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private slots:
|
||||
void wakeup(QString mac);
|
||||
|
||||
@ -22,8 +22,7 @@
|
||||
|
||||
#include "devicepluginwemo.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devices/device.h"
|
||||
#include "plugininfo.h"
|
||||
#include "network/networkaccessmanager.h"
|
||||
#include "network/upnp/upnpdiscovery.h"
|
||||
@ -52,30 +51,30 @@ void DevicePluginWemo::init()
|
||||
connect(hardwareManager()->upnpDiscovery(), &UpnpDiscovery::upnpNotify, this, &DevicePluginWemo::onUpnpNotifyReceived);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginWemo::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
Device::DeviceError DevicePluginWemo::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params);
|
||||
Q_UNUSED(deviceClassId)
|
||||
|
||||
UpnpDiscoveryReply *reply = hardwareManager()->upnpDiscovery()->discoverDevices("upnp:rootdevice");
|
||||
connect(reply, &UpnpDiscoveryReply::finished, this, &DevicePluginWemo::onUpnpDiscoveryFinished);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginWemo::setupDevice(Device *device)
|
||||
Device::DeviceSetupStatus DevicePluginWemo::setupDevice(Device *device)
|
||||
{
|
||||
if (device->deviceClassId() != wemoSwitchDeviceClassId) {
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
refresh(device);
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginWemo::executeAction(Device *device, const Action &action)
|
||||
Device::DeviceError DevicePluginWemo::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
if (device->deviceClassId() != wemoSwitchDeviceClassId)
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
|
||||
// Set power
|
||||
if (action.actionTypeId() == wemoSwitchPowerActionTypeId) {
|
||||
@ -83,16 +82,16 @@ DeviceManager::DeviceError DevicePluginWemo::executeAction(Device *device, const
|
||||
if (device->stateValue(wemoSwitchConnectedStateTypeId).toBool()) {
|
||||
// setPower returns false, if the curent powerState is already the new powerState
|
||||
if (setPower(device, action.param(wemoSwitchPowerActionPowerParamTypeId).value().toBool(), action.id())) {
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
return Device::DeviceErrorAsync;
|
||||
} else {
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
} else {
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
return Device::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginWemo::deviceRemoved(Device *device)
|
||||
@ -168,12 +167,12 @@ void DevicePluginWemo::processRefreshData(const QByteArray &data, Device *device
|
||||
void DevicePluginWemo::processSetPowerData(const QByteArray &data, Device *device, const ActionId &actionId)
|
||||
{
|
||||
if (data.contains("<BinaryState>1</BinaryState>") || data.contains("<BinaryState>0</BinaryState>")) {
|
||||
emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorNoError);
|
||||
emit actionExecutionFinished(actionId, Device::DeviceErrorNoError);
|
||||
device->setStateValue(wemoSwitchConnectedStateTypeId, true);
|
||||
refresh(device);
|
||||
} else {
|
||||
device->setStateValue(wemoSwitchConnectedStateTypeId, false);
|
||||
emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorHardwareNotAvailable);
|
||||
emit actionExecutionFinished(actionId, Device::DeviceErrorHardwareNotAvailable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
#define DEVICEPLUGINWEMO_H
|
||||
|
||||
#include "plugintimer.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "devices/deviceplugin.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
|
||||
@ -40,9 +40,9 @@ public:
|
||||
~DevicePluginWemo();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
Device::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
private:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user