From a409bdae50ef271cc13bdbace5bd4f18b134319c Mon Sep 17 00:00:00 2001 From: Richard Genoud Date: Wed, 1 Jan 2020 17:12:26 +0100 Subject: [PATCH] thermostat: shutdown heaters if sensor is not available --- soft/thermostat/inc/zoneitem.h | 1 + soft/thermostat/src/mainwindow.cpp | 14 ++++++++++---- soft/thermostat/src/zoneitem.cpp | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/soft/thermostat/inc/zoneitem.h b/soft/thermostat/inc/zoneitem.h index 9977f5f..55232c7 100644 --- a/soft/thermostat/inc/zoneitem.h +++ b/soft/thermostat/inc/zoneitem.h @@ -26,6 +26,7 @@ public: double m_temperature_value; double m_hygro_value; double m_target_temperature; + bool m_available; bool m_heating_on; private: diff --git a/soft/thermostat/src/mainwindow.cpp b/soft/thermostat/src/mainwindow.cpp index aed6fb6..eaf989d 100644 --- a/soft/thermostat/src/mainwindow.cpp +++ b/soft/thermostat/src/mainwindow.cpp @@ -175,6 +175,9 @@ bool MainWindow::get_heater_order(int room_idx) if (m_zones.at(room_idx)->m_temperature_value == FORCE_OFF) { goto out; } + if (!m_zones.at(room_idx)->m_available) { + goto out; + } /* TODO: make it smarter */ if (qFabs(get_target_temperature(room_idx) @@ -292,10 +295,13 @@ void MainWindow::availability_slot(int idx, bool ok) { Settings *s = Settings::getInstance(); - if ((idx < s->nbZones()) && !ok) { - m_zones.at(idx)->m_hygro_value = 0; - m_zones.at(idx)->m_temperature_value = 0; - m_zones.at(idx)->refresh(); + if (idx < s->nbZones()) { + m_zones.at(idx)->m_available = ok; + if (!ok) { + m_zones.at(idx)->m_hygro_value = 0; + m_zones.at(idx)->m_temperature_value = 0; + m_zones.at(idx)->refresh(); + } } } diff --git a/soft/thermostat/src/zoneitem.cpp b/soft/thermostat/src/zoneitem.cpp index 6d0750b..d7bbf54 100644 --- a/soft/thermostat/src/zoneitem.cpp +++ b/soft/thermostat/src/zoneitem.cpp @@ -26,6 +26,7 @@ ZoneItem::ZoneItem(const QString &zoneName, QWidget *parent) : m_temperature_value = FORCE_OFF; m_hygro_value = FORCE_OFF; m_target_temperature = FORCE_OFF; + m_available = false; /* * Layout for the left part of the window