|
|
@ -12,6 +12,7 @@ |
|
|
|
#include <QLocale>
|
|
|
|
#include <QVector>
|
|
|
|
|
|
|
|
#include "mqttclient.h"
|
|
|
|
#include "zoneitem.h"
|
|
|
|
#include "settings.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
@ -58,18 +59,23 @@ MainWindow::MainWindow(QWidget *parent) : |
|
|
|
setCentralWidget(mainWidget); |
|
|
|
|
|
|
|
setWindowTitle(tr("Sorico's thermostat")); |
|
|
|
m_backLoop.start(); |
|
|
|
|
|
|
|
connect(this, SIGNAL(new_pwr_state(enum power_states)), |
|
|
|
&m_backLoop, SLOT(onNewPowerState(enum power_states))); |
|
|
|
/*
|
|
|
|
* MQTT client |
|
|
|
*/ |
|
|
|
m_mqtt = new MQTTClient(QHostAddress(s->m_broker.address), s->m_broker.port, NULL); |
|
|
|
|
|
|
|
connect(&m_backLoop, SIGNAL(new_temperature(int, double)), |
|
|
|
m_mqtt->connectToHost(); |
|
|
|
|
|
|
|
connect(m_mqtt, SIGNAL(new_temperature(int, double)), |
|
|
|
this, SLOT(temperature_slot(int, double))); |
|
|
|
connect(&m_backLoop, SIGNAL(new_hygro(int, double)), |
|
|
|
connect(m_mqtt, SIGNAL(new_hygro(int, double)), |
|
|
|
this, SLOT(hygro_slot(int, double))); |
|
|
|
connect(&m_backLoop, SIGNAL(new_availability(int, bool)), |
|
|
|
connect(m_mqtt, SIGNAL(new_availability(int, bool)), |
|
|
|
this, SLOT(availability_slot(int, bool))); |
|
|
|
|
|
|
|
connect(this, SIGNAL(setAllHeatersOn(bool)), m_mqtt, SLOT(allHeatersOn(bool))); |
|
|
|
|
|
|
|
connect(&m_state_btn, SIGNAL(clicked()), this, SLOT(change_state())); |
|
|
|
} |
|
|
|
|
|
|
@ -110,8 +116,22 @@ void MainWindow::change_state(void) |
|
|
|
m_pwr_state = OFF; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
update_state_btn(m_pwr_state); |
|
|
|
emit new_pwr_state(m_pwr_state); |
|
|
|
|
|
|
|
switch (m_pwr_state) { |
|
|
|
case ON: |
|
|
|
emit setAllHeatersOn(true); |
|
|
|
break; |
|
|
|
case AUTO: |
|
|
|
/* TODO */ |
|
|
|
break; |
|
|
|
case OFF: |
|
|
|
/* fall */ |
|
|
|
default: |
|
|
|
emit setAllHeatersOn(false); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::temperature_slot(int idx, double val) |
|
|
|