Generic Things: Add eneric pressure and co2 sensors
This commit is contained in:
parent
db67710185
commit
d05f21d4c7
@ -491,6 +491,36 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info)
|
||||
} else {
|
||||
Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8());
|
||||
}
|
||||
} else if (thing->thingClassId() == pressureSensorThingClassId) {
|
||||
if (action.actionTypeId() == pressureSensorInputActionTypeId) {
|
||||
double value = info->action().param(pressureSensorInputActionInputParamTypeId).value().toDouble();
|
||||
thing->setStateValue(pressureSensorInputStateTypeId, value);
|
||||
double min = info->thing()->setting(pressureSensorSettingsMinPressureParamTypeId).toDouble();
|
||||
double max = info->thing()->setting(pressureSensorSettingsMaxPressureParamTypeId).toDouble();
|
||||
double newValue = mapDoubleValue(value, 0, 100, min, max);
|
||||
double roundingFactor = qPow(10, info->thing()->setting(pressureSensorSettingsAccuracyParamTypeId).toInt());
|
||||
newValue = qRound(newValue * roundingFactor) / roundingFactor;
|
||||
thing->setStateValue(pressureSensorPressureStateTypeId, 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() == co2SensorThingClassId) {
|
||||
if (action.actionTypeId() == co2SensorInputActionTypeId) {
|
||||
double value = info->action().param(co2SensorInputActionInputParamTypeId).value().toDouble();
|
||||
thing->setStateValue(co2SensorInputStateTypeId, value);
|
||||
double min = info->thing()->setting(co2SensorSettingsMinCO2ParamTypeId).toDouble();
|
||||
double max = info->thing()->setting(co2SensorSettingsMaxCO2ParamTypeId).toDouble();
|
||||
double newValue = mapDoubleValue(value, 0, 100, min, max);
|
||||
double roundingFactor = qPow(10, info->thing()->setting(co2SensorSettingsAccuracyParamTypeId).toInt());
|
||||
newValue = qRound(newValue * roundingFactor) / roundingFactor;
|
||||
thing->setStateValue(co2SensorCo2StateTypeId, 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();
|
||||
|
||||
@ -694,6 +694,122 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "9a8d804b-d1dc-450a-8c41-be491e5cdda0",
|
||||
"name": "pressureSensor",
|
||||
"displayName": "Generic pressure sensor",
|
||||
"createMethods": ["user"],
|
||||
"interfaces": ["pressuresensor"],
|
||||
"settingsTypes": [
|
||||
{
|
||||
"id": "035e2619-f9c2-4e8f-95dd-f124ad9402d0",
|
||||
"name": "minPressure",
|
||||
"displayName": "Minimum pressure",
|
||||
"type": "double",
|
||||
"defaultValue": 0,
|
||||
"unit": "MilliBar"
|
||||
},
|
||||
{
|
||||
"id": "06e21251-8b4f-44a1-8504-6b51f8526bd0",
|
||||
"name": "maxPressure",
|
||||
"displayName": "Maximum pressure",
|
||||
"type": "double",
|
||||
"defaultValue": 2000,
|
||||
"unit": "MilliBar"
|
||||
},
|
||||
{
|
||||
"id": "021a17d8-9e5e-4dd6-835d-1a3e1ffd6b23",
|
||||
"name": "accuracy",
|
||||
"displayName": "Accuracy (decimal places)",
|
||||
"type": "uint",
|
||||
"minValue": 0,
|
||||
"maxValue": 5,
|
||||
"defaultValue": 1
|
||||
}
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "e645a979-1465-4592-b8b0-f4c123db0800",
|
||||
"name": "pressure",
|
||||
"displayName": "Pressure",
|
||||
"displayNameEvent": "Pressure changed",
|
||||
"type": "double",
|
||||
"unit": "MilliBar",
|
||||
"defaultValue": 0
|
||||
},
|
||||
{
|
||||
"id": "c320577c-371a-442b-ac80-b692ff2064c9",
|
||||
"name": "input",
|
||||
"displayName": "Input value",
|
||||
"displayNameEvent": "Input value changed",
|
||||
"displayNameAction": "Set input value",
|
||||
"type": "double",
|
||||
"defaultValue": 0,
|
||||
"minValue": 0,
|
||||
"maxValue": 100,
|
||||
"writable": true,
|
||||
"ioType": "analogOutput"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "a58a2dae-4148-4a4d-ab34-2a11124454a0",
|
||||
"name": "co2Sensor",
|
||||
"displayName": "Generic CO2 sensor",
|
||||
"createMethods": ["user"],
|
||||
"interfaces": ["co2Sensor"],
|
||||
"settingsTypes": [
|
||||
{
|
||||
"id": "a0d8a6ec-599a-4ded-ae03-2950561f0b72",
|
||||
"name": "minCO2",
|
||||
"displayName": "Minimum CO2",
|
||||
"type": "double",
|
||||
"defaultValue": 0,
|
||||
"unit": "PartsPerMillion"
|
||||
},
|
||||
{
|
||||
"id": "a3029bee-8b13-4aed-8ebd-eaceb603f8ef",
|
||||
"name": "maxCO2",
|
||||
"displayName": "Maximum CO2",
|
||||
"type": "double",
|
||||
"defaultValue": 2000,
|
||||
"unit": "PartsPerMillion"
|
||||
},
|
||||
{
|
||||
"id": "236831a8-a455-4e38-a9cd-eabbebaa3f67",
|
||||
"name": "accuracy",
|
||||
"displayName": "Accuracy (decimal places)",
|
||||
"type": "uint",
|
||||
"minValue": 0,
|
||||
"maxValue": 5,
|
||||
"defaultValue": 1
|
||||
}
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "755c4c7f-093e-41dd-a38d-9ee18c9890d6",
|
||||
"name": "co2",
|
||||
"displayName": "CO2",
|
||||
"displayNameEvent": "CO2 changed",
|
||||
"type": "double",
|
||||
"unit": "PartsPerMillion",
|
||||
"defaultValue": 0
|
||||
},
|
||||
{
|
||||
"id": "7dc765f8-fa9b-4199-8f21-49ed452f226d",
|
||||
"name": "input",
|
||||
"displayName": "Input value",
|
||||
"displayNameEvent": "Input value changed",
|
||||
"displayNameAction": "Set input value",
|
||||
"type": "double",
|
||||
"defaultValue": 0,
|
||||
"minValue": 0,
|
||||
"maxValue": 100,
|
||||
"writable": true,
|
||||
"ioType": "analogOutput"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "c3123967-f741-4fe1-a0d4-9a3e405d7e52",
|
||||
"name": "extendedSmartMeterConsumer",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user