diff --git a/genericthings/integrationplugingenericthings.cpp b/genericthings/integrationplugingenericthings.cpp
index 233c2e44..364bb67a 100644
--- a/genericthings/integrationplugingenericthings.cpp
+++ b/genericthings/integrationplugingenericthings.cpp
@@ -251,6 +251,19 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info)
thermostatCheckPowerOutputState(thing);
}
});
+ } else if (thing->thingClassId() == waterLevelSensorThingClassId) {
+ connect(thing, &Thing::settingChanged, thing, [ thing](const ParamTypeId &settingTypeId, const QVariant &value){
+ if (settingTypeId == waterLevelSensorSettingsCapacityParamTypeId) {
+ double capacity = value.toDouble();
+ double input = thing->stateValue(waterLevelSensorInputStateTypeId).toDouble();
+ double minInputValue = thing->setting(waterLevelSensorSettingsMinInputValueParamTypeId).toDouble();
+ double maxInputValue = thing->setting(waterLevelSensorSettingsMaxInputValueParamTypeId).toDouble();
+ double normalizedInput = (input - minInputValue) / (maxInputValue - minInputValue);
+ double waterLevel = normalizedInput * capacity;
+ thing->setStateMaxValue(waterLevelSensorWaterLevelStateTypeId, capacity);
+ thing->setStateValue(waterLevelSensorWaterLevelStateTypeId, waterLevel);
+ }
+ });
} else if (thing->thingClassId() == sgReadyThingClassId) {
bool relay1 = thing->stateValue(sgReadyRelay1StateTypeId).toBool();
bool relay2 = thing->stateValue(sgReadyRelay2StateTypeId).toBool();
@@ -866,6 +879,18 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info)
info->finish(Thing::ThingErrorNoError);
return;
}
+ } else if (thing->thingClassId() == waterLevelSensorThingClassId) {
+ if (action.actionTypeId() == waterLevelSensorInputActionTypeId) {
+ double capacity = thing->setting(waterLevelSensorSettingsCapacityParamTypeId).toDouble();
+ double input = action.paramValue(waterLevelSensorInputActionInputParamTypeId).toDouble();
+ double minInputValue = thing->setting(waterLevelSensorSettingsMinInputValueParamTypeId).toDouble();
+ double maxInputValue = thing->setting(waterLevelSensorSettingsMaxInputValueParamTypeId).toDouble();
+ double normalizedInput = (input - minInputValue) / (maxInputValue - minInputValue);
+ double waterLevel = normalizedInput * capacity;
+ thing->setStateValue(waterLevelSensorWaterLevelStateTypeId, waterLevel);
+ info->finish(Thing::ThingErrorNoError);
+ return;
+ }
} else if (thing->thingClassId() == presenceSensorThingClassId) {
if (action.actionTypeId() == presenceSensorIsPresentActionTypeId) {
bool isPresent = action.paramValue(presenceSensorIsPresentActionIsPresentParamTypeId).toBool();
diff --git a/genericthings/integrationplugingenericthings.json b/genericthings/integrationplugingenericthings.json
index 75ee1d70..d3cb682a 100644
--- a/genericthings/integrationplugingenericthings.json
+++ b/genericthings/integrationplugingenericthings.json
@@ -1688,6 +1688,64 @@
}
]
},
+ {
+ "id": "f1576df0-fb45-4bf0-89fa-a83c4118c326",
+ "name": "waterLevelSensor",
+ "displayName": "Generic water level sensor",
+ "createMethods": ["user"],
+ "interfaces": ["waterlevelsensor"],
+ "settingsTypes": [
+ {
+ "id": "5e98e8d2-d849-46c5-b25a-d54f184ea4c7",
+ "name": "capacity",
+ "displayName": "Tank capactity",
+ "type": "double",
+ "unit": "Liter",
+ "minValue": 0,
+ "defaultValue": 100
+ },
+ {
+ "id": "16ea3cf2-46fd-40a3-88bf-21a2bb7cbabe",
+ "name": "minInputValue",
+ "displayName": "Minimum input value",
+ "type": "double",
+ "defaultValue": 0
+ },
+ {
+ "id": "4e228f9b-8631-4643-8375-3d8d76d12e9c",
+ "name": "maxInputValue",
+ "displayName": "Maximum input value",
+ "type": "double",
+ "defaultValue": 1
+ }
+ ],
+ "stateTypes": [
+ {
+ "id": "07563165-e42d-4d0f-ac60-31cdd19170f2",
+ "name": "waterLevel",
+ "displayName": "Water level",
+ "displayNameEvent": "Water level changed",
+ "type": "double",
+ "unit": "Liter",
+ "defaultValue": 0,
+ "minValue": 0,
+ "maxValue": 100
+ },
+ {
+ "id": "d344887d-da5d-4742-83bd-608754b2d0aa",
+ "name": "input",
+ "displayName": "Input value",
+ "displayNameEvent": "Input value changed",
+ "displayNameAction": "Set input value",
+ "type": "double",
+ "defaultValue": 0,
+ "minValue": 0,
+ "maxValue": 1,
+ "writable": true,
+ "ioType": "analogOutput"
+ }
+ ]
+ },
{
"id": "339a0c54-4086-404f-8d36-bcf20621b785",
"name": "presenceSensor",
diff --git a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts
index e5635c0a..3c7229b7 100644
--- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts
+++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts
@@ -196,7 +196,13 @@ The name of the StateType ({925225d9-2965-444a-9c42-63c2873700fb}) of ThingClass
Input value
- The name of the ParamType (ThingClass: lightSensor, ActionType: input, ID: {520e5d27-7d15-4d79-94cf-5d01f5a09ea8})
+ The name of the ParamType (ThingClass: waterLevelSensor, ActionType: input, ID: {d344887d-da5d-4742-83bd-608754b2d0aa})
+----------
+The name of the ParamType (ThingClass: waterLevelSensor, EventType: input, ID: {d344887d-da5d-4742-83bd-608754b2d0aa})
+----------
+The name of the StateType ({d344887d-da5d-4742-83bd-608754b2d0aa}) of ThingClass waterLevelSensor
+----------
+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})
----------
@@ -265,7 +271,9 @@ The name of the StateType ({fed37466-1264-4ac1-84fd-aff3a1f7ff04}) of ThingClass
Input value changed
- The name of the EventType ({520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) of ThingClass lightSensor
+ The name of the EventType ({d344887d-da5d-4742-83bd-608754b2d0aa}) of ThingClass waterLevelSensor
+----------
+The name of the EventType ({520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) of ThingClass lightSensor
----------
The name of the EventType ({e3eb500a-ac00-426c-932a-dee4fd6fbcf5}) of ThingClass gasSensor
----------
@@ -527,7 +535,9 @@ The name of the ActionType ({59bfd575-709f-4e43-9726-de26e6d4ca8b}) of ThingClas
Set input value
- The name of the ActionType ({520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) of ThingClass lightSensor
+ The name of the ActionType ({d344887d-da5d-4742-83bd-608754b2d0aa}) of ThingClass waterLevelSensor
+----------
+The name of the ActionType ({520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) of ThingClass lightSensor
----------
The name of the ActionType ({e3eb500a-ac00-426c-932a-dee4fd6fbcf5}) of ThingClass gasSensor
----------
@@ -1421,7 +1431,9 @@ The name of the StateType ({5135648f-57b7-44b0-b9d0-c5accad09356}) of ThingClass
Maximum input value
- The name of the ParamType (ThingClass: o2Sensor, Type: settings, ID: {198847f6-a188-42b0-9e0b-15587eaabbed})
+ The name of the ParamType (ThingClass: waterLevelSensor, Type: settings, ID: {4e228f9b-8631-4643-8375-3d8d76d12e9c})
+----------
+The name of the ParamType (ThingClass: o2Sensor, Type: settings, ID: {198847f6-a188-42b0-9e0b-15587eaabbed})
----------
The name of the ParamType (ThingClass: phSensor, Type: settings, ID: {a8889e45-59e5-4cc4-b228-611f8f19f531})Maximaler Eingangswert
@@ -1438,7 +1450,9 @@ The name of the ParamType (ThingClass: phSensor, Type: settings, ID: {a8889e45-5
Minimum input value
- The name of the ParamType (ThingClass: o2Sensor, Type: settings, ID: {58e84041-d451-44a2-972e-13a79b449b58})
+ The name of the ParamType (ThingClass: waterLevelSensor, Type: settings, ID: {16ea3cf2-46fd-40a3-88bf-21a2bb7cbabe})
+----------
+The name of the ParamType (ThingClass: o2Sensor, Type: settings, ID: {58e84041-d451-44a2-972e-13a79b449b58})
----------
The name of the ParamType (ThingClass: orpSensor, Type: settings, ID: {396bf3f9-a3fc-44c3-90f8-b316670116a7})
----------
@@ -1543,6 +1557,28 @@ The name of the StateType ({363a2a39-61b6-4109-9cd9-aca7367d12c7}) of ThingClass
The name of the ThingClass ({2d936f56-48ee-4be1-9b3e-28a335ad8085})Generischer Tür- oder Fenstersensor
+
+ Generic water level sensor
+ The name of the ThingClass ({f1576df0-fb45-4bf0-89fa-a83c4118c326})
+
+
+
+ Tank capactity
+ The name of the ParamType (ThingClass: waterLevelSensor, Type: settings, ID: {5e98e8d2-d849-46c5-b25a-d54f184ea4c7})
+
+
+
+ Water level
+ The name of the ParamType (ThingClass: waterLevelSensor, EventType: waterLevel, ID: {07563165-e42d-4d0f-ac60-31cdd19170f2})
+----------
+The name of the StateType ({07563165-e42d-4d0f-ac60-31cdd19170f2}) of ThingClass waterLevelSensor
+
+
+
+ Water level changed
+ The name of the EventType ({07563165-e42d-4d0f-ac60-31cdd19170f2}) of ThingClass waterLevelSensor
+
+ 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 d20660a7..0a2046ca 100644
--- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts
+++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts
@@ -196,7 +196,13 @@ The name of the StateType ({925225d9-2965-444a-9c42-63c2873700fb}) of ThingClass
Input value
- The name of the ParamType (ThingClass: lightSensor, ActionType: input, ID: {520e5d27-7d15-4d79-94cf-5d01f5a09ea8})
+ The name of the ParamType (ThingClass: waterLevelSensor, ActionType: input, ID: {d344887d-da5d-4742-83bd-608754b2d0aa})
+----------
+The name of the ParamType (ThingClass: waterLevelSensor, EventType: input, ID: {d344887d-da5d-4742-83bd-608754b2d0aa})
+----------
+The name of the StateType ({d344887d-da5d-4742-83bd-608754b2d0aa}) of ThingClass waterLevelSensor
+----------
+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})
----------
@@ -265,7 +271,9 @@ The name of the StateType ({fed37466-1264-4ac1-84fd-aff3a1f7ff04}) of ThingClass
Input value changed
- The name of the EventType ({520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) of ThingClass lightSensor
+ The name of the EventType ({d344887d-da5d-4742-83bd-608754b2d0aa}) of ThingClass waterLevelSensor
+----------
+The name of the EventType ({520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) of ThingClass lightSensor
----------
The name of the EventType ({e3eb500a-ac00-426c-932a-dee4fd6fbcf5}) of ThingClass gasSensor
----------
@@ -527,7 +535,9 @@ The name of the ActionType ({59bfd575-709f-4e43-9726-de26e6d4ca8b}) of ThingClas
Set input value
- The name of the ActionType ({520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) of ThingClass lightSensor
+ The name of the ActionType ({d344887d-da5d-4742-83bd-608754b2d0aa}) of ThingClass waterLevelSensor
+----------
+The name of the ActionType ({520e5d27-7d15-4d79-94cf-5d01f5a09ea8}) of ThingClass lightSensor
----------
The name of the ActionType ({e3eb500a-ac00-426c-932a-dee4fd6fbcf5}) of ThingClass gasSensor
----------
@@ -1421,7 +1431,9 @@ The name of the StateType ({5135648f-57b7-44b0-b9d0-c5accad09356}) of ThingClass
Maximum input value
- The name of the ParamType (ThingClass: o2Sensor, Type: settings, ID: {198847f6-a188-42b0-9e0b-15587eaabbed})
+ The name of the ParamType (ThingClass: waterLevelSensor, Type: settings, ID: {4e228f9b-8631-4643-8375-3d8d76d12e9c})
+----------
+The name of the ParamType (ThingClass: o2Sensor, Type: settings, ID: {198847f6-a188-42b0-9e0b-15587eaabbed})
----------
The name of the ParamType (ThingClass: phSensor, Type: settings, ID: {a8889e45-59e5-4cc4-b228-611f8f19f531})
@@ -1438,7 +1450,9 @@ The name of the ParamType (ThingClass: phSensor, Type: settings, ID: {a8889e45-5
Minimum input value
- The name of the ParamType (ThingClass: o2Sensor, Type: settings, ID: {58e84041-d451-44a2-972e-13a79b449b58})
+ The name of the ParamType (ThingClass: waterLevelSensor, Type: settings, ID: {16ea3cf2-46fd-40a3-88bf-21a2bb7cbabe})
+----------
+The name of the ParamType (ThingClass: o2Sensor, Type: settings, ID: {58e84041-d451-44a2-972e-13a79b449b58})
----------
The name of the ParamType (ThingClass: orpSensor, Type: settings, ID: {396bf3f9-a3fc-44c3-90f8-b316670116a7})
----------
@@ -1543,6 +1557,28 @@ The name of the StateType ({363a2a39-61b6-4109-9cd9-aca7367d12c7}) of ThingClass
The name of the ThingClass ({2d936f56-48ee-4be1-9b3e-28a335ad8085})
+
+ Generic water level sensor
+ The name of the ThingClass ({f1576df0-fb45-4bf0-89fa-a83c4118c326})
+
+
+
+ Tank capactity
+ The name of the ParamType (ThingClass: waterLevelSensor, Type: settings, ID: {5e98e8d2-d849-46c5-b25a-d54f184ea4c7})
+
+
+
+ Water level
+ The name of the ParamType (ThingClass: waterLevelSensor, EventType: waterLevel, ID: {07563165-e42d-4d0f-ac60-31cdd19170f2})
+----------
+The name of the StateType ({07563165-e42d-4d0f-ac60-31cdd19170f2}) of ThingClass waterLevelSensor
+
+
+
+ Water level changed
+ The name of the EventType ({07563165-e42d-4d0f-ac60-31cdd19170f2}) of ThingClass waterLevelSensor
+
+ IntegrationPluginGenericThings