From fb2406d4787d723fd22ab41c9d4be0fcb8378ee1 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Mon, 18 Aug 2014 03:00:42 +0200 Subject: [PATCH] port new plugins to json system --- libguh/plugin/deviceplugin.cpp | 62 +++--- libguh/plugin/deviceplugin.h | 2 + .../conrad/devicepluginconrad.json | 35 ++- .../deviceplugins/elro/devicepluginelro.json | 159 ++++++++++++- .../intertechno/devicepluginintertechno.cpp | 150 ------------- .../intertechno/devicepluginintertechno.json | 208 +++++++++++++++++- .../deviceplugins/lircd/devicepluginlircd.cpp | 48 ---- .../lircd/devicepluginlircd.json | 31 ++- .../devicepluginmailnotification.json | 12 +- .../deviceplugins/mock/devicepluginmock.cpp | 148 ------------- .../deviceplugins/mock/devicepluginmock.json | 95 +++++++- .../devicepluginopenweathermap.json | 109 ++++++++- .../philipshue/devicepluginphilipshue.cpp | 70 ------ .../philipshue/devicepluginphilipshue.json | 34 ++- .../wakeonlan/devicepluginwakeonlan.json | 26 ++- .../wifidetector/devicepluginwifidetector.cpp | 28 --- .../devicepluginwifidetector.json | 24 +- 17 files changed, 757 insertions(+), 484 deletions(-) diff --git a/libguh/plugin/deviceplugin.cpp b/libguh/plugin/deviceplugin.cpp index 04b97d50..2063f729 100644 --- a/libguh/plugin/deviceplugin.cpp +++ b/libguh/plugin/deviceplugin.cpp @@ -150,14 +150,20 @@ QList DevicePlugin::supportedDevices() const QJsonObject jo = deviceClassJson.toObject(); DeviceClass deviceClass(pluginId(), vendorId, jo.value("deviceClassId").toString()); deviceClass.setName(jo.value("name").toString()); - QString createMethod = jo.value("createMethod").toString(); - if (createMethod == "discovery") { - deviceClass.setCreateMethod(DeviceClass::CreateMethodDiscovery); - } else if (createMethod == "auto") { - deviceClass.setCreateMethod(DeviceClass::CreateMethodAuto); - } else { - deviceClass.setCreateMethod(DeviceClass::CreateMethodUser); + DeviceClass::CreateMethods createMethods; + foreach (const QJsonValue &createMethodValue, jo.value("createMethods").toArray()) { + if (createMethodValue.toString() == "discovery") { + createMethods |= DeviceClass::CreateMethodDiscovery; + } else if (createMethodValue.toString() == "auto") { + createMethods |= DeviceClass::CreateMethodAuto; + } else { + createMethods |= DeviceClass::CreateMethodUser; + } } + deviceClass.setCreateMethods(createMethods); + + deviceClass.setDiscoveryParamTypes(parseParamTypes(jo.value("discoveryParamTypes").toArray())); + QString setupMethod = jo.value("setupMethod").toString(); if (setupMethod == "pushButton") { deviceClass.setSetupMethod(DeviceClass::SetupMethodPushButton); @@ -169,21 +175,7 @@ QList DevicePlugin::supportedDevices() const deviceClass.setSetupMethod(DeviceClass::SetupMethodJustAdd); } deviceClass.setPairingInfo(jo.value("pairingInfo").toString()); - - QList paramTypes; - foreach (const QJsonValue ¶mTypesJson, jo.value("paramTypes").toArray()) { - QJsonObject pt = paramTypesJson.toObject(); - QVariant::Type t = QVariant::nameToType(pt.value("type").toString().toLatin1().data()); - ParamType paramType(pt.value("name").toString(), t, pt.value("defaultValue").toVariant()); - QVariantList allowedValues; - foreach (const QJsonValue &allowedTypesJson, pt.value("allowedValues").toArray()) { - allowedValues.append(allowedTypesJson.toVariant()); - } - paramType.setAllowedValues(allowedValues); - paramType.setLimits(pt.value("minValue").toVariant(), pt.value("maxValue").toVariant()); - paramTypes.append(paramType); - } - deviceClass.setParamTypes(paramTypes); + deviceClass.setParamTypes(parseParamTypes(jo.value("paramTypes").toArray())); QList stateTypes; qDebug() << "############### s" << jo; @@ -198,6 +190,27 @@ QList DevicePlugin::supportedDevices() const } deviceClass.setStateTypes(stateTypes); + QList actionTypes; + foreach (const QJsonValue &actionTypesJson, jo.value("actionTypes").toArray()) { + QJsonObject at = actionTypesJson.toObject(); + ActionType actionType(at.value("id").toString()); + actionType.setName(at.value("name").toString()); + actionType.setParamTypes(parseParamTypes(at.value("paramTypes").toArray())); + qDebug() << "***got actionType" << actionType.id(); + actionTypes.append(actionType); + } + deviceClass.setActionTypes(actionTypes); + + QList eventTypes; + foreach (const QJsonValue &eventTypesJson, jo.value("eventTypes").toArray()) { + QJsonObject et = eventTypesJson.toObject(); + EventType eventType(et.value("id").toString()); + eventType.setName(et.value("name").toString()); + eventType.setParamTypes(parseParamTypes(et.value("paramTypes").toArray())); + eventTypes.append(eventType); + } + deviceClass.setEventTypes(eventTypes); + deviceClasses.append(deviceClass); } } @@ -280,11 +293,6 @@ QList DevicePlugin::parseParamTypes(const QJsonArray &array) const foreach (const QJsonValue ¶mTypesJson, array) { QJsonObject pt = paramTypesJson.toObject(); QVariant::Type t = QVariant::nameToType(pt.value("type").toString().toLatin1().data()); - Q_ASSERT_X(t != QVariant::Invalid, - pluginName().toLatin1().data(), - QString("Invalid type %1 for param %2 in json file.") - .arg(pt.value("type").toString()) - .arg(pt.value("name").toString()).toLatin1().data()); ParamType paramType(pt.value("name").toString(), t, pt.value("defaultValue").toVariant()); QVariantList allowedValues; foreach (const QJsonValue &allowedTypesJson, pt.value("allowedValues").toArray()) { diff --git a/libguh/plugin/deviceplugin.h b/libguh/plugin/deviceplugin.h index 113a422c..ec80e684 100644 --- a/libguh/plugin/deviceplugin.h +++ b/libguh/plugin/deviceplugin.h @@ -96,6 +96,8 @@ protected: private: void initPlugin(const QJsonObject &metaData, DeviceManager *deviceManager); + QList parseParamTypes(const QJsonArray &array) const; + DeviceManager *m_deviceManager; ParamList m_config; diff --git a/plugins/deviceplugins/conrad/devicepluginconrad.json b/plugins/deviceplugins/conrad/devicepluginconrad.json index 64c6db47..dcf6dce7 100644 --- a/plugins/deviceplugins/conrad/devicepluginconrad.json +++ b/plugins/deviceplugins/conrad/devicepluginconrad.json @@ -4,7 +4,40 @@ "vendors": [ { "name": "Conrad Electronic SE", - "id": "986cf06f-3ef1-4271-b2a3-2cc277ebecb6" + "id": "986cf06f-3ef1-4271-b2a3-2cc277ebecb6", + "deviceClasses": [ + { + "deviceClassId": "17cd2492-28ab-4827-ba6e-5ef35be23f1b", + "name": "Conrad Remote", + "createMethods": ["user"], + "paramTypes": [ + { + "name": "name", + "type": "QString" + } + ], + "eventTypes": [ + { + "id": "1f4050f5-4c90-4799-8d6d-e4069f3a2519", + "name": "Button pressed", + "paramTypes": [ + { + "name": "button", + "type": "int" + }, + { + "name": "group", + "type": "int" + }, + { + "name": "power", + "type": "bool" + } + ] + } + ] + } + ] } ] } diff --git a/plugins/deviceplugins/elro/devicepluginelro.json b/plugins/deviceplugins/elro/devicepluginelro.json index 50f49d28..10afc111 100644 --- a/plugins/deviceplugins/elro/devicepluginelro.json +++ b/plugins/deviceplugins/elro/devicepluginelro.json @@ -4,11 +4,168 @@ "vendors": [ { "name": "Electronic Roos", - "id": "435a13a0-65ca-4f0c-94c1-e5873b258db5" + "id": "435a13a0-65ca-4f0c-94c1-e5873b258db5", + "deviceClasses": [ + { + "deviceClassId": "d85c1ef4-197c-4053-8e40-707aa671d302", + "name": "Elro Remote", + "createMethods": ["user"], + "paramTypes": [ + { + "name": "channel1", + "type": "bool" + }, + { + "name": "channel2", + "type": "bool" + }, + { + "name": "channel3", + "type": "bool" + }, + { + "name": "channel4", + "type": "bool" + }, + { + "name": "channel5", + "type": "bool" + } + ], + "eventTypes": [ + { + "id": "9dd3f862-35f3-4b69-954e-fa3c8bd68e39", + "name": "A", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "733226eb-91ba-4e37-9d78-12c87eb5e763", + "name": "B", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "47aaeaec-485a-4775-a543-33f339fd28c8", + "name": "C", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "db3d484c-add9-44ab-80a4-a0664e0c87c8", + "name": "D", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "eb914aac-fb73-4ee2-9f1b-c34b2f6cc24a", + "name": "E", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + } + ] + }, + { + "deviceClassId": "308ae6e6-38b3-4b3a-a513-3199da2764f8", + "name": "Elro switch", + "createMethods": ["user"], + "paramTypes": [ + { + "name": "channel1", + "type": "bool" + }, + { + "name": "channel2", + "type": "bool" + }, + { + "name": "channel3", + "type": "bool" + }, + { + "name": "channel4", + "type": "bool" + }, + { + "name": "channel5", + "type": "bool" + }, + { + "name": "A", + "type": "bool" + }, + { + "name": "B", + "type": "bool" + }, + { + "name": "C", + "type": "bool" + }, + { + "name": "D", + "type": "bool" + }, + { + "name": "E", + "type": "bool" + } + ], + "actionTypes": [ + { + "id": "31c9758e-6567-4f89-85bb-29e1a7c55d44", + "name": "Set power", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + } + ] + }, + { + "deviceClassId": "4c64aee6-7a4f-41f2-b278-edc55f0da0d3", + "name": "Elro motion detector", + "createMethods": ["discovery"] + } + ] }, { "name": "Mumbi", "id": "5f91c01c-0168-4bdf-a5ed-37cb6971b775" + }, + { + "name": "Vivanco", + "id": "3826a836-ba69-4e50-8408-bb827fc92128" + }, + { + "name": "Brennenstuhl", + "id": "4ac9dd1f-9ca9-4a76-aae1-3e91cfb86f5b" + }, + { + "name": "BAT", + "id": "30115ad4-c83d-454a-a483-c781c951d3b6" } ] } diff --git a/plugins/deviceplugins/intertechno/devicepluginintertechno.cpp b/plugins/deviceplugins/intertechno/devicepluginintertechno.cpp index 4225283b..fc0a3954 100644 --- a/plugins/deviceplugins/intertechno/devicepluginintertechno.cpp +++ b/plugins/deviceplugins/intertechno/devicepluginintertechno.cpp @@ -170,156 +170,6 @@ DevicePluginIntertechno::DevicePluginIntertechno() { } -//QList DevicePluginIntertechno::supportedDevices() const -//{ -// QList ret; - -// // ======================================= -// // Remote -// DeviceClass deviceClassIntertechnoRemote(pluginId(), supportedVendors().first().id(), intertechnoRemote); -// deviceClassIntertechnoRemote.setName("Intertechno Remote"); - -// QList remoteParams; -// // family code = A-P -// ParamType familyParam("familyCode", QVariant::String); -// remoteParams.append(familyParam); - -// deviceClassIntertechnoRemote.setParamTypes(remoteParams); - -// QList buttonEvents; - -// QList paramsRemote; -// // on = true -// // off = false -// ParamType paramRemote("power", QVariant::Bool); -// paramsRemote.append(paramRemote); - -// /* 1-16 -// * ________________ -// * | I | II|III| IV | -// * |---|---|---|----| -// * 1 | 1 | 5 | 9 | 13 | -// * 2 | 2 | 6 | 10| 14 | -// * 3 | 3 | 7 | 11| 15 | -// * 4 | 4 | 8 | 12| 16 | -// * |___|___|___|____| -// */ - -// EventType button1Event(EventTypeId("785c1b30-a3f2-4696-af7c-d532acf3d6f7")); -// button1Event.setName("1"); -// button1Event.setParameters(paramsRemote); -// buttonEvents.append(button1Event); - -// EventType button2Event(EventTypeId("1d42c850-7b43-452f-b205-e1aac14eb3ee")); -// button2Event.setName("2"); -// button2Event.setParameters(paramsRemote); -// buttonEvents.append(button2Event); - -// EventType button3Event(EventTypeId("77a4780e-2355-4a77-870d-2f675bf986ce")); -// button3Event.setName("3"); -// button3Event.setParameters(paramsRemote); -// buttonEvents.append(button3Event); - -// EventType button4Event(EventTypeId("bd6a8b4b-f946-4f3b-992f-e7cff10187b8")); -// button4Event.setName("4"); -// button4Event.setParameters(paramsRemote); -// buttonEvents.append(button4Event); - -// EventType button5Event(EventTypeId("0f20782e-0acc-45f1-8c42-5dc5f5b29f1b")); -// button5Event.setName("5"); -// button5Event.setParameters(paramsRemote); -// buttonEvents.append(button5Event); - -// EventType button6Event(EventTypeId("f7cb439a-0528-4905-9583-06b6bfeb3ba1")); -// button6Event.setName("6"); -// button6Event.setParameters(paramsRemote); -// buttonEvents.append(button6Event); - -// EventType button7Event(EventTypeId("a0b0d8d8-2b43-4897-98e0-05b6b408a950")); -// button7Event.setName("7"); -// button7Event.setParameters(paramsRemote); -// buttonEvents.append(button7Event); - -// EventType button8Event(EventTypeId("ae5833a2-bc43-4462-ae47-e45dac1fb0ce")); -// button8Event.setName("8"); -// button8Event.setParameters(paramsRemote); -// buttonEvents.append(button8Event); - -// EventType button9Event(EventTypeId("52c13828-d047-4256-b488-0bf84abbc87c")); -// button9Event.setName("9"); -// button9Event.setParameters(paramsRemote); -// buttonEvents.append(button9Event); - -// EventType button10Event(EventTypeId("22c5afbc-835e-47cc-8211-4429eb9d9fee")); -// button10Event.setName("10"); -// button10Event.setParameters(paramsRemote); -// buttonEvents.append(button10Event); - -// EventType button11Event(EventTypeId("6bec5cbc-8bfb-4c6c-8ac8-f8e7723fd5aa")); -// button11Event.setName("11"); -// button11Event.setParameters(paramsRemote); -// buttonEvents.append(button11Event); - -// EventType button12Event(EventTypeId("8b71edd2-8135-4c8b-bf44-380efadf1942")); -// button12Event.setName("12"); -// button12Event.setParameters(paramsRemote); -// buttonEvents.append(button12Event); - -// EventType button13Event(EventTypeId("192f36a4-1e58-41aa-9618-83d46e329a4b")); -// button13Event.setName("13"); -// button13Event.setParameters(paramsRemote); -// buttonEvents.append(button13Event); - -// EventType button14Event(EventTypeId("6c76de60-5e19-4a29-b027-e71e66caa2d6")); -// button14Event.setName("14"); -// button14Event.setParameters(paramsRemote); -// buttonEvents.append(button14Event); - -// EventType button15Event(EventTypeId("c2f56c10-1f81-4477-88fa-fc0f4a6383df")); -// button15Event.setName("15"); -// button15Event.setParameters(paramsRemote); -// buttonEvents.append(button15Event); - -// EventType button16Event(EventTypeId("5d2eb3f8-4cd4-4c71-9c0c-e0b685e168e4")); -// button16Event.setName("16"); -// button16Event.setParameters(paramsRemote); -// buttonEvents.append(button16Event); - -// deviceClassIntertechnoRemote.setEventTypes(buttonEvents); -// ret.append(deviceClassIntertechnoRemote); - - -// // ======================================= -// // Switch -// DeviceClass deviceClassIntertechnoSwitch(pluginId(), supportedVendors().last().id(), intertechnoSwitch); -// deviceClassIntertechnoSwitch.setName("Intertechno Switch"); - -// QList switchDeviceParams; -// // button code = 1-16 -// ParamType buttonParam("buttonCode", QVariant::Int); - -// switchDeviceParams.append(familyParam); -// switchDeviceParams.append(buttonParam); - -// deviceClassIntertechnoSwitch.setParamTypes(switchDeviceParams); - -// QList switchActions; - -// QList paramsSwitch; -// ParamType paramSwitch("power", QVariant::Bool); -// paramsSwitch.append(paramSwitch); - -// ActionType switchActionPower(ActionTypeId("df19fb51-c3cd-4b95-8d88-ebbb535f4789")); -// switchActionPower.setName("power"); -// switchActionPower.setParameters(paramsSwitch); -// switchActions.append(switchActionPower); - -// deviceClassIntertechnoSwitch.setActions(switchActions); -// ret.append(deviceClassIntertechnoSwitch); - -// return ret; -//} - DeviceManager::HardwareResources DevicePluginIntertechno::requiredHardware() const { return DeviceManager::HardwareResourceRadio433; diff --git a/plugins/deviceplugins/intertechno/devicepluginintertechno.json b/plugins/deviceplugins/intertechno/devicepluginintertechno.json index d3264078..ec3c961f 100644 --- a/plugins/deviceplugins/intertechno/devicepluginintertechno.json +++ b/plugins/deviceplugins/intertechno/devicepluginintertechno.json @@ -4,7 +4,213 @@ "vendors": [ { "name": "Intertechno", - "id": "6a852bc2-34dd-4f4c-9ac9-dd4c32ddbcba" + "id": "6a852bc2-34dd-4f4c-9ac9-dd4c32ddbcba", + "deviceClasses": [ + { + "deviceClassId": "ab73ad2f-6594-45a3-9063-8f72d365c5e5", + "name": "Intertechno Remote", + "createMethods": ["user"], + "paramTypes": [ + { + "name": "familyCode", + "type": "QString", + "allowedValues": ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P"] + } + ], + "eventTypes": [ + { + "id": "785c1b30-a3f2-4696-af7c-d532acf3d6f7", + "name": "Button 1 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "1d42c850-7b43-452f-b205-e1aac14eb3ee", + "name": "Button 2 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "77a4780e-2355-4a77-870d-2f675bf986ce", + "name": "Button 3 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "bd6a8b4b-f946-4f3b-992f-e7cff10187b8", + "name": "Button 4 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "0f20782e-0acc-45f1-8c42-5dc5f5b29f1b", + "name": "Button 5 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "f7cb439a-0528-4905-9583-06b6bfeb3ba1", + "name": "Button 6 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "a0b0d8d8-2b43-4897-98e0-05b6b408a950", + "name": "Button 7 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "ae5833a2-bc43-4462-ae47-e45dac1fb0ce", + "name": "Button 8 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "52c13828-d047-4256-b488-0bf84abbc87c", + "name": "Button 9 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "22c5afbc-835e-47cc-8211-4429eb9d9fee", + "name": "Button 10 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "6bec5cbc-8bfb-4c6c-8ac8-f8e7723fd5aa", + "name": "Button 11 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "8b71edd2-8135-4c8b-bf44-380efadf1942", + "name": "Button 12 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "192f36a4-1e58-41aa-9618-83d46e329a4b", + "name": "Button 13 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "6c76de60-5e19-4a29-b027-e71e66caa2d6", + "name": "Button 14 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "c2f56c10-1f81-4477-88fa-fc0f4a6383df", + "name": "Button 15 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "5d2eb3f8-4cd4-4c71-9c0c-e0b685e168e4", + "name": "Button 16 pressed", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + } + ] + }, + { + "deviceClassId": "324219e8-7c53-41b5-b314-c2900cd15252", + "name": "Intertechno switch", + "createMethods": ["user"], + "paramTypes": [ + { + "name": "familyCode", + "type": "QString", + "allowedValues": ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P"] + }, + { + "name": "button", + "type": "int", + "minimumValue": 1, + "maximumValue": 16 + } + ], + "actionTypes": [ + { + "id": "df19fb51-c3cd-4b95-8d88-ebbb535f4789", + "name": "Set power", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + } + ] + } + ] } ] } diff --git a/plugins/deviceplugins/lircd/devicepluginlircd.cpp b/plugins/deviceplugins/lircd/devicepluginlircd.cpp index 883382c9..7eee0423 100644 --- a/plugins/deviceplugins/lircd/devicepluginlircd.cpp +++ b/plugins/deviceplugins/lircd/devicepluginlircd.cpp @@ -37,54 +37,6 @@ DevicePluginLircd::DevicePluginLircd() connect(m_lircClient, &LircClient::buttonPressed, this, &DevicePluginLircd::buttonPressed); } -//QList DevicePluginLircd::supportedDevices() const -//{ -// QList ret; - -// DeviceClass deviceClassLircd(pluginId(), supportedVendors().first().id(), lircdDeviceClassId); -// deviceClassLircd.setName("IR Receiver"); - -// QList params; -// ParamType remoteNameParam("remoteName", QVariant::String); -// params.append(remoteNameParam); -// deviceClassLircd.setParamTypes(params); - -// // TODO: find a way to load this stuff from a json file, really! -// // Ideally that file can be generated from /usr/share/lirc/remotes/* -// // Note that the IDs need to be kept static! -// QList repeatParam; -// ParamType repeatParamMap("repeat", QVariant::Int); -// repeatParam.append(repeatParamMap); - -// QList events; -// EventType powerButton(EventTypeId("d62d779f-e5c6-4767-98e6-efe9c062b662")); -// powerButton.setName("Power"); -// powerButton.setParameters(repeatParam); -// events.append(powerButton); -// EventType yellowButton(EventTypeId("3313f62e-ea20-47f5-85af-28897d6ac440")); -// yellowButton.setName("Yellow"); -// yellowButton.setParameters(repeatParam); -// events.append(yellowButton); -// EventType blueButton(EventTypeId("9a395d93-e482-4fa2-b4bc-e60bb4bf8652")); -// blueButton.setName("Blue"); -// blueButton.setParameters(repeatParam); -// events.append(blueButton); -// EventType greenButton(EventTypeId("e8aaf18e-dc11-40da-980d-4eec42c58267")); -// greenButton.setName("Green"); -// greenButton.setParameters(repeatParam); -// events.append(greenButton); -// EventType redButton(EventTypeId("b8518755-55a0-4cd4-8856-1680848edcb7")); -// redButton.setName("Red"); -// redButton.setParameters(repeatParam); -// events.append(redButton); - -// deviceClassLircd.setEventTypes(events); - -// ret.append(deviceClassLircd); - -// return ret; -//} - DeviceManager::HardwareResources DevicePluginLircd::requiredHardware() const { return DeviceManager::HardwareResourceNone; diff --git a/plugins/deviceplugins/lircd/devicepluginlircd.json b/plugins/deviceplugins/lircd/devicepluginlircd.json index aae296ce..0f75dc98 100644 --- a/plugins/deviceplugins/lircd/devicepluginlircd.json +++ b/plugins/deviceplugins/lircd/devicepluginlircd.json @@ -4,7 +4,36 @@ "vendors": [ { "name": "Lirc", - "id": "9a53049c-8828-4b87-b3f6-7bc7708196cd" + "id": "9a53049c-8828-4b87-b3f6-7bc7708196cd", + "deviceClasses": [ + { + "deviceClassId": "5c2bc4cd-ba6c-4052-b6cd-1db83323ea22", + "name": "IR receiver", + "createMethods": ["user"], + "paramTypes": [ + { + "name": "remoteName", + "type": "QString" + } + ], + "eventTypes": [ + { + "id": "8711471a-fa0e-410b-b174-dfc3d2aeffb1", + "name": "Button pressed", + "paramTypes": [ + { + "name": "button", + "type": "string" + }, + { + "name": "repeat", + "type": "int" + } + ] + } + ] + } + ] } ] } diff --git a/plugins/deviceplugins/mailnotification/devicepluginmailnotification.json b/plugins/deviceplugins/mailnotification/devicepluginmailnotification.json index 47dc8e9c..31fb652c 100644 --- a/plugins/deviceplugins/mailnotification/devicepluginmailnotification.json +++ b/plugins/deviceplugins/mailnotification/devicepluginmailnotification.json @@ -4,7 +4,17 @@ "vendors": [ { "name": "guh", - "id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6" + "id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6", + "deviceClasses": [ + { + "deviceClassId": "3869884a-1592-4b8f-84a7-994be18ff555", + "name": "GMail", + "createMethods": ["user"], + "paramTypes": [ + + ] + } + ] } ] } diff --git a/plugins/deviceplugins/mock/devicepluginmock.cpp b/plugins/deviceplugins/mock/devicepluginmock.cpp index 8ae5d913..4bdf3737 100644 --- a/plugins/deviceplugins/mock/devicepluginmock.cpp +++ b/plugins/deviceplugins/mock/devicepluginmock.cpp @@ -44,154 +44,6 @@ DevicePluginMock::~DevicePluginMock() { } -//QList DevicePluginMock::supportedDevices() const -//{ -// QList ret; - -// DeviceClass deviceClassMock(pluginId(), supportedVendors().first().id(), mockDeviceClassId); -// deviceClassMock.setName("Mock Device"); - -// QList mockParams; -// ParamType portParam("httpport", QVariant::Int); -// mockParams.append(portParam); - -// deviceClassMock.setParamTypes(mockParams); - -// QList mockStates; - -// StateType intState(mockIntStateId); -// intState.setName("Dummy int state"); -// intState.setType(QVariant::Int); -// intState.setDefaultValue(10); -// mockStates.append(intState); - -// StateType boolState(mockBoolStateId); -// boolState.setName("Dummy bool state"); -// boolState.setType(QVariant::Int); -// boolState.setDefaultValue(false); -// mockStates.append(boolState); - -// deviceClassMock.setStateTypes(mockStates); - -// QList mockEvents; - -// EventType event1(mockEvent1Id); -// event1.setName("Mock Event 1"); -// mockEvents.append(event1); - -// EventType event2(mockEvent2Id); -// event2.setName("Mock Event 2"); -// QList event2ParamTypes; -// ParamType event2Param1Type("mockParamInt", QVariant::Int, 42); -// event2ParamTypes.append(event2Param1Type); -// event2.setParameters(event2ParamTypes); -// mockEvents.append(event2); - -// deviceClassMock.setEventTypes(mockEvents); - -// QList mockActions; - -// mockParams.clear(); -// ActionType action1(mockActionIdWithParams); -// action1.setName("Mock Action 1 (with params)"); -// ParamType mockActionParam1("mockActionParam1", QVariant::Int); -// mockParams.append(mockActionParam1); -// ParamType mockActionParam2("mockActionParam2", QVariant::Bool); -// mockParams.append(mockActionParam2); -// action1.setParameters(mockParams); -// mockActions.append(action1); - -// ActionType action2(mockActionIdNoParams); -// action2.setName("Mock Action 3 (without params)"); -// mockActions.append(action2); - -// ActionType action3(mockActionIdAsync); -// action3.setName("Mock Action 3 (async)"); -// mockActions.append(action3); - -// ActionType action4(mockActionIdFailing); -// action4.setName("Mock Action 4 (broken)"); -// mockActions.append(action4); - -// ActionType action5(mockActionIdAsyncFailing); -// action5.setName("Mock Action 5 (async, broken)"); -// mockActions.append(action4); - -// deviceClassMock.setActions(mockActions); - -// ret.append(deviceClassMock); - -// // Auto created mock device -// DeviceClass deviceClassMockAuto(pluginId(), supportedVendors().first().id(), mockDeviceAutoClassId); -// deviceClassMockAuto.setName("Mock Device (Auto created)"); -// deviceClassMockAuto.setCreateMethod(DeviceClass::CreateMethodAuto); - -// mockParams.clear(); -// deviceClassMockAuto.setParamTypes(mockParams); -// deviceClassMockAuto.setStateTypes(mockStates); -// deviceClassMockAuto.setEventTypes(mockEvents); -// deviceClassMockAuto.setActions(mockActions); - -// ret.append(deviceClassMockAuto); - -// // Discovery created device -// DeviceClass deviceClassMockDiscovery(pluginId(), supportedVendors().first().id(), mockDeviceDiscoveryClassId); -// deviceClassMockDiscovery.setName("Mock Device (Discovery created)"); -// deviceClassMockDiscovery.setCreateMethod(DeviceClass::CreateMethodDiscovery); -// QList paramTypes; -// ParamType paramType = ParamType("resultCount", QVariant::Int, 2); -// paramType.setAllowedValues(QList() << 1 << 2); -// paramTypes.append(paramType); -// deviceClassMockDiscovery.setDiscoveryParamTypes(paramTypes); - -// mockParams.clear(); -// mockParams.append(portParam); -// deviceClassMockDiscovery.setParamTypes(mockParams); -// deviceClassMockDiscovery.setStateTypes(mockStates); -// deviceClassMockDiscovery.setEventTypes(mockEvents); -// deviceClassMockDiscovery.setActions(mockActions); - -// ret.append(deviceClassMockDiscovery); - -// // Async setup device -// DeviceClass deviceClassMockAsync(pluginId(), supportedVendors().first().id(), mockDeviceAsyncSetupClassId); -// deviceClassMockAsync.setName("Mock Device (Async)"); -// deviceClassMockAsync.setCreateMethod(DeviceClass::CreateMethodUser); - -// deviceClassMockAsync.setParamTypes(mockParams); -// deviceClassMockAsync.setStateTypes(mockStates); -// deviceClassMockAsync.setEventTypes(mockEvents); -// deviceClassMockAsync.setActions(mockActions); - -// ret.append(deviceClassMockAsync); - -// // Async setup device -// DeviceClass deviceClassMockBroken(pluginId(), supportedVendors().first().id(), mockDeviceBrokenClassId); -// deviceClassMockBroken.setName("Mock Device (Broken setup)"); -// deviceClassMockBroken.setCreateMethod(DeviceClass::CreateMethodUser); - -// deviceClassMockBroken.setParamTypes(mockParams); -// deviceClassMockBroken.setStateTypes(mockStates); -// deviceClassMockBroken.setEventTypes(mockEvents); -// deviceClassMockBroken.setActions(mockActions); - -// ret.append(deviceClassMockBroken); - -// // Broken Async setup device -// DeviceClass deviceClassMockBrokenAsyncSetup(pluginId(), supportedVendors().first().id(), mockDeviceBrokenAsyncSetupClassId); -// deviceClassMockBrokenAsyncSetup.setName("Mock Device (Async Broken setup)"); -// deviceClassMockBrokenAsyncSetup.setCreateMethod(DeviceClass::CreateMethodUser); - -// deviceClassMockBrokenAsyncSetup.setParamTypes(mockParams); -// deviceClassMockBrokenAsyncSetup.setStateTypes(mockStates); -// deviceClassMockBrokenAsyncSetup.setEventTypes(mockEvents); -// deviceClassMockBrokenAsyncSetup.setActions(mockActions); - -// ret.append(deviceClassMockBrokenAsyncSetup); - -// return ret; -//} - DeviceManager::HardwareResources DevicePluginMock::requiredHardware() const { return DeviceManager::HardwareResourceTimer; diff --git a/plugins/deviceplugins/mock/devicepluginmock.json b/plugins/deviceplugins/mock/devicepluginmock.json index 4efceec0..ebaa620f 100644 --- a/plugins/deviceplugins/mock/devicepluginmock.json +++ b/plugins/deviceplugins/mock/devicepluginmock.json @@ -4,8 +4,99 @@ "vendors": [ { "name": "guh", - "id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6" + "id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6", + "deviceClasses": [ + { + "deviceClassId": "753f0d32-0468-4d08-82ed-1964aab03298", + "name": "Mock Device", + "createMethods": ["user", "auto", "discovery"], + "discoveryParamTypes": [ + { + "name": "resultCount", + "type": "int", + "defaultValue": 2, + "allowedValues": [1, 2] + } + ], + "paramTypes": [ + { + "name": "httpport", + "type": "int" + }, + { + "name": "async", + "type": "bool", + "defaultValue": false + }, + { + "name": "broken", + "type": "bool", + "defaultValue": false + } + ], + "stateTypes": [ + { + "id": "80baec19-54de-4948-ac46-31eabfaceb83", + "name": "Dummy int state", + "defaultValue": 10 + }, + { + "id": "9dd6a97c-dfd1-43dc-acbd-367932742310", + "name:": "Dummy boo state", + "defaultValue": "false" + } + ], + "eventTypes": [ + { + "id": "45bf3752-0fc6-46b9-89fd-ffd878b5b22b", + "name": "Mock Event 1" + }, + { + "id": "863d5920-b1cf-4eb9-88bd-8f7b8583b1cf", + "name": "Mock Event 2", + "paramTypes": [ + { + "name": "mockParamInt", + "type": "int", + "defaultValue": 10 + } + ] + } + ], + "actionTypes": [ + { + "id": "dea0f4e1-65e3-4981-8eaa-2701c53a9185", + "name": "Mock Action 1 (with params)", + "paramTypes": [ + { + "name": "mockActionParam1", + "type": "int" + }, + { + "name": "mockActionParam2", + "type": "bool" + } + ] + }, + { + "id": "defd3ed6-1a0d-400b-8879-a0202cf39935", + "name": "Mock Action 2 (without params)" + }, + { + "id": "fbae06d3-7666-483e-a39e-ec50fe89054e", + "name": "Mock Action 3 (async)" + }, + { + "id": "df3cf33d-26d5-4577-9132-9823bd33fad0", + "name": "Mock Action 4 (broken)" + }, + { + "id": "bfe89a1d-3497-4121-8318-e77c37537219", + "name": "Mock Action 5 (async, broken)" + } + ] + } + ] } - ] } diff --git a/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.json b/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.json index 6a0de742..aac6f81d 100644 --- a/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.json +++ b/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.json @@ -4,8 +4,113 @@ "vendors": [ { "name": "Openweathermap", - "id": "bf1e96f0-9650-4e7c-a56c-916d54d18e7a" + "id": "bf1e96f0-9650-4e7c-a56c-916d54d18e7a", + "deviceClasses": [ + { + "deviceClassId": "985195aa-17ad-4530-88a4-cdd753d747d7", + "name": "Weather from openweathermap", + "createMethods": ["discovery"], + "discoveryParamTypes": [ + { + "name": "location", + "type": "string" + } + ], + "paramTypes": [ + { + "name": "location", + "type": "string" + }, + { + "name": "country", + "type": "string" + }, + { + "name": "id", + "type": "string" + } + ], + "actionTypes": [ + { + "id": "cfbc6504-d86f-4856-8dfa-97b6fbb385e4", + "name": "Update" + } + ], + "stateTypes": [ + { + "id": "36b2f09b-7d77-4fbc-a68f-23d735dda0b1", + "name": "last update [unixtime]", + "type": "uint", + "defaultValue": "0" + }, + { + "id": "6013402f-b5b1-46b3-8490-f0c20d62fe61", + "name": "temperature [Celsius]", + "type": "double", + "defaultValue": "0" + }, + { + "id": "14ec2781-cb04-4bbf-b097-7d01ef982630", + "name": "temperature minimum [Celsius]", + "type": "double", + "defaultValue": "0" + }, + { + "id": "fefe5563-452f-4833-b5cf-49c3cc67c772", + "name": "temperature maximum [Celsius]", + "type": "double", + "defaultValue": "0" + }, + { + "id": "6f32ec73-3240-4630-ada9-1c10b8e98123", + "name": "humidity [%]", + "type": "int", + "defaultValue": "-1" + }, + { + "id": "4a42eea9-00eb-440b-915e-dbe42180f83b", + "name": "pressure [hPa]", + "type": "double", + "defaultValue": "0" + }, + { + "id": "2bf63430-e9e2-4fbf-88e6-6f1b4770f287", + "name": "wind speed [m/s]", + "type": "double", + "defaultValue": "0" + }, + { + "id": "589e2ea5-65b2-4afd-9b72-e3708a589a12", + "name": "wind direction [degree]", + "type": "int", + "defaultValue": "0" + }, + { + "id": "798553bc-45c7-42eb-9105-430bddb5d9b7", + "name": "cloudiness [%]", + "type": "int", + "defaultValue": "0" + }, + { + "id": "f9539108-0e0e-4736-a306-6408f8e20a26", + "name": "weather description", + "type": "QString" + }, + { + "id": "af155e94-9492-44e1-8608-7d0ee8b5d50d", + "name": "sunset [timestamp]", + "type": "uint", + "defaultValue": "0" + }, + { + "id": "a1dddc3d-549f-4f20-b78b-be850548f286", + "name": "sunrise [unixtime]", + "type": "int", + "defaultValue": "0" + } + ] + } + ] } - ] } diff --git a/plugins/deviceplugins/philipshue/devicepluginphilipshue.cpp b/plugins/deviceplugins/philipshue/devicepluginphilipshue.cpp index e86d4ab8..b1eeffd3 100644 --- a/plugins/deviceplugins/philipshue/devicepluginphilipshue.cpp +++ b/plugins/deviceplugins/philipshue/devicepluginphilipshue.cpp @@ -52,76 +52,6 @@ DevicePluginPhilipsHue::DevicePluginPhilipsHue(): connect(m_bridge, &HueBridgeConnection::getFinished, this, &DevicePluginPhilipsHue::getFinished); } -//QList DevicePluginPhilipsHue::supportedDevices() const -//{ -// QList ret; - - -// QList hueStates; - -// StateType powerState(huePowerStateTypeId); -// powerState.setName("power"); -// powerState.setType(QVariant::Bool); -// powerState.setDefaultValue(false); -// hueStates.append(powerState); - -// StateType brightnessState(hueBrightnessStateTypeId); -// brightnessState.setName("brightness"); -// brightnessState.setType(QVariant::Int); -// brightnessState.setDefaultValue(255); -// hueStates.append(brightnessState); - -// deviceClassHue.setStateTypes(hueStates); - -// QList hueActons; - -// ActionType setColorAction(hueSetColorActionTypeId); -// setColorAction.setName("Set color"); -// QList actionParamsSetColor; -// ParamType actionParamSetColor("color", QVariant::Color); -// actionParamsSetColor.append(actionParamSetColor); -// setColorAction.setParameters(actionParamsSetColor); -// hueActons.append(setColorAction); - -// ActionType setPowerAction(hueSetPowerActionTypeId); -// setPowerAction.setName("Power"); -// QList actionParamsSetPower; -// ParamType actionParamSetPower("power", QVariant::Bool); -// actionParamsSetPower.append(actionParamSetPower); -// setPowerAction.setParameters(actionParamsSetPower); -// hueActons.append(setPowerAction); - -// ActionType setBrightnessAction(hueSetBrightnessActionTypeId); -// setBrightnessAction.setName("Brightness"); -// QList actionParamsSetBrightness; -// ParamType actionParamSetBrightness("brightness", QVariant::Int); -// actionParamSetBrightness.setMinValue(0); -// actionParamSetBrightness.setMaxValue(255); -// actionParamsSetBrightness.append(actionParamSetBrightness); -// setBrightnessAction.setParameters(actionParamsSetBrightness); -// hueActons.append(setBrightnessAction); - -// deviceClassHue.setActions(hueActons); - -// ret.append(deviceClassHue); - -// // Now create the same device again with CreateMethodAuto -// // When we pair a bridge, one discovered device is created. -// // The other light bulbs connected to the bridge will -// // then appear as auto devices. -// DeviceClass deviceClassHueAuto(pluginId(), hueVendorId, hueDeviceClassAutoId); -// deviceClassHueAuto.setName("Hue"); -// deviceClassHueAuto.setCreateMethod(DeviceClass::CreateMethodAuto); -// deviceClassHueAuto.setParamTypes(paramTypes); -// deviceClassHueAuto.setStateTypes(hueStates); -// deviceClassHueAuto.setActions(hueActons); - -// ret.append(deviceClassHueAuto); - - -// return ret; -//} - DeviceManager::HardwareResources DevicePluginPhilipsHue::requiredHardware() const { return DeviceManager::HardwareResourceTimer; diff --git a/plugins/deviceplugins/philipshue/devicepluginphilipshue.json b/plugins/deviceplugins/philipshue/devicepluginphilipshue.json index 8eee3438..91cb3684 100644 --- a/plugins/deviceplugins/philipshue/devicepluginphilipshue.json +++ b/plugins/deviceplugins/philipshue/devicepluginphilipshue.json @@ -9,7 +9,7 @@ { "deviceClassId": "d8f4c397-e05e-47c1-8917-8e72d4d0d47c", "name": "Hue", - "createMethod": "discovery", + "createMethods": ["discovery", "auto"], "setupMethod": "pushButton", "pairingInfo": "Please press the button on the Hue bridge and then press OK", "paramTypes": [ @@ -38,6 +38,38 @@ "type": "color", "defaultValue": "black" } + ], + "actionTypes": [ + { + "id": "29cc299a-818b-47b2-817f-c5a6361545e4", + "name": "Set color", + "paramTypes": [ + { + "name": "color", + "type": "QColor" + } + ] + }, + { + "id": "7782d91e-d73a-4321-8828-da768e2f6827", + "name": "Set power", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + }, + { + "id": "3bc95552-cba0-4222-abd5-9b668132e442", + "name": "Set brightness", + "paramTypes": [ + { + "name": "brightness", + "type": "int" + } + ] + } ] } ] diff --git a/plugins/deviceplugins/wakeonlan/devicepluginwakeonlan.json b/plugins/deviceplugins/wakeonlan/devicepluginwakeonlan.json index a4a1450a..330c919f 100644 --- a/plugins/deviceplugins/wakeonlan/devicepluginwakeonlan.json +++ b/plugins/deviceplugins/wakeonlan/devicepluginwakeonlan.json @@ -4,8 +4,30 @@ "vendors": [ { "name": "guh", - "id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6" + "id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6", + "deviceClasses": [ + { + "deviceClassId": "3c8f2447-dcd0-4882-8c09-99e579e4d24c", + "name": "Wake On Lan", + "createMethods": ["user"], + "paramTypes": [ + { + "name": "name", + "type": "QString" + }, + { + "name": "MAC", + "type": "QString" + } + ], + "actionTypes": [ + { + "id": "fb9b9d87-218f-4f0d-9e16-39f8a105029a", + "name": "Wake up device" + } + ] + } + ] } - ] } diff --git a/plugins/deviceplugins/wifidetector/devicepluginwifidetector.cpp b/plugins/deviceplugins/wifidetector/devicepluginwifidetector.cpp index c0de22af..d64c7c2e 100644 --- a/plugins/deviceplugins/wifidetector/devicepluginwifidetector.cpp +++ b/plugins/deviceplugins/wifidetector/devicepluginwifidetector.cpp @@ -31,34 +31,6 @@ DevicePluginWifiDetector::DevicePluginWifiDetector() { } -//QList DevicePluginWifiDetector::supportedDevices() const -//{ -// QList ret; - -// DeviceClass deviceClassWifiDetector(pluginId(), supportedVendors().first().id(), detectorId); -// deviceClassWifiDetector.setName("WiFi Device"); - -// QList detectorParams; -// ParamType macParam("mac", QVariant::String); -// detectorParams.append(macParam); - -// deviceClassWifiDetector.setParamTypes(detectorParams); - -// QList detectorStates; - -// StateType inRangeState(inRangeStateTypeId); -// inRangeState.setName("inRange"); -// inRangeState.setType(QVariant::Bool); -// inRangeState.setDefaultValue(false); -// detectorStates.append(inRangeState); - -// deviceClassWifiDetector.setStateTypes(detectorStates); - -// ret.append(deviceClassWifiDetector); - -// return ret; -//} - DeviceManager::HardwareResources DevicePluginWifiDetector::requiredHardware() const { return DeviceManager::HardwareResourceTimer; diff --git a/plugins/deviceplugins/wifidetector/devicepluginwifidetector.json b/plugins/deviceplugins/wifidetector/devicepluginwifidetector.json index 53a375a7..b10c60d8 100644 --- a/plugins/deviceplugins/wifidetector/devicepluginwifidetector.json +++ b/plugins/deviceplugins/wifidetector/devicepluginwifidetector.json @@ -4,7 +4,29 @@ "vendors": [ { "name": "guh", - "id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6" + "id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6", + "deviceClasses": [ + { + "deviceClassId": "bd216356-f1ec-4324-9785-6982d2174e17", + "name": "WiFi Device", + "createMethods": ["user"], + "paramTypes": [ + { + "name": "MAC", + "type": "QString" + } + ], + "stateTypes": [ + { + "id": "cb43e1b5-4f61-4538-bfa2-c33055c542cf", + "name": "In Range", + "type": "bool", + "defaultValue": false + } + ] + } + + ] } ]