fixed power state change on settings change
This commit is contained in:
parent
c6b0e86bda
commit
af83f1514f
@ -243,6 +243,14 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info)
|
|||||||
timer->stop();
|
timer->stop();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (thing->thingClassId() == thermostatThingClassId) {
|
||||||
|
thermostatCheckPowerOutputState(thing); // check the initial values
|
||||||
|
connect(thing, &Thing::settingChanged, thing, [this, thing] (const ParamTypeId ¶mTypeId, const QVariant &value) {
|
||||||
|
Q_UNUSED(value)
|
||||||
|
if (paramTypeId == thermostatSettingsTemperatureDifferenceParamTypeId) {
|
||||||
|
thermostatCheckPowerOutputState(thing);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
}
|
}
|
||||||
@ -627,32 +635,18 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info)
|
|||||||
|
|
||||||
Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8());
|
Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8());
|
||||||
} else if (thing->thingClassId() == thermostatThingClassId) {
|
} else if (thing->thingClassId() == thermostatThingClassId) {
|
||||||
if (action.actionTypeId() == temperatureSensorInputActionTypeId) {
|
if (action.actionTypeId() == thermostatTemperatureSensorInputActionTypeId) {
|
||||||
|
thing->setStateValue(thermostatTemperatureSensorInputStateTypeId, action.param(thermostatTemperatureSensorInputActionTemperatureSensorInputParamTypeId).value());
|
||||||
double targetTemperature = thing->stateValue(thermostatTargetTemperatureStateTypeId).toDouble();
|
} else if (action.actionTypeId() == thermostatTargetTemperatureActionTypeId) {
|
||||||
double actualTemperature = action.param(thermostatTemperatureSensorInputActionTemperatureSensorInputParamTypeId).value().toDouble();
|
|
||||||
thing->setStateValue(temperatureSensorInputStateTypeId, actualTemperature);
|
|
||||||
double temperatureDifference = thing->setting(thermostatSettingsTemperatureDifferenceParamTypeId).toDouble();
|
|
||||||
if (actualTemperature <= (targetTemperature-temperatureDifference)) {
|
|
||||||
thing->setStateValue(thermostatPowerStateTypeId, true);
|
|
||||||
} else if (actualTemperature >= targetTemperature) {
|
|
||||||
thing->setStateValue(thermostatPowerStateTypeId, false);
|
|
||||||
}
|
|
||||||
info->finish(Thing::ThingErrorNoError);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (action.actionTypeId() == thermostatTargetTemperatureActionTypeId) {
|
|
||||||
|
|
||||||
thing->setStateValue(thermostatTargetTemperatureStateTypeId, action.param(thermostatTargetTemperatureActionTargetTemperatureParamTypeId).value());
|
thing->setStateValue(thermostatTargetTemperatureStateTypeId, action.param(thermostatTargetTemperatureActionTargetTemperatureParamTypeId).value());
|
||||||
info->finish(Thing::ThingErrorNoError);
|
} else if (action.actionTypeId() == thermostatPowerActionTypeId) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (action.actionTypeId() == thermostatPowerActionTypeId) {
|
|
||||||
thing->setStateValue(thermostatPowerStateTypeId, action.param(thermostatPowerActionPowerParamTypeId).value());
|
thing->setStateValue(thermostatPowerStateTypeId, action.param(thermostatPowerActionPowerParamTypeId).value());
|
||||||
info->finish(Thing::ThingErrorNoError);
|
} else {
|
||||||
return;
|
Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8());
|
||||||
}
|
}
|
||||||
Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8());
|
thermostatCheckPowerOutputState(thing);
|
||||||
|
info->finish(Thing::ThingErrorNoError);
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
|
Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
|
||||||
}
|
}
|
||||||
@ -806,3 +800,18 @@ void IntegrationPluginGenericThings::moveBlindToAngle(Action action, Thing *thin
|
|||||||
qCDebug(dcGenericThings()) << "Move to angle doesn't support this thingClass";
|
qCDebug(dcGenericThings()) << "Move to angle doesn't support this thingClass";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IntegrationPluginGenericThings::thermostatCheckPowerOutputState(Thing *thing)
|
||||||
|
{
|
||||||
|
double targetTemperature = thing->stateValue(thermostatTargetTemperatureStateTypeId).toDouble();
|
||||||
|
double actualTemperature = thing->stateValue(thermostatTemperatureSensorInputStateTypeId).toDouble();
|
||||||
|
double temperatureDifference = thing->setting(thermostatSettingsTemperatureDifferenceParamTypeId).toDouble();
|
||||||
|
if (actualTemperature <= (targetTemperature-temperatureDifference)) {
|
||||||
|
thing->setStateValue(thermostatPowerStateTypeId, true);
|
||||||
|
} else if (actualTemperature >= targetTemperature) {
|
||||||
|
thing->setStateValue(thermostatPowerStateTypeId, false);
|
||||||
|
} else {
|
||||||
|
//Keep actual state
|
||||||
|
//Possible improvement add boost action where powerState = true is forced inside the hysteresis
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -70,6 +70,8 @@ private:
|
|||||||
void setBlindState(BlindState state, Thing *thing);
|
void setBlindState(BlindState state, Thing *thing);
|
||||||
void moveBlindToPercentage(Action action, Thing *thing);
|
void moveBlindToPercentage(Action action, Thing *thing);
|
||||||
void moveBlindToAngle(Action action, Thing *thing);
|
void moveBlindToAngle(Action action, Thing *thing);
|
||||||
|
|
||||||
|
void thermostatCheckPowerOutputState(Thing *thing);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTEGRATIONPLUGINGENERICTHINGS_H
|
#endif // INTEGRATIONPLUGINGENERICTHINGS_H
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user