ClassFlowMQTT.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #pragma once
  2. #ifndef CLASSFFLOWMQTT_H
  3. #define CLASSFFLOWMQTT_H
  4. #include <string>
  5. #include <mqtt_client.h>
  6. #include "ClassFlow.h"
  7. #include "ClassFlowPostProcessing.h"
  8. typedef struct
  9. {
  10. bool mqtt_enabled;
  11. bool mqtt_configOK;
  12. bool mqtt_initialized;
  13. bool mqtt_connected;
  14. bool HomeAssistantDiscovery;
  15. esp_mqtt_event_id_t esp_mqtt_ID;
  16. std::string uri;
  17. std::string topic;
  18. std::string topicError;
  19. std::string clientname;
  20. std::string topicRate;
  21. std::string topicTimeStamp;
  22. std::string topicUptime;
  23. std::string topicFreeMem;
  24. std::string oldValue;
  25. std::string user;
  26. std::string password;
  27. std::string caCertFilename;
  28. std::string clientCertFilename;
  29. std::string clientKeyFilename;
  30. bool validateServerCert;
  31. std::string maintopic;
  32. std::string discoveryprefix;
  33. std::string domoticzintopic;
  34. std::string lwt_topic;
  35. std::string lwt_connected;
  36. std::string lwt_disconnected;
  37. std::string meterType;
  38. std::string valueUnit;
  39. std::string timeUnit;
  40. std::string rateUnit;
  41. float roundInterval; // in Minutes
  42. bool retainFlag;
  43. int keepAlive; // in Seconds
  44. } mqtt_controll_config_t;
  45. extern mqtt_controll_config_t mqtt_controll_config;
  46. class ClassFlowMQTT : public ClassFlow
  47. {
  48. protected:
  49. ClassFlowPostProcessing *flowpostprocessing;
  50. void SetInitialParameter(void);
  51. void SetMeterType(std::string _meterType, std::string _valueUnit, std::string _timeUnit, std::string _rateUnit);
  52. void handleIdx(std::string _decsep, std::string _value);
  53. public:
  54. ClassFlowMQTT(void);
  55. ClassFlowMQTT(std::vector<ClassFlow *> *lfc);
  56. ClassFlowMQTT(std::vector<ClassFlow *> *lfc, ClassFlow *_prev);
  57. bool Start(float AutoInterval);
  58. bool ReadParameter(FILE *pFile, std::string &aktparamgraph);
  59. bool doFlow(std::string time);
  60. std::string name(void) { return "ClassFlowMQTT"; };
  61. };
  62. #endif // CLASSFFLOWMQTT_H