From ff6c8f1ce0f547faf8e916117464ed731ecb5d54 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 25 Oct 2018 12:07:38 +0200 Subject: [PATCH] gateway now inherits connectable --- netatmo/devicepluginnetatmo.cpp | 12 ++++++------ netatmo/devicepluginnetatmo.json | 4 ++-- orderbutton/devicepluginorderbutton.cpp | 8 ++++---- orderbutton/devicepluginorderbutton.json | 2 +- osdomotics/devicepluginosdomotics.json | 11 +++++++++++ plantcare/devicepluginplantcare.cpp | 8 ++++---- plantcare/devicepluginplantcare.json | 2 +- snapd/devicepluginsnapd.json | 1 + ws2812/devicepluginws2812.cpp | 8 ++++---- ws2812/devicepluginws2812.json | 2 +- 10 files changed, 35 insertions(+), 23 deletions(-) diff --git a/netatmo/devicepluginnetatmo.cpp b/netatmo/devicepluginnetatmo.cpp index 7993f25a..1dc9d32c 100644 --- a/netatmo/devicepluginnetatmo.cpp +++ b/netatmo/devicepluginnetatmo.cpp @@ -66,13 +66,13 @@ void DevicePluginNetatmo::init() DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device) { - if (device->deviceClassId() == connectionDeviceClassId) { + if (device->deviceClassId() == netatmoConnectionDeviceClassId) { qCDebug(dcNetatmo) << "Setup netatmo connection" << device->name() << device->params(); OAuth2 *authentication = new OAuth2("561c015d49c75f0d1cce6e13", "GuvKkdtu7JQlPD47qTTepRR9hQ0CUPAj4Tae3Ohcq", this); authentication->setUrl(QUrl("https://api.netatmo.net/oauth2/token")); - authentication->setUsername(device->paramValue(connectionDeviceUsernameParamTypeId).toString()); - authentication->setPassword(device->paramValue(connectionDevicePasswordParamTypeId).toString()); + authentication->setUsername(device->paramValue(netatmoConnectionDeviceUsernameParamTypeId).toString()); + authentication->setPassword(device->paramValue(netatmoConnectionDevicePasswordParamTypeId).toString()); authentication->setScope("read_station read_thermostat write_thermostat"); m_authentications.insert(authentication, device); @@ -109,7 +109,7 @@ DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device void DevicePluginNetatmo::deviceRemoved(Device *device) { - if (device->deviceClassId() == connectionDeviceClassId) { + if (device->deviceClassId() == netatmoConnectionDeviceClassId) { OAuth2 * authentication = m_authentications.key(device); m_authentications.remove(authentication); authentication->deleteLater(); @@ -252,7 +252,7 @@ void DevicePluginNetatmo::onNetworkReplyFinished() // check HTTP status code if (status != 200) { qCWarning(dcNetatmo) << "Device list reply HTTP error:" << status << reply->errorString(); - device->setStateValue(connectionAvailableStateTypeId, false); + device->setStateValue(netatmoConnectionConnectedStateTypeId, false); reply->deleteLater(); return; } @@ -282,7 +282,7 @@ void DevicePluginNetatmo::onAuthenticationChanged() return; // set the available state - device->setStateValue(connectionAvailableStateTypeId, authentication->authenticated()); + device->setStateValue(netatmoConnectionConnectedStateTypeId, authentication->authenticated()); // check if this is was a setup athentication if (m_asyncSetups.contains(device)) { diff --git a/netatmo/devicepluginnetatmo.json b/netatmo/devicepluginnetatmo.json index 93f7dae4..f552bcf6 100644 --- a/netatmo/devicepluginnetatmo.json +++ b/netatmo/devicepluginnetatmo.json @@ -10,7 +10,7 @@ "deviceClasses": [ { "id": "728d5a67-27a3-400e-b83c-2765f5196f69", - "name": "connection", + "name": "netatmoConnection", "displayName": "Netatmo Connection", "criticalStateTypeId": "2f79bc1d-27ed-480a-b583-728363c83ea6", "deviceIcon": "Network", @@ -40,7 +40,7 @@ "stateTypes": [ { "id": "2f79bc1d-27ed-480a-b583-728363c83ea6", - "name": "available", + "name": "connected", "displayName": "available", "displayNameEvent": "available changed", "type": "bool", diff --git a/orderbutton/devicepluginorderbutton.cpp b/orderbutton/devicepluginorderbutton.cpp index 6192ee97..823f2590 100644 --- a/orderbutton/devicepluginorderbutton.cpp +++ b/orderbutton/devicepluginorderbutton.cpp @@ -122,7 +122,7 @@ DeviceManager::DeviceError DevicePluginOrderButton::executeAction(Device *device qCDebug(dcOrderButton) << "Execute action" << device->name() << action.params(); // Check if the device is reachable - if (!device->stateValue(orderbuttonReachableStateTypeId).toBool()) { + if (!device->stateValue(orderbuttonConnectedStateTypeId).toBool()) { qCWarning(dcOrderButton) << "Device not reachable."; return DeviceManager::DeviceErrorHardwareNotAvailable; } @@ -273,7 +273,7 @@ void DevicePluginOrderButton::enableNotifications(Device *device) void DevicePluginOrderButton::setReachable(Device *device, const bool &reachable) { - if (device->stateValue(orderbuttonReachableStateTypeId).toBool() != reachable) { + if (device->stateValue(orderbuttonConnectedStateTypeId).toBool() != reachable) { if (!reachable) { // Warn just once that the device is not reachable qCWarning(dcOrderButton()) << device->name() << "reachable changed" << reachable; @@ -291,7 +291,7 @@ void DevicePluginOrderButton::setReachable(Device *device, const bool &reachable } } - device->setStateValue(orderbuttonReachableStateTypeId, reachable); + device->setStateValue(orderbuttonConnectedStateTypeId, reachable); } bool DevicePluginOrderButton::deviceAlreadyAdded(const QHostAddress &address) @@ -377,7 +377,7 @@ void DevicePluginOrderButton::coapReplyFinished(CoapReply *reply) // Check CoAP reply error if (reply->error() != CoapReply::NoError) { - if (device->stateValue(orderbuttonReachableStateTypeId).toBool()) + if (device->stateValue(orderbuttonConnectedStateTypeId).toBool()) qCWarning(dcOrderButton) << "Ping device" << reply->request().url().toString() << "reply finished with error" << reply->errorString(); setReachable(device, false); diff --git a/orderbutton/devicepluginorderbutton.json b/orderbutton/devicepluginorderbutton.json index 657cf545..ecc1e0e5 100644 --- a/orderbutton/devicepluginorderbutton.json +++ b/orderbutton/devicepluginorderbutton.json @@ -58,7 +58,7 @@ }, { "id": "783e74ee-ffd6-4dd7-ade5-3a961452cf15", - "name": "reachable", + "name": "connected", "displayNameEvent": "reachable changed", "displayName": "reachable", "type": "bool", diff --git a/osdomotics/devicepluginosdomotics.json b/osdomotics/devicepluginosdomotics.json index 59d04b4e..c247afb0 100644 --- a/osdomotics/devicepluginosdomotics.json +++ b/osdomotics/devicepluginosdomotics.json @@ -34,6 +34,17 @@ "type": "QString", "inputType": "IPv6Address" } + ], + "stateTypes": [ + { + "id": "2389b6c4-31ad-4058-bcc9-c2feb0c041d8", + "name": "connected", + "displayName": "Connected", + "displayNameEvent": "Connected changed", + "type": "bool", + "defaultValue": true + } + ] }, { diff --git a/plantcare/devicepluginplantcare.cpp b/plantcare/devicepluginplantcare.cpp index 0dfcdafe..210d6699 100644 --- a/plantcare/devicepluginplantcare.cpp +++ b/plantcare/devicepluginplantcare.cpp @@ -123,7 +123,7 @@ DeviceManager::DeviceError DevicePluginPlantCare::executeAction(Device *device, qCDebug(dcPlantCare) << "Execute action" << device->name() << action.params(); // Check if the device is reachable - if (!device->stateValue(plantCareReachableStateTypeId).toBool()) { + if (!device->stateValue(plantCareConnectedStateTypeId).toBool()) { qCWarning(dcPlantCare) << "Device not reachable."; return DeviceManager::DeviceErrorHardwareNotAvailable; } @@ -316,7 +316,7 @@ void DevicePluginPlantCare::enableNotifications(Device *device) void DevicePluginPlantCare::setReachable(Device *device, const bool &reachable) { - if (device->stateValue(plantCareReachableStateTypeId).toBool() != reachable) { + if (device->stateValue(plantCareConnectedStateTypeId).toBool() != reachable) { if (!reachable) { // Warn just once that the device is not reachable qCWarning(dcPlantCare()) << device->name() << "reachable changed" << reachable; @@ -335,7 +335,7 @@ void DevicePluginPlantCare::setReachable(Device *device, const bool &reachable) } } - device->setStateValue(plantCareReachableStateTypeId, reachable); + device->setStateValue(plantCareConnectedStateTypeId, reachable); } bool DevicePluginPlantCare::deviceAlreadyAdded(const QHostAddress &address) @@ -421,7 +421,7 @@ void DevicePluginPlantCare::coapReplyFinished(CoapReply *reply) // Check CoAP reply error if (reply->error() != CoapReply::NoError) { - if (device->stateValue(plantCareReachableStateTypeId).toBool()) + if (device->stateValue(plantCareConnectedStateTypeId).toBool()) qCWarning(dcPlantCare) << "Ping device" << reply->request().url().toString() << "reply finished with error" << reply->errorString(); setReachable(device, false); diff --git a/plantcare/devicepluginplantcare.json b/plantcare/devicepluginplantcare.json index fea5eee9..72a2abf7 100644 --- a/plantcare/devicepluginplantcare.json +++ b/plantcare/devicepluginplantcare.json @@ -88,7 +88,7 @@ }, { "id": "8384e07b-8b91-492a-b6c8-e72b325ba0b4", - "name": "reachable", + "name": "connected", "displayName": "reachable", "displayNameEvent": "reachable changed", "type": "bool", diff --git a/snapd/devicepluginsnapd.json b/snapd/devicepluginsnapd.json index a9f49b23..3b70052e 100644 --- a/snapd/devicepluginsnapd.json +++ b/snapd/devicepluginsnapd.json @@ -115,6 +115,7 @@ "displayName": "Snap", "createMethods": [ "auto" ], "basicTags": [ "Gateway" ], + "interfaces": ["system"], "deviceIcon": "Network", "paramTypes": [ { diff --git a/ws2812/devicepluginws2812.cpp b/ws2812/devicepluginws2812.cpp index 69fc3b9f..71df2c3f 100644 --- a/ws2812/devicepluginws2812.cpp +++ b/ws2812/devicepluginws2812.cpp @@ -128,7 +128,7 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con qCDebug(dcWs2812) << "Execute action" << device->name() << action.params(); // Check if the device is reachable - if (!device->stateValue(ws2812ReachableStateTypeId).toBool()) { + if (!device->stateValue(ws2812ConnectedStateTypeId).toBool()) { qCWarning(dcWs2812) << "Device not reachable."; return DeviceManager::DeviceErrorHardwareNotAvailable; } @@ -468,7 +468,7 @@ void DevicePluginWs2812::enableNotifications(Device *device) void DevicePluginWs2812::setReachable(Device *device, const bool &reachable) { - if (device->stateValue(ws2812ReachableStateTypeId).toBool() != reachable) { + if (device->stateValue(ws2812ConnectedStateTypeId).toBool() != reachable) { if (!reachable) { // Warn just once that the device is not reachable qCWarning(dcWs2812()) << device->name() << "reachable changed" << reachable; @@ -487,7 +487,7 @@ void DevicePluginWs2812::setReachable(Device *device, const bool &reachable) } } - device->setStateValue(ws2812ReachableStateTypeId, reachable); + device->setStateValue(ws2812ConnectedStateTypeId, reachable); } bool DevicePluginWs2812::deviceAlreadyAdded(const QHostAddress &address) @@ -573,7 +573,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply) // Check CoAP reply error if (reply->error() != CoapReply::NoError) { - if (device->stateValue(ws2812ReachableStateTypeId).toBool()) + if (device->stateValue(ws2812ConnectedStateTypeId).toBool()) qCWarning(dcWs2812) << "Ping device" << reply->request().url().toString() << "reply finished with error" << reply->errorString(); setReachable(device, false); diff --git a/ws2812/devicepluginws2812.json b/ws2812/devicepluginws2812.json index fd0731e9..ceea4b84 100644 --- a/ws2812/devicepluginws2812.json +++ b/ws2812/devicepluginws2812.json @@ -50,7 +50,7 @@ }, { "id": "08091cde-983d-42f7-bdd7-d89c312ccbed", - "name": "reachable", + "name": "connected", "displayName": "reachable", "displayNameEvent": "reachable changed", "type": "bool",