ESPHome  2024.11.0
hon_packet.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 
5 namespace esphome {
6 namespace haier {
7 namespace hon_protocol {
8 
9 enum class VerticalSwingMode : uint8_t {
10  HEALTH_UP = 0x01,
11  MAX_UP = 0x02,
12  HEALTH_DOWN = 0x03,
13  UP = 0x04,
14  CENTER = 0x06,
15  DOWN = 0x08,
16  MAX_DOWN = 0x0A,
17  AUTO = 0x0C,
18  // Auto for special modes
19  AUTO_SPECIAL = 0x0E
20 };
21 
22 enum class HorizontalSwingMode : uint8_t {
23  CENTER = 0x00,
24  MAX_LEFT = 0x03,
25  LEFT = 0x04,
26  RIGHT = 0x05,
27  MAX_RIGHT = 0x06,
28  AUTO = 0x07
29 };
30 
31 enum class ConditioningMode : uint8_t {
32  AUTO = 0x00,
33  COOL = 0x01,
34  DRY = 0x02,
35  HEALTHY_DRY = 0x03,
36  HEAT = 0x04,
37  ENERGY_SAVING = 0x05,
38  FAN = 0x06
39 };
40 
41 enum class DataParameters : uint8_t {
42  AC_POWER = 0x01,
43  SET_POINT = 0x02,
44  VERTICAL_SWING_MODE = 0x03,
45  AC_MODE = 0x04,
46  FAN_MODE = 0x05,
47  USE_FAHRENHEIT = 0x07,
48  DISPLAY_STATUS = 0x09,
49  TEN_DEGREE = 0x0A,
50  HEALTH_MODE = 0x0B,
51  HORIZONTAL_SWING_MODE = 0x0C,
52  SELF_CLEANING = 0x0D,
53  BEEPER_STATUS = 0x16,
54  LOCK_REMOTE = 0x17,
55  QUIET_MODE = 0x19,
56  FAST_MODE = 0x1A,
57  SLEEP_MODE = 0x1B,
58 };
59 
60 enum class SpecialMode : uint8_t { NONE = 0x00, ELDERLY = 0x01, CHILDREN = 0x02, PREGNANT = 0x03 };
61 
62 enum class FanMode : uint8_t { FAN_HIGH = 0x01, FAN_MID = 0x02, FAN_LOW = 0x03, FAN_AUTO = 0x05 };
63 
65  // Control bytes starts here
66  // 1
67  uint8_t set_point; // Target temperature with 16°C offset (0x00 = 16°C)
68  // 2
69  uint8_t vertical_swing_mode : 4; // See enum VerticalSwingMode
70  uint8_t : 0;
71  // 3
72  uint8_t fan_mode : 3; // See enum FanMode
73  uint8_t special_mode : 2; // See enum SpecialMode
74  uint8_t ac_mode : 3; // See enum ConditioningMode
75  // 4
76  uint8_t : 8;
77  // 5
78  uint8_t ten_degree : 1; // 10 degree status
79  uint8_t display_status : 1; // If 0 disables AC's display
80  uint8_t half_degree : 1; // Use half degree
81  uint8_t intelligence_status : 1; // Intelligence status
82  uint8_t pmv_status : 1; // Comfort/PMV status
83  uint8_t use_fahrenheit : 1; // Use Fahrenheit instead of Celsius
84  uint8_t : 1;
85  uint8_t steri_clean : 1;
86  // 6
87  uint8_t ac_power : 1; // Is ac on or off
88  uint8_t health_mode : 1; // Health mode (negative ions) on or off
89  uint8_t electric_heating_status : 1; // Electric heating status
90  uint8_t fast_mode : 1; // Fast mode
91  uint8_t quiet_mode : 1; // Quiet mode
92  uint8_t sleep_mode : 1; // Sleep mode
93  uint8_t lock_remote : 1; // Disable remote
94  uint8_t beeper_status : 1; // If 1 disables AC's command feedback beeper (need to be set on every control command)
95  // 7
96  uint8_t target_humidity; // Target humidity (0=30% .. 3C=90%, step = 1%)
97  // 8
98  uint8_t horizontal_swing_mode : 3; // See enum HorizontalSwingMode
99  uint8_t : 3;
100  uint8_t human_sensing_status : 2; // Human sensing status
101  // 9
102  uint8_t change_filter : 1; // Filter need replacement
103  uint8_t : 0;
104  // 10
105  uint8_t fresh_air_status : 1; // Fresh air status
106  uint8_t humidification_status : 1; // Humidification status
107  uint8_t pm2p5_cleaning_status : 1; // PM2.5 cleaning status
108  uint8_t ch2o_cleaning_status : 1; // CH2O cleaning status
109  uint8_t self_cleaning_status : 1; // Self cleaning status
110  uint8_t light_status : 1; // Light status
111  uint8_t energy_saving_status : 1; // Energy saving status
112  uint8_t cleaning_time_status : 1; // Cleaning time (0 - accumulation, 1 - clear)
113 };
114 
116  // 11
117  uint8_t room_temperature; // 0.5°C step
118  // 12
119  uint8_t room_humidity; // 0%-100% with 1% step
120  // 13
121  uint8_t outdoor_temperature; // 1°C step, -64°C offset (0=-64°C)
122  // 14
123  uint8_t pm2p5_level : 2; // Indoor PM2.5 grade (00: Excellent, 01: good, 02: Medium, 03: Bad)
124  uint8_t air_quality : 2; // Air quality grade (00: Excellent, 01: good, 02: Medium, 03: Bad)
125  uint8_t human_sensing : 2; // Human presence result (00: N/A, 01: not detected, 02: One, 03: Multiple)
126  uint8_t : 1;
127  uint8_t ac_type : 1; // 00 - Heat and cool, 01 - Cool only)
128  // 15
129  uint8_t error_status; // See enum ErrorStatus
130  // 16
131  uint8_t operation_source : 2; // who is controlling AC (00: Other, 01: Remote control, 02: Button, 03: ESP)
132  uint8_t operation_mode_hk : 2; // Homekit only, operation mode (00: Cool, 01: Dry, 02: Heat, 03: Fan)
133  uint8_t : 3;
134  uint8_t err_confirmation : 1; // If 1 clear error status
135  // 17
136  uint16_t total_cleaning_time; // Cleaning cumulative time (1h step)
137  // 19
138  uint16_t indoor_pm2p5_value; // Indoor PM2.5 value (0 ug/m3 - 4095 ug/m3, 1 ug/m3 step)
139  // 21
140  uint16_t outdoor_pm2p5_value; // Outdoor PM2.5 value (0 ug/m3 - 4095 ug/m3, 1 ug/m3 step)
141  // 23
142  uint16_t ch2o_value; // Formaldehyde value (0 ug/m3 - 10000 ug/m3, 1 ug/m3 step)
143  // 25
144  uint16_t voc_value; // VOC value (Volatile Organic Compounds) (0 ug/m3 - 1023 ug/m3, 1 ug/m3 step)
145  // 27
146  uint16_t co2_value; // CO2 value (0 PPM - 10000 PPM, 1 PPM step)
147 };
148 
150  // 29
151  uint8_t power[2]; // AC power consumption (0W - 65535W, 1W step)
152  // 31
153  uint8_t indoor_coil_temperature; // 0.5°C step, -20°C offset (0=-20°C)
154  // 32
155  uint8_t outdoor_out_air_temperature; // 1°C step, -64°C offset (0=-64°C)
156  // 33
157  uint8_t outdoor_coil_temperature; // 1°C step, -64°C offset (0=-64°C)
158  // 34
159  uint8_t outdoor_in_air_temperature; // 1°C step, -64°C offset (0=-64°C)
160  // 35
161  uint8_t outdoor_defrost_temperature; // 1°C step, -64°C offset (0=-64°C)
162  // 36
163  uint8_t compressor_frequency; // 1Hz step, 0Hz - 127Hz
164  // 37
165  uint8_t compressor_current[2]; // 0.1A step, 0.0A - 51.1A (0x0000 - 0x01FF)
166  // 39
167  uint8_t outdoor_fan_status : 2; // 0 - off, 1 - on, 2 - information not available
168  uint8_t defrost_status : 2; // 0 - off, 1 - on, 2 - information not available
169  uint8_t : 0;
170  // 40
171  uint8_t compressor_status : 2; // 0 - off, 1 - on, 2 - information not available
172  uint8_t indoor_fan_status : 2; // 0 - off, 1 - on, 2 - information not available
173  uint8_t four_way_valve_status : 2; // 0 - off, 1 - on, 2 - information not available
174  uint8_t indoor_electric_heating_status : 2; // 0 - off, 1 - on, 2 - information not available
175  // 41
176  uint8_t expansion_valve_open_degree[2]; // 0 - 4095
177 };
178 
180  char protocol_version[8];
181  char software_version[8];
182  uint8_t encryption[3];
183  char hardware_version[8];
184  uint8_t : 8;
185  char device_name[8];
186  uint8_t functions[2];
187 };
188 
189 enum class SubcommandsControl : uint16_t {
190  GET_PARAMETERS = 0x4C01, // Request specific parameters (packet content: parameter ID1 + parameter ID2 + ...)
191  GET_USER_DATA = 0x4D01, // Request all user data from device (packet content: None)
192  GET_BIG_DATA = 0x4DFE, // Request big data information from device (packet content: None)
193  SET_PARAMETERS = 0x5C01, // Set parameters of the device and device return parameters (packet content: parameter ID1
194  // + parameter data1 + parameter ID2 + parameter data 2 + ...)
195  SET_SINGLE_PARAMETER = 0x5D00, // Set single parameter (0x5DXX second byte define parameter ID) and return all user
196  // data (packet content: ???)
197  SET_GROUP_PARAMETERS = 0x6001, // Set group parameters to device (0x60XX second byte define parameter is group ID,
198  // the only group mentioned in document is 1) and return all user data (packet
199  // content: all values like in status packet)
200 };
201 
202 const std::string HON_ALARM_MESSAGES[] = {
203  "Outdoor module failure",
204  "Outdoor defrost sensor failure",
205  "Outdoor compressor exhaust sensor failure",
206  "Outdoor EEPROM abnormality",
207  "Indoor coil sensor failure",
208  "Indoor-outdoor communication failure",
209  "Power supply overvoltage protection",
210  "Communication failure between panel and indoor unit",
211  "Outdoor compressor overheat protection",
212  "Outdoor environmental sensor abnormality",
213  "Full water protection",
214  "Indoor EEPROM failure",
215  "Outdoor out air sensor failure",
216  "CBD and module communication failure",
217  "Indoor DC fan failure",
218  "Outdoor DC fan failure",
219  "Door switch failure",
220  "Dust filter needs cleaning reminder",
221  "Water shortage protection",
222  "Humidity sensor failure",
223  "Indoor temperature sensor failure",
224  "Manipulator limit failure",
225  "Indoor PM2.5 sensor failure",
226  "Outdoor PM2.5 sensor failure",
227  "Indoor heating overload/high load alarm",
228  "Outdoor AC current protection",
229  "Outdoor compressor operation abnormality",
230  "Outdoor DC current protection",
231  "Outdoor no-load failure",
232  "CT current abnormality",
233  "Indoor cooling freeze protection",
234  "High and low pressure protection",
235  "Compressor out air temperature is too high",
236  "Outdoor evaporator sensor failure",
237  "Outdoor cooling overload",
238  "Water pump drainage failure",
239  "Three-phase power supply failure",
240  "Four-way valve failure",
241  "External alarm/scraper flow switch failure",
242  "Temperature cutoff protection alarm",
243  "Different mode operation failure",
244  "Electronic expansion valve failure",
245  "Dual heat source sensor Tw failure",
246  "Communication failure with the wired controller",
247  "Indoor unit address duplication failure",
248  "50Hz zero crossing failure",
249  "Outdoor unit failure",
250  "Formaldehyde sensor failure",
251  "VOC sensor failure",
252  "CO2 sensor failure",
253  "Firewall failure",
254 };
255 
256 constexpr size_t HON_ALARM_COUNT = sizeof(HON_ALARM_MESSAGES) / sizeof(HON_ALARM_MESSAGES[0]);
257 
258 } // namespace hon_protocol
259 } // namespace haier
260 } // namespace esphome
constexpr size_t HON_ALARM_COUNT
Definition: hon_packet.h:256
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
const std::string HON_ALARM_MESSAGES[]
Definition: hon_packet.h:202