Thermostat pour piloter jusqu'à 4 radiateurs avec fil pilote
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1019 B

  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. /*
  3. * Qt mutizone MQTT thermostat
  4. *
  5. * Copyright (C) 2019 Richard Genoud
  6. *
  7. */
  8. #ifndef MQTTCLIENT_H
  9. #define MQTTCLIENT_H
  10. #include <QTimer>
  11. #include <QtMqtt/QtMqtt>
  12. class MQTTClient: public QMqttClient
  13. {
  14. Q_OBJECT
  15. public:
  16. explicit MQTTClient(const QString& host = "localhost", int port = 1883,
  17. QObject* parent = NULL);
  18. virtual ~MQTTClient();
  19. void publish_msg(const QString& topic, const QString& payload);
  20. private:
  21. QTimer m_timer;
  22. public slots:
  23. void onConnected();
  24. void onReceived(const QByteArray &message, const QMqttTopicName &topic);
  25. void onError(ClientError error);
  26. void onPublished(qint32 msgid);
  27. void onStateChanged(ClientState state);
  28. void onDisconnected(void);
  29. void allHeatersOn(bool on);
  30. signals:
  31. void new_temperature(int idx, double val);
  32. void new_hygro(int idx, double val);
  33. void new_battery(int idx, double val);
  34. void new_availability(int idx, bool ok);
  35. };
  36. #endif
  37. /* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */