Browse Source

thermostat: refresh zones text according to status

master
Richard Genoud 5 years ago
parent
commit
878bf1cdc0
2 changed files with 24 additions and 9 deletions
  1. +9
    -7
      soft/thermostat/src/mainwindow.cpp
  2. +15
    -2
      soft/thermostat/src/zoneitem.cpp

+ 9
- 7
soft/thermostat/src/mainwindow.cpp View File

@ -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;
}
}


+ 15
- 2
soft/thermostat/src/zoneitem.cpp View File

@ -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("<center><b>") + m_name + QString("</b></center>");
/* Temperature */
text += QString("<center><b>");
if (m_heating_on) {
if (((s->m_state == AUTO) && m_heating_on) || (s->m_state == FORCE_ON)) {
text += QString("<font color='red'>");
} else {
text += QString("<font color='black'>");
@ -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("</b></center>");
/* hygrometry */


Loading…
Cancel
Save