diff --git a/soft/thermostat/src/mainwindow.cpp b/soft/thermostat/src/mainwindow.cpp index 8f2c67c..b39771d 100644 --- a/soft/thermostat/src/mainwindow.cpp +++ b/soft/thermostat/src/mainwindow.cpp @@ -369,7 +369,6 @@ void MainWindow::apply_automatic_state(void) for (int j = 0; j < r->heaters.count(); j++) { const struct Heater *h = &(r->heaters.at(j)); qDebug() << "heater " << h->ctrl_topic; - /* TODO: check if connected */ m_mqtt->publish_msg(h->ctrl_topic, m_zones.at(i)->m_heating_on ? "1" : "0"); } @@ -402,6 +401,7 @@ void MainWindow::change_state(void) void MainWindow::apply_order_to_heaters(void) { Settings *s = Settings::getInstance(); + bool heating_order = false; if (m_end_holiday > QDate::currentDate()) { qDebug() << "Holiday mode => emit ALL_OFF order"; @@ -409,19 +409,21 @@ void MainWindow::apply_order_to_heaters(void) } switch (s->m_state) { - case ON: - qDebug() << "emit ALL_ON order"; - emit setAllHeatersOn(true); - break; case AUTO: qDebug() << "apply AUTO state"; apply_automatic_state(); break; + case ON: + heating_order = true; + /* fall */ case OFF: /* fall */ default: - qDebug() << "emit ALL_OFF order"; - emit setAllHeatersOn(false); + emit setAllHeatersOn(heating_order); + + for (int i = 0; i < s->m_rooms.count(); i++) { + m_zones.at(i)->refresh(); + } break; } } diff --git a/soft/thermostat/src/zoneitem.cpp b/soft/thermostat/src/zoneitem.cpp index 94c9e38..948687c 100644 --- a/soft/thermostat/src/zoneitem.cpp +++ b/soft/thermostat/src/zoneitem.cpp @@ -54,13 +54,26 @@ void ZoneItem::mouseReleaseEvent(QMouseEvent* event) { void ZoneItem::refresh(void) { QString text; + Settings *s = Settings::getInstance(); + + switch (s->m_state) { + case OFF: + m_target_temperature = FORCE_OFF; + break; + case ON: + m_target_temperature = FORCE_ON; + break; + case AUTO: + case MAX_POWER_STATES: + break; + } /* Zone name */ text += QString("
") + m_name + QString("
"); /* Temperature */ text += QString("
"); - if (m_heating_on) { + if (((s->m_state == AUTO) && m_heating_on) || (s->m_state == FORCE_ON)) { text += QString(""); } else { text += QString(""); @@ -79,8 +92,8 @@ void ZoneItem::refresh(void) text += QString("+"); } else { text += QString::number(m_target_temperature); + text += QString("°C").toHtmlEscaped(); } - text += QString("°C").toHtmlEscaped(); text += QString("
"); /* hygrometry */