diff --git a/genericthings/integrationplugingenericthings.cpp b/genericthings/integrationplugingenericthings.cpp index adbe0811..eac714b0 100644 --- a/genericthings/integrationplugingenericthings.cpp +++ b/genericthings/integrationplugingenericthings.cpp @@ -574,6 +574,21 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info) } else { Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8()); } + } else if (thing->thingClassId() == lightSensorThingClassId) { + if (action.actionTypeId() == lightSensorInputActionTypeId) { + double value = info->action().param(lightSensorInputActionInputParamTypeId).value().toDouble(); + thing->setStateValue(lightSensorInputStateTypeId, value); + double min = info->thing()->setting(lightSensorSettingsMinLuxParamTypeId).toDouble(); + double max = info->thing()->setting(lightSensorSettingsMaxLuxParamTypeId).toDouble(); + double newValue = mapDoubleValue(value, 0, 100, min, max); + double roundingFactor = qPow(10, info->thing()->setting(lightSensorSettingsAccuracyParamTypeId).toInt()); + newValue = qRound(newValue * roundingFactor) / roundingFactor; + thing->setStateValue(lightSensorLightIntensityStateTypeId, newValue); + info->finish(Thing::ThingErrorNoError); + return; + } else { + Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8()); + } } else if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) { if (action.actionTypeId() == extendedSmartMeterConsumerImpulseInputActionTypeId) { bool value = info->action().param(extendedSmartMeterConsumerImpulseInputActionImpulseInputParamTypeId).value().toBool(); diff --git a/genericthings/integrationplugingenericthings.json b/genericthings/integrationplugingenericthings.json index 500c9522..f649e1a2 100644 --- a/genericthings/integrationplugingenericthings.json +++ b/genericthings/integrationplugingenericthings.json @@ -972,6 +972,65 @@ } ] }, + { + "id": "d4d873fd-f0fc-433f-b615-91c1506a1890", + "name": "lightSensor", + "displayName": "Generic light sensor", + "createMethods": ["user"], + "interfaces": ["lightsensor"], + "settingsTypes": [ + { + "id": "6dea7384-b079-443b-8cc2-1479138fa212", + "name": "minLux", + "displayName": "Minimum Lux", + "type": "double", + "defaultValue": 0, + "unit": "Lux" + }, + { + "id": "7fe74404-d7f0-41af-a8d4-dd1bda27f752", + "name": "maxLux", + "displayName": "Maximum Lux", + "type": "double", + "defaultValue": 120000, + "unit": "Lux" + }, + { + "id": "f800988f-1ad5-4ffb-9aa8-70ef17614966", + "name": "accuracy", + "displayName": "Accuracy (decimal places)", + "type": "uint", + "minValue": 0, + "maxValue": 5, + "defaultValue": 1 + } + ], + "stateTypes": [ + { + "id": "fe12ef32-9f2f-41cd-acb7-6b8e4acffa3b", + "name": "lightIntensity", + "displayName": "Light intensity", + "displayNameEvent": "Light intensity changed", + "type": "double", + "unit": "Lux", + "defaultValue": 0 + }, + { + "id": "520e5d27-7d15-4d79-94cf-5d01f5a09ea8", + "name": "input", + "displayName": "Input value", + "displayNameEvent": "Input value changed", + "displayNameAction": "Set input value", + "type": "double", + "defaultValue": 0, + "minValue": 0, + "maxValue": 100, + "unit": "Percentage", + "writable": true, + "ioType": "analogOutput" + } + ] + }, { "id": "c3123967-f741-4fe1-a0d4-9a3e405d7e52", "name": "extendedSmartMeterConsumer", diff --git a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts index a552310b..d311860c 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts @@ -5,7 +5,9 @@ GenericThings Accuracy (decimal places) - The name of the ParamType (ThingClass: co2Sensor, Type: settings, ID: {236831a8-a455-4e38-a9cd-eabbebaa3f67}) + The name of the ParamType (ThingClass: lightSensor, Type: settings, ID: {f800988f-1ad5-4ffb-9aa8-70ef17614966}) +---------- +The name of the ParamType (ThingClass: co2Sensor, Type: settings, ID: {236831a8-a455-4e38-a9cd-eabbebaa3f67}) ---------- The name of the ParamType (ThingClass: pressureSensor, Type: settings, ID: {021a17d8-9e5e-4dd6-835d-1a3e1ffd6b23}) ---------- @@ -184,7 +186,13 @@ The name of the StateType ({925225d9-2965-444a-9c42-63c2873700fb}) of ThingClass Input value - The name of the ParamType (ThingClass: co2Sensor, ActionType: input, ID: {7dc765f8-fa9b-4199-8f21-49ed452f226d}) + The name of the ParamType (ThingClass: lightSensor, ActionType: input, ID: {520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) +---------- +The name of the ParamType (ThingClass: lightSensor, EventType: input, ID: {520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) +---------- +The name of the StateType ({520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) of ThingClass lightSensor +---------- +The name of the ParamType (ThingClass: co2Sensor, ActionType: input, ID: {7dc765f8-fa9b-4199-8f21-49ed452f226d}) ---------- The name of the ParamType (ThingClass: co2Sensor, EventType: input, ID: {7dc765f8-fa9b-4199-8f21-49ed452f226d}) ---------- @@ -217,7 +225,9 @@ The name of the StateType ({fed37466-1264-4ac1-84fd-aff3a1f7ff04}) of ThingClass Input value changed - The name of the EventType ({7dc765f8-fa9b-4199-8f21-49ed452f226d}) of ThingClass co2Sensor + The name of the EventType ({520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) of ThingClass lightSensor +---------- +The name of the EventType ({7dc765f8-fa9b-4199-8f21-49ed452f226d}) of ThingClass co2Sensor ---------- The name of the EventType ({c320577c-371a-442b-ac80-b692ff2064c9}) of ThingClass pressureSensor ---------- @@ -463,7 +473,9 @@ The name of the ActionType ({59bfd575-709f-4e43-9726-de26e6d4ca8b}) of ThingClas Set input value - The name of the ActionType ({7dc765f8-fa9b-4199-8f21-49ed452f226d}) of ThingClass co2Sensor + The name of the ActionType ({520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) of ThingClass lightSensor +---------- +The name of the ActionType ({7dc765f8-fa9b-4199-8f21-49ed452f226d}) of ThingClass co2Sensor ---------- The name of the ActionType ({c320577c-371a-442b-ac80-b692ff2064c9}) of ThingClass pressureSensor ---------- @@ -959,6 +971,33 @@ The name of the StateType ({7f5fdc2b-7916-4e90-9c24-558162304f71}) of ThingClass The name of the ActionType ({7f5fdc2b-7916-4e90-9c24-558162304f71}) of ThingClass doorSensor + + Generic light sensor + The name of the ThingClass ({d4d873fd-f0fc-433f-b615-91c1506a1890}) + + + + Light intensity + The name of the ParamType (ThingClass: lightSensor, EventType: lightIntensity, ID: {fe12ef32-9f2f-41cd-acb7-6b8e4acffa3b}) +---------- +The name of the StateType ({fe12ef32-9f2f-41cd-acb7-6b8e4acffa3b}) of ThingClass lightSensor + + + + Light intensity changed + The name of the EventType ({fe12ef32-9f2f-41cd-acb7-6b8e4acffa3b}) of ThingClass lightSensor + + + + Maximum Lux + The name of the ParamType (ThingClass: lightSensor, Type: settings, ID: {7fe74404-d7f0-41af-a8d4-dd1bda27f752}) + + + + Minimum Lux + The name of the ParamType (ThingClass: lightSensor, Type: settings, ID: {6dea7384-b079-443b-8cc2-1479138fa212}) + + 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 9e50e748..309a01f6 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts @@ -5,7 +5,9 @@ GenericThings Accuracy (decimal places) - The name of the ParamType (ThingClass: co2Sensor, Type: settings, ID: {236831a8-a455-4e38-a9cd-eabbebaa3f67}) + The name of the ParamType (ThingClass: lightSensor, Type: settings, ID: {f800988f-1ad5-4ffb-9aa8-70ef17614966}) +---------- +The name of the ParamType (ThingClass: co2Sensor, Type: settings, ID: {236831a8-a455-4e38-a9cd-eabbebaa3f67}) ---------- The name of the ParamType (ThingClass: pressureSensor, Type: settings, ID: {021a17d8-9e5e-4dd6-835d-1a3e1ffd6b23}) ---------- @@ -184,7 +186,13 @@ The name of the StateType ({925225d9-2965-444a-9c42-63c2873700fb}) of ThingClass Input value - The name of the ParamType (ThingClass: co2Sensor, ActionType: input, ID: {7dc765f8-fa9b-4199-8f21-49ed452f226d}) + The name of the ParamType (ThingClass: lightSensor, ActionType: input, ID: {520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) +---------- +The name of the ParamType (ThingClass: lightSensor, EventType: input, ID: {520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) +---------- +The name of the StateType ({520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) of ThingClass lightSensor +---------- +The name of the ParamType (ThingClass: co2Sensor, ActionType: input, ID: {7dc765f8-fa9b-4199-8f21-49ed452f226d}) ---------- The name of the ParamType (ThingClass: co2Sensor, EventType: input, ID: {7dc765f8-fa9b-4199-8f21-49ed452f226d}) ---------- @@ -217,7 +225,9 @@ The name of the StateType ({fed37466-1264-4ac1-84fd-aff3a1f7ff04}) of ThingClass Input value changed - The name of the EventType ({7dc765f8-fa9b-4199-8f21-49ed452f226d}) of ThingClass co2Sensor + The name of the EventType ({520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) of ThingClass lightSensor +---------- +The name of the EventType ({7dc765f8-fa9b-4199-8f21-49ed452f226d}) of ThingClass co2Sensor ---------- The name of the EventType ({c320577c-371a-442b-ac80-b692ff2064c9}) of ThingClass pressureSensor ---------- @@ -463,7 +473,9 @@ The name of the ActionType ({59bfd575-709f-4e43-9726-de26e6d4ca8b}) of ThingClas Set input value - The name of the ActionType ({7dc765f8-fa9b-4199-8f21-49ed452f226d}) of ThingClass co2Sensor + The name of the ActionType ({520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) of ThingClass lightSensor +---------- +The name of the ActionType ({7dc765f8-fa9b-4199-8f21-49ed452f226d}) of ThingClass co2Sensor ---------- The name of the ActionType ({c320577c-371a-442b-ac80-b692ff2064c9}) of ThingClass pressureSensor ---------- @@ -959,6 +971,33 @@ The name of the StateType ({7f5fdc2b-7916-4e90-9c24-558162304f71}) of ThingClass The name of the ActionType ({7f5fdc2b-7916-4e90-9c24-558162304f71}) of ThingClass doorSensor + + Generic light sensor + The name of the ThingClass ({d4d873fd-f0fc-433f-b615-91c1506a1890}) + + + + Light intensity + The name of the ParamType (ThingClass: lightSensor, EventType: lightIntensity, ID: {fe12ef32-9f2f-41cd-acb7-6b8e4acffa3b}) +---------- +The name of the StateType ({fe12ef32-9f2f-41cd-acb7-6b8e4acffa3b}) of ThingClass lightSensor + + + + Light intensity changed + The name of the EventType ({fe12ef32-9f2f-41cd-acb7-6b8e4acffa3b}) of ThingClass lightSensor + + + + Maximum Lux + The name of the ParamType (ThingClass: lightSensor, Type: settings, ID: {7fe74404-d7f0-41af-a8d4-dd1bda27f752}) + + + + Minimum Lux + The name of the ParamType (ThingClass: lightSensor, Type: settings, ID: {6dea7384-b079-443b-8cc2-1479138fa212}) + + IntegrationPluginGenericThings