Use the thermostats windowOpenDetected state too for determining open windows
This commit is contained in:
parent
65107f88fe
commit
d04de54280
@ -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) {
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user