Use the thermostats windowOpenDetected state too for determining open windows

This commit is contained in:
Michael Zanetti 2023-03-16 17:30:38 +01:00
parent 65107f88fe
commit d04de54280
2 changed files with 12 additions and 1 deletions

View File

@ -347,6 +347,17 @@ void AirConditioningManager::updateZone(const QUuid &zoneId)
// Checking window open
bool windowOpen = false;
foreach (const ThingId &thingId, zone.thermostats()) {
Thing *thing = m_thingManager->findConfiguredThing(thingId);
if (!thing) {
qCWarning(dcAirConditioning()) << "Thing" << thingId << "seems to have been removed from the system!";
continue;
}
if (thing->hasState("windowOpenDetected") && thing->stateValue("windowOpenDetected").toBool()) {
windowOpen = true;
break;
}
}
foreach (const ThingId &thingId, zone.windowSensors()) {
Thing *thing = m_thingManager->findConfiguredThing(thingId);
if (!thing) {

View File

@ -76,7 +76,7 @@ void Thermostat::setWindowOpen(bool windowOpen)
m_windowOpen = windowOpen;
// First check if the device is capable of handling a window open locks
if (m_thing->hasState("windowOpen")) {
if (!m_thing->thingClass().actionTypes().findByName("windowOpen").id().isNull()) {
if (m_thing->stateValue("windowOpen").toBool() != windowOpen) {
ActionType actionType = m_thing->thingClass().actionTypes().findByName("windowOpen");
Action action(actionType.id(), m_thing->id(), Action::TriggeredByRule);