From 794f4eb9bd3bb2c589c3a7d455641ec9725801dc Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 11 May 2021 13:04:46 +0200 Subject: [PATCH] GenericThings: Add a totally generic thing --- .../integrationplugingenericthings.cpp | 28 +++++ .../integrationplugingenericthings.json | 66 ++++++++++++ ...b3188696-2585-4806-bf98-30ab576ce5c8-de.ts | 100 ++++++++++++++++++ ...88696-2585-4806-bf98-30ab576ce5c8-en_US.ts | 100 ++++++++++++++++++ 4 files changed, 294 insertions(+) diff --git a/genericthings/integrationplugingenericthings.cpp b/genericthings/integrationplugingenericthings.cpp index bd6cbc5..fa1dc59 100644 --- a/genericthings/integrationplugingenericthings.cpp +++ b/genericthings/integrationplugingenericthings.cpp @@ -274,6 +274,34 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info) Thing *thing = info->thing(); Action action = info->action(); + if (thing->thingClassId() == genericThingClassId) { + if (action.actionTypeId() == genericAnalogInputActionTypeId) { + thing->setStateValue(genericAnalogInputStateTypeId, action.paramValue(genericAnalogInputActionAnalogInputParamTypeId)); + info->finish(Thing::ThingErrorNoError); + return; + } + if (action.actionTypeId() == genericAnalogOutputActionTypeId) { + thing->setStateValue(genericAnalogOutputStateTypeId, action.paramValue(genericAnalogOutputActionAnalogOutputParamTypeId)); + info->finish(Thing::ThingErrorNoError); + return; + } + if (action.actionTypeId() == genericDigitalInputActionTypeId) { + thing->setStateValue(genericDigitalInputStateTypeId, action.paramValue(genericDigitalInputActionDigitalInputParamTypeId)); + info->finish(Thing::ThingErrorNoError); + return; + } + if (action.actionTypeId() == genericDigitalOutputActionTypeId) { + thing->setStateValue(genericDigitalOutputStateTypeId, action.paramValue(genericDigitalOutputActionDigitalOutputParamTypeId)); + info->finish(Thing::ThingErrorNoError); + return; + } + if (action.actionTypeId() == genericStringStateActionTypeId) { + thing->setStateValue(genericStringStateStateTypeId, action.paramValue(genericStringStateActionStringStateParamTypeId)); + info->finish(Thing::ThingErrorNoError); + return; + } + } + if (thing->thingClassId() == awningThingClassId) { if (action.actionTypeId() == awningOpenActionTypeId) { thing->setStateValue(awningStatusStateTypeId, "Opening"); diff --git a/genericthings/integrationplugingenericthings.json b/genericthings/integrationplugingenericthings.json index 6313642..816233c 100644 --- a/genericthings/integrationplugingenericthings.json +++ b/genericthings/integrationplugingenericthings.json @@ -8,6 +8,72 @@ "displayName": "nymea", "id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6", "thingClasses": [ + { + "id": "f5c02d35-b06e-4950-8238-847d50cabfdf", + "name": "generic", + "displayName": "Generic thing", + "createMethods": ["user"], + "stateTypes": [ + { + "id": "f477e227-0d2d-4d88-a545-7dedf36266d5", + "name": "stringState", + "displayName": "String state", + "displayNameEvent": "String state changed", + "displayNameAction": "Set string state", + "type": "QString", + "defaultValue": "", + "writable": true + }, + { + "id": "3cf5eb01-dae8-49cd-8c5f-b0224be0044f", + "name": "digitalInput", + "displayName": "Digital input", + "displayNameEvent": "Digital input changed", + "displayNameAction": "Set digital input", + "type": "bool", + "defaultValue": false, + "writable": true, + "ioType": "digitalInput" + }, + { + "id": "605b4d8e-71a7-441e-900a-e07c305acd93", + "name": "digitalOutput", + "displayName": "Digital output", + "displayNameEvent": "Digital output changed", + "displayNameAction": "Set digital output", + "type": "bool", + "defaultValue": false, + "writable": true, + "ioType": "digitalOutput" + }, + { + "id": "810fcd3c-7854-4bb1-82f6-1403ba54875e", + "name": "analogInput", + "displayName": "Analog input", + "displayNameEvent": "Analog input changed", + "displayNameAction": "Set analog input", + "type": "double", + "defaultValue": 0, + "minValue": 0, + "maxValue": 1, + "ioType": "analogInput", + "writable": true + }, + { + "id": "de8ec1b1-8026-4fd8-aefb-dedc07616aa4", + "name": "analogOutput", + "displayName": "Analog output", + "displayNameEvent": "Analog output changed", + "displayNameAction": "Set analog output", + "type": "double", + "defaultValue": 0, + "minValue": 0, + "maxValue": 1, + "ioType": "analogOutput", + "writable": true + } + ] + }, { "id": "9e69585f-90ba-44e4-ad90-5b4bffbe345a", "name": "awning", diff --git a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts index daa6d62..fd83d11 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts @@ -1153,6 +1153,106 @@ The name of the StateType ({a61c0328-b982-46a5-9cc0-b4fa4d0ab84d}) of ThingClass The name of the ActionType ({a61c0328-b982-46a5-9cc0-b4fa4d0ab84d}) of ThingClass battery Setze Laden + + Analog input + The name of the ParamType (ThingClass: generic, ActionType: analogInput, ID: {810fcd3c-7854-4bb1-82f6-1403ba54875e}) +---------- +The name of the ParamType (ThingClass: generic, EventType: analogInput, ID: {810fcd3c-7854-4bb1-82f6-1403ba54875e}) +---------- +The name of the StateType ({810fcd3c-7854-4bb1-82f6-1403ba54875e}) of ThingClass generic + Analoger Eingang + + + Analog input changed + The name of the EventType ({810fcd3c-7854-4bb1-82f6-1403ba54875e}) of ThingClass generic + Analoger Eingang geändert + + + Analog output + The name of the ParamType (ThingClass: generic, ActionType: analogOutput, ID: {de8ec1b1-8026-4fd8-aefb-dedc07616aa4}) +---------- +The name of the ParamType (ThingClass: generic, EventType: analogOutput, ID: {de8ec1b1-8026-4fd8-aefb-dedc07616aa4}) +---------- +The name of the StateType ({de8ec1b1-8026-4fd8-aefb-dedc07616aa4}) of ThingClass generic + Analoger Ausgang + + + Analog output changed + The name of the EventType ({de8ec1b1-8026-4fd8-aefb-dedc07616aa4}) of ThingClass generic + Analoger Ausgang geändret + + + Digital input + The name of the ParamType (ThingClass: generic, ActionType: digitalInput, ID: {3cf5eb01-dae8-49cd-8c5f-b0224be0044f}) +---------- +The name of the ParamType (ThingClass: generic, EventType: digitalInput, ID: {3cf5eb01-dae8-49cd-8c5f-b0224be0044f}) +---------- +The name of the StateType ({3cf5eb01-dae8-49cd-8c5f-b0224be0044f}) of ThingClass generic + Digitaler Eingang + + + Digital input changed + The name of the EventType ({3cf5eb01-dae8-49cd-8c5f-b0224be0044f}) of ThingClass generic + Digitaler Eingang geändert + + + Digital output + The name of the ParamType (ThingClass: generic, ActionType: digitalOutput, ID: {605b4d8e-71a7-441e-900a-e07c305acd93}) +---------- +The name of the ParamType (ThingClass: generic, EventType: digitalOutput, ID: {605b4d8e-71a7-441e-900a-e07c305acd93}) +---------- +The name of the StateType ({605b4d8e-71a7-441e-900a-e07c305acd93}) of ThingClass generic + Digitaler Ausgang + + + Digital output changed + The name of the EventType ({605b4d8e-71a7-441e-900a-e07c305acd93}) of ThingClass generic + Digitaler Ausgang geändert + + + Generic thing + The name of the ThingClass ({f5c02d35-b06e-4950-8238-847d50cabfdf}) + Generisches "Thing" + + + Set analog input + The name of the ActionType ({810fcd3c-7854-4bb1-82f6-1403ba54875e}) of ThingClass generic + Setze Analogen Eingang + + + Set analog output + The name of the ActionType ({de8ec1b1-8026-4fd8-aefb-dedc07616aa4}) of ThingClass generic + Setze analogen Ausgang + + + Set digital input + The name of the ActionType ({3cf5eb01-dae8-49cd-8c5f-b0224be0044f}) of ThingClass generic + Setze digitalen Eingang + + + Set digital output + The name of the ActionType ({605b4d8e-71a7-441e-900a-e07c305acd93}) of ThingClass generic + Setze digitalen Ausgang + + + Set string state + The name of the ActionType ({f477e227-0d2d-4d88-a545-7dedf36266d5}) of ThingClass generic + Setze Zeichenkette + + + String state + The name of the ParamType (ThingClass: generic, ActionType: stringState, ID: {f477e227-0d2d-4d88-a545-7dedf36266d5}) +---------- +The name of the ParamType (ThingClass: generic, EventType: stringState, ID: {f477e227-0d2d-4d88-a545-7dedf36266d5}) +---------- +The name of the StateType ({f477e227-0d2d-4d88-a545-7dedf36266d5}) of ThingClass generic + Zeichenkette + + + String state changed + The name of the EventType ({f477e227-0d2d-4d88-a545-7dedf36266d5}) of ThingClass generic + Zeichenkette geändert + IntegrationPluginGenericThings diff --git a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts index ea50a69..e35e1ad 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts @@ -1153,6 +1153,106 @@ The name of the StateType ({a61c0328-b982-46a5-9cc0-b4fa4d0ab84d}) of ThingClass The name of the ActionType ({a61c0328-b982-46a5-9cc0-b4fa4d0ab84d}) of ThingClass battery + + Analog input + The name of the ParamType (ThingClass: generic, ActionType: analogInput, ID: {810fcd3c-7854-4bb1-82f6-1403ba54875e}) +---------- +The name of the ParamType (ThingClass: generic, EventType: analogInput, ID: {810fcd3c-7854-4bb1-82f6-1403ba54875e}) +---------- +The name of the StateType ({810fcd3c-7854-4bb1-82f6-1403ba54875e}) of ThingClass generic + + + + Analog input changed + The name of the EventType ({810fcd3c-7854-4bb1-82f6-1403ba54875e}) of ThingClass generic + + + + Analog output + The name of the ParamType (ThingClass: generic, ActionType: analogOutput, ID: {de8ec1b1-8026-4fd8-aefb-dedc07616aa4}) +---------- +The name of the ParamType (ThingClass: generic, EventType: analogOutput, ID: {de8ec1b1-8026-4fd8-aefb-dedc07616aa4}) +---------- +The name of the StateType ({de8ec1b1-8026-4fd8-aefb-dedc07616aa4}) of ThingClass generic + + + + Analog output changed + The name of the EventType ({de8ec1b1-8026-4fd8-aefb-dedc07616aa4}) of ThingClass generic + + + + Digital input + The name of the ParamType (ThingClass: generic, ActionType: digitalInput, ID: {3cf5eb01-dae8-49cd-8c5f-b0224be0044f}) +---------- +The name of the ParamType (ThingClass: generic, EventType: digitalInput, ID: {3cf5eb01-dae8-49cd-8c5f-b0224be0044f}) +---------- +The name of the StateType ({3cf5eb01-dae8-49cd-8c5f-b0224be0044f}) of ThingClass generic + + + + Digital input changed + The name of the EventType ({3cf5eb01-dae8-49cd-8c5f-b0224be0044f}) of ThingClass generic + + + + Digital output + The name of the ParamType (ThingClass: generic, ActionType: digitalOutput, ID: {605b4d8e-71a7-441e-900a-e07c305acd93}) +---------- +The name of the ParamType (ThingClass: generic, EventType: digitalOutput, ID: {605b4d8e-71a7-441e-900a-e07c305acd93}) +---------- +The name of the StateType ({605b4d8e-71a7-441e-900a-e07c305acd93}) of ThingClass generic + + + + Digital output changed + The name of the EventType ({605b4d8e-71a7-441e-900a-e07c305acd93}) of ThingClass generic + + + + Generic thing + The name of the ThingClass ({f5c02d35-b06e-4950-8238-847d50cabfdf}) + + + + Set analog input + The name of the ActionType ({810fcd3c-7854-4bb1-82f6-1403ba54875e}) of ThingClass generic + + + + Set analog output + The name of the ActionType ({de8ec1b1-8026-4fd8-aefb-dedc07616aa4}) of ThingClass generic + + + + Set digital input + The name of the ActionType ({3cf5eb01-dae8-49cd-8c5f-b0224be0044f}) of ThingClass generic + + + + Set digital output + The name of the ActionType ({605b4d8e-71a7-441e-900a-e07c305acd93}) of ThingClass generic + + + + Set string state + The name of the ActionType ({f477e227-0d2d-4d88-a545-7dedf36266d5}) of ThingClass generic + + + + String state + The name of the ParamType (ThingClass: generic, ActionType: stringState, ID: {f477e227-0d2d-4d88-a545-7dedf36266d5}) +---------- +The name of the ParamType (ThingClass: generic, EventType: stringState, ID: {f477e227-0d2d-4d88-a545-7dedf36266d5}) +---------- +The name of the StateType ({f477e227-0d2d-4d88-a545-7dedf36266d5}) of ThingClass generic + + + + String state changed + The name of the EventType ({f477e227-0d2d-4d88-a545-7dedf36266d5}) of ThingClass generic + + IntegrationPluginGenericThings