From d04de54280e7ec0a13e80934c0f2f48d46ffaddf Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 16 Mar 2023 17:30:38 +0100 Subject: [PATCH] Use the thermostats windowOpenDetected state too for determining open windows --- airconditioningmanager.cpp | 11 +++++++++++ thermostat.cpp | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/airconditioningmanager.cpp b/airconditioningmanager.cpp index 760c555..1889201 100644 --- a/airconditioningmanager.cpp +++ b/airconditioningmanager.cpp @@ -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) { diff --git a/thermostat.cpp b/thermostat.cpp index ee394e3..819e851 100644 --- a/thermostat.cpp +++ b/thermostat.cpp @@ -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);