Browse Source

thermostat: save automatically holiday end date

master
Richard Genoud 4 years ago
parent
commit
82500bb0cb
4 changed files with 15 additions and 5 deletions
  1. +3
    -2
      soft/thermostat/inc/settings.h
  2. +2
    -2
      soft/thermostat/src/mainwindow.cpp
  3. +9
    -0
      soft/thermostat/src/settings.cpp
  4. +1
    -1
      soft/thermostat/src/zoneitem.cpp

+ 3
- 2
soft/thermostat/inc/settings.h View File

@ -57,12 +57,12 @@ public:
static Settings *getInstance(void);
int nbZones(void);
enum power_states getPowerState(void) { return m_state; }
void setPowerState(enum power_states state);
const QDateTime &getEndHoliday(void) { return m_end_holiday; }
void setEndHoliday(const QDateTime &endDate);
QVector<struct Room> m_rooms;
struct Brocker m_broker;
QDateTime m_end_holiday;
private:
explicit Settings(QObject *parent = Q_NULLPTR);
@ -73,6 +73,7 @@ private:
int read_config(void);
enum power_states m_state;
QDateTime m_end_holiday;
};
#endif // SETTINGS_H


+ 2
- 2
soft/thermostat/src/mainwindow.cpp View File

@ -207,7 +207,7 @@ void MainWindow::set_holiday_mode(QDateTime end_date)
{
Settings *s = Settings::getInstance();
s->m_end_holiday = end_date;
s->setEndHoliday(end_date);
apply_order_to_heaters();
}
@ -430,7 +430,7 @@ void MainWindow::apply_order_to_heaters(void)
Settings *s = Settings::getInstance();
bool heating_order = false;
if (s->m_end_holiday > QDateTime::currentDateTime()) {
if (s->getEndHoliday() > QDateTime::currentDateTime()) {
qDebug() << "Holiday mode => emit ALL_OFF order";
emit setAllHeatersOn(false);
} else {


+ 9
- 0
soft/thermostat/src/settings.cpp View File

@ -138,6 +138,15 @@ void Settings::setPowerState(enum power_states state)
}
}
void Settings::setEndHoliday(const QDateTime &endDate)
{
if (endDate.isValid()) {
m_end_holiday = endDate;
this->setValue("end_holiday", m_end_holiday.toString(Qt::ISODate));
}
/* else TODO: error */
}
void Settings::set_rooms_default_config(void)
{
this->setValue("state", "auto");


+ 1
- 1
soft/thermostat/src/zoneitem.cpp View File

@ -81,7 +81,7 @@ void ZoneItem::refresh(void)
break;
}
if (s->m_end_holiday > QDateTime::currentDateTime()) {
if (s->getEndHoliday() > QDateTime::currentDateTime()) {
m_target_temperature = FORCE_OFF;
}


Loading…
Cancel
Save