ESPHome  2024.11.1
anova_base.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "esphome/core/helpers.h"
4 #include "esphome/core/log.h"
5 
6 namespace esphome {
7 namespace anova {
8 
20 };
21 
22 struct AnovaPacket {
23  uint16_t length;
24  uint8_t data[24];
25 };
26 
27 #define CMD_READ_DEVICE_STATUS "status\r"
28 #define CMD_READ_TARGET_TEMP "read set temp\r"
29 #define CMD_READ_CURRENT_TEMP "read temp\r"
30 #define CMD_READ_UNIT "read unit\r"
31 #define CMD_READ_DATA "read data\r"
32 #define CMD_SET_TARGET_TEMP "set temp %.1f\r"
33 #define CMD_SET_TEMP_UNIT "set unit %c\r"
34 
35 #define CMD_START "start\r"
36 #define CMD_STOP "stop\r"
37 
38 class AnovaCodec {
39  public:
40  AnovaPacket *get_read_device_status_request();
41  AnovaPacket *get_read_target_temp_request();
42  AnovaPacket *get_read_current_temp_request();
43  AnovaPacket *get_read_data_request();
44  AnovaPacket *get_read_unit_request();
45 
46  AnovaPacket *get_set_target_temp_request(float temperature);
47  AnovaPacket *get_set_unit_request(char unit);
48 
49  AnovaPacket *get_start_request();
50  AnovaPacket *get_stop_request();
51 
52  void decode(const uint8_t *data, uint16_t length);
53  bool has_target_temp() { return this->has_target_temp_; }
54  bool has_current_temp() { return this->has_current_temp_; }
55  bool has_unit() { return this->has_unit_; }
56  bool has_running() { return this->has_running_; }
57 
58  union {
59  float target_temp_;
61  char unit_;
62  bool running_;
63  };
64 
65  protected:
66  AnovaPacket *clean_packet_();
68 
71  bool has_unit_;
74 
76 };
77 
78 } // namespace anova
79 } // namespace esphome
CurrentQuery current_query_
Definition: anova_base.h:75
uint16_t temperature
Definition: sun_gtil2.cpp:26
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7