ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
hon_climate.cpp
Go to the documentation of this file.
1#include <chrono>
2#include <string>
6#include "esphome/core/hal.h"
9#include "hon_climate.h"
10#include "hon_packet.h"
11
12using namespace esphome::climate;
13using namespace esphome::uart;
14
15namespace esphome::haier {
16
17static bool vertical_axis_is_auto(climate::ClimateSwingMode swing_mode) {
19}
20
21static bool horizontal_axis_is_auto(climate::ClimateSwingMode swing_mode) {
23}
24
25static bool is_auto(hon_protocol::VerticalSwingMode mode) {
27}
28
30
31// A position the user just set wins over the appliance's echo of the old one for this long
33static bool in_debounce(uint32_t set_time, uint32_t now) {
34 return set_time != 0 && now - set_time < AIRFLOW_SELECT_DEBOUNCE_MS;
35}
36
37ESPHOME_LOG_TAG(TAG, "haier.climate");
38constexpr size_t SIGNAL_LEVEL_UPDATE_INTERVAL_MS = 10000;
40constexpr uint8_t CONTROL_MESSAGE_RETRIES = 5;
41constexpr std::chrono::milliseconds CONTROL_MESSAGE_RETRIES_INTERVAL = std::chrono::milliseconds(500);
42constexpr size_t ALARM_STATUS_REQUEST_INTERVAL_MS = 600000;
43const uint8_t ONE_BUF[] = {0x00, 0x01};
44const uint8_t ZERO_BUF[] = {0x00, 0x00};
45
46// Alarm texts indexed by alarm code; the last entry is the fallback for unknown codes
48 HonAlarmMessages, "Outdoor module failure", "Outdoor defrost sensor failure",
49 "Outdoor compressor exhaust sensor failure", "Outdoor EEPROM abnormality", "Indoor coil sensor failure",
50 "Indoor-outdoor communication failure", "Power supply overvoltage protection",
51 "Communication failure between panel and indoor unit", "Outdoor compressor overheat protection",
52 "Outdoor environmental sensor abnormality", "Full water protection", "Indoor EEPROM failure",
53 "Outdoor out air sensor failure", "CBD and module communication failure", "Indoor DC fan failure",
54 "Outdoor DC fan failure", "Door switch failure", "Dust filter needs cleaning reminder", "Water shortage protection",
55 "Humidity sensor failure", "Indoor temperature sensor failure", "Manipulator limit failure",
56 "Indoor PM2.5 sensor failure", "Outdoor PM2.5 sensor failure", "Indoor heating overload/high load alarm",
57 "Outdoor AC current protection", "Outdoor compressor operation abnormality", "Outdoor DC current protection",
58 "Outdoor no-load failure", "CT current abnormality", "Indoor cooling freeze protection",
59 "High and low pressure protection", "Compressor out air temperature is too high",
60 "Outdoor evaporator sensor failure", "Outdoor cooling overload", "Water pump drainage failure",
61 "Three-phase power supply failure", "Four-way valve failure", "External alarm/scraper flow switch failure",
62 "Temperature cutoff protection alarm", "Different mode operation failure", "Electronic expansion valve failure",
63 "Dual heat source sensor Tw failure", "Communication failure with the wired controller",
64 "Indoor unit address duplication failure", "50Hz zero crossing failure", "Outdoor unit failure",
65 "Formaldehyde sensor failure", "VOC sensor failure", "CO2 sensor failure", "Firewall failure", "Unknown");
66
68 : cleaning_status_(CleaningState::NO_CLEANING),
69 got_valid_outdoor_temp_(false),
70 active_alarms_{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} {
73}
74
76
78 if (state != this->settings_.beeper_state) {
80#ifdef USE_SWITCH
81 PUBLISH_STATE(this->beeper_switch_, state);
82#endif
83 this->hon_rtc_.save(&this->settings_);
84 }
85}
86
88
90 if (state != this->get_quiet_mode_state()) {
91 if ((this->mode != ClimateMode::CLIMATE_MODE_OFF) && (this->mode != ClimateMode::CLIMATE_MODE_FAN_ONLY)) {
93 this->force_send_control_ = true;
94 } else {
96 }
98#ifdef USE_SWITCH
99 PUBLISH_STATE(this->quiet_mode_switch_, state);
100#endif
101 this->hon_rtc_.save(&this->settings_);
102 }
103}
104
108
109esphome::optional<hon_protocol::VerticalSwingMode> HonClimate::get_vertical_airflow() const {
110 if (!this->current_vertical_swing_.has_value()) {
111 return this->current_vertical_swing_;
112 }
113 // While the appliance swings, or right after the user chose a position, report the chosen position
114 if (is_auto(this->current_vertical_swing_.value()) ||
116 return this->settings_.last_vertiacal_swing;
117 }
118 return this->current_vertical_swing_;
119}
120
122 if (is_auto(direction)) {
123 ESP_LOGW(TAG, "Vertical AUTO mode is not allowed for airflow position selector");
124 return;
125 }
126 if (this->settings_.last_vertiacal_swing != direction) {
128 this->hon_rtc_.save(&this->settings_);
129 }
131 this->force_send_control_ = true;
133#ifdef USE_SELECT
134 this->publish_airflow_selects_();
135#endif
136}
137
138esphome::optional<hon_protocol::HorizontalSwingMode> HonClimate::get_horizontal_airflow() const {
139 if (!this->current_horizontal_swing_.has_value()) {
140 return this->current_horizontal_swing_;
141 }
142 if (is_auto(this->current_horizontal_swing_.value()) ||
144 return this->settings_.last_horizontal_swing;
145 }
146 return this->current_horizontal_swing_;
147}
148
150 if (is_auto(direction)) {
151 ESP_LOGW(TAG, "Horizontal AUTO mode is not allowed for airflow position selector");
152 return;
153 }
154 if (this->settings_.last_horizontal_swing != direction) {
156 this->hon_rtc_.save(&this->settings_);
157 }
159 this->force_send_control_ = true;
161#ifdef USE_SELECT
162 this->publish_airflow_selects_();
163#endif
164}
165
167 switch (this->cleaning_status_) {
169 return "Self clean";
171 return "56°C Steri-Clean";
172 default:
173 return "No cleaning";
174 }
175}
176
178
181 ESP_LOGI(TAG, "Sending self cleaning start request");
182 this->action_request_ =
183 PendingAction({ActionRequest::START_SELF_CLEAN, esphome::optional<haier_protocol::HaierMessage>()});
184 }
185}
186
189 ESP_LOGI(TAG, "Sending steri cleaning start request");
190 this->action_request_ =
191 PendingAction({ActionRequest::START_STERI_CLEAN, esphome::optional<haier_protocol::HaierMessage>()});
192 }
193}
194
195haier_protocol::HandlerError HonClimate::get_device_version_answer_handler_(haier_protocol::FrameType request_type,
196 haier_protocol::FrameType message_type,
197 const uint8_t *data, size_t data_size) {
198 // Should check this before preprocess
199 if (message_type == haier_protocol::FrameType::INVALID) {
200 ESP_LOGW(TAG, "It looks like your ESPHome Haier climate configuration is wrong. You should use the smartAir2 "
201 "protocol instead of hOn");
203 return haier_protocol::HandlerError::INVALID_ANSWER;
204 }
205 haier_protocol::HandlerError result =
206 this->answer_preprocess_(request_type, haier_protocol::FrameType::GET_DEVICE_VERSION, message_type,
207 haier_protocol::FrameType::GET_DEVICE_VERSION_RESPONSE, ProtocolPhases::SENDING_INIT_1);
208 if (result == haier_protocol::HandlerError::HANDLER_OK) {
209 if (data_size < sizeof(hon_protocol::DeviceVersionAnswer)) {
210 // Wrong structure
211 return haier_protocol::HandlerError::WRONG_MESSAGE_STRUCTURE;
212 }
213 // All OK
215 HardwareInfo info{}; // zero-init guarantees null-termination
216 strncpy(info.protocol_version_, answr->protocol_version, HARDWARE_INFO_STR_SIZE - 1);
217 strncpy(info.software_version_, answr->software_version, HARDWARE_INFO_STR_SIZE - 1);
218 strncpy(info.hardware_version_, answr->hardware_version, HARDWARE_INFO_STR_SIZE - 1);
219 strncpy(info.device_name_, answr->device_name, HARDWARE_INFO_STR_SIZE - 1);
220 info.functions_[0] = (answr->functions[1] & 0x01) != 0; // interactive mode support
221 info.functions_[1] = (answr->functions[1] & 0x02) != 0; // controller-device mode support
222 info.functions_[2] = (answr->functions[1] & 0x04) != 0; // crc support
223 info.functions_[3] = (answr->functions[1] & 0x08) != 0; // multiple AC support
224 info.functions_[4] = (answr->functions[1] & 0x20) != 0; // roles support
225 this->use_crc_ = info.functions_[2];
226#ifdef USE_TEXT_SENSOR
229#endif
230 this->hvac_hardware_info_ = info;
232 return result;
233 } else {
234 this->reset_phase_();
235 return result;
236 }
237}
238
239haier_protocol::HandlerError HonClimate::get_device_id_answer_handler_(haier_protocol::FrameType request_type,
240 haier_protocol::FrameType message_type,
241 const uint8_t *data, size_t data_size) {
242 haier_protocol::HandlerError result =
243 this->answer_preprocess_(request_type, haier_protocol::FrameType::GET_DEVICE_ID, message_type,
244 haier_protocol::FrameType::GET_DEVICE_ID_RESPONSE, ProtocolPhases::SENDING_INIT_2);
245 if (result == haier_protocol::HandlerError::HANDLER_OK) {
247 return result;
248 } else {
249 this->reset_phase_();
250 return result;
251 }
252}
253
254haier_protocol::HandlerError HonClimate::status_handler_(haier_protocol::FrameType request_type,
255 haier_protocol::FrameType message_type, const uint8_t *data,
256 size_t data_size) {
257 haier_protocol::HandlerError result =
258 this->answer_preprocess_(request_type, haier_protocol::FrameType::CONTROL, message_type,
259 haier_protocol::FrameType::STATUS, ProtocolPhases::UNKNOWN);
260 if (result == haier_protocol::HandlerError::HANDLER_OK) {
261 result = this->process_status_message_(data, data_size);
262 if (result != haier_protocol::HandlerError::HANDLER_OK) {
263 ESP_LOGW(TAG, "Error %d while parsing Status packet", (int) result);
264 this->reset_phase_();
265 this->action_request_.reset();
266 this->force_send_control_ = false;
267 } else {
268 if (!this->last_status_message_) {
271 this->last_status_message_.reset();
272 this->last_status_message_ = std::unique_ptr<uint8_t[]>(new uint8_t[this->real_control_packet_size_]);
273 };
274 if (data_size >= this->real_control_packet_size_ + 2) {
275 memcpy(this->last_status_message_.get(), data + 2 + this->status_message_header_size_,
276 this->real_control_packet_size_);
277 this->status_message_callback_.call((const char *) data, data_size);
278 } else {
279 ESP_LOGW(TAG, "Status packet too small: %zu (should be >= %zu)", data_size, this->real_control_packet_size_);
280 }
281 switch (this->protocol_phase_) {
283 ESP_LOGI(TAG, "First HVAC status received");
285 break;
287 // Do nothing, phase will be changed in process_phase
288 break;
291 break;
293 if (!this->control_messages_queue_.empty())
294 this->control_messages_queue_.pop();
295 if (this->control_messages_queue_.empty()) {
297 this->force_send_control_ = false;
300 } else {
302 }
303 break;
304 default:
305 break;
306 }
307 }
308 return result;
309 } else {
310 this->action_request_.reset();
311 this->force_send_control_ = false;
312 this->reset_phase_();
313 return result;
314 }
315}
316
318 haier_protocol::FrameType request_type, haier_protocol::FrameType message_type, const uint8_t *data,
319 size_t data_size) {
320 haier_protocol::HandlerError result = this->answer_preprocess_(
321 request_type, haier_protocol::FrameType::GET_MANAGEMENT_INFORMATION, message_type,
322 haier_protocol::FrameType::GET_MANAGEMENT_INFORMATION_RESPONSE, ProtocolPhases::SENDING_UPDATE_SIGNAL_REQUEST);
323 if (result == haier_protocol::HandlerError::HANDLER_OK) {
325 return result;
326 } else {
328 return result;
329 }
330}
331
332haier_protocol::HandlerError HonClimate::get_alarm_status_answer_handler_(haier_protocol::FrameType request_type,
333 haier_protocol::FrameType message_type,
334 const uint8_t *data, size_t data_size) {
335 if (request_type == haier_protocol::FrameType::GET_ALARM_STATUS) {
336 if (message_type != haier_protocol::FrameType::GET_ALARM_STATUS_RESPONSE) {
337 // Unexpected answer to request
339 return haier_protocol::HandlerError::UNSUPPORTED_MESSAGE;
340 }
343 // Don't expect this answer now
345 return haier_protocol::HandlerError::UNEXPECTED_MESSAGE;
346 }
347 if (data_size < sizeof(active_alarms_) + 2)
348 return haier_protocol::HandlerError::WRONG_MESSAGE_STRUCTURE;
349 this->process_alarm_message_(data, data_size, this->protocol_phase_ >= ProtocolPhases::IDLE);
351 return haier_protocol::HandlerError::HANDLER_OK;
352 } else {
354 return haier_protocol::HandlerError::UNSUPPORTED_MESSAGE;
355 }
356}
357
358haier_protocol::HandlerError HonClimate::alarm_status_message_handler_(haier_protocol::FrameType type,
359 const uint8_t *buffer, size_t size) {
360 haier_protocol::HandlerError result = haier_protocol::HandlerError::HANDLER_OK;
361 if (size < sizeof(this->active_alarms_) + 2) {
362 // Log error but confirm anyway to avoid to many messages
363 result = haier_protocol::HandlerError::WRONG_MESSAGE_STRUCTURE;
364 }
365 this->process_alarm_message_(buffer, size, true);
366 this->haier_protocol_.send_answer(haier_protocol::HaierMessage(haier_protocol::FrameType::CONFIRM));
367 this->last_alarm_request_ = std::chrono::steady_clock::now();
368 return result;
369}
370
372 // Set handlers
373 this->haier_protocol_.set_answer_handler(
374 haier_protocol::FrameType::GET_DEVICE_VERSION,
375 [this](haier_protocol::FrameType req, haier_protocol::FrameType msg, const uint8_t *data, size_t size) {
376 return this->get_device_version_answer_handler_(req, msg, data, size);
377 });
378 this->haier_protocol_.set_answer_handler(
379 haier_protocol::FrameType::GET_DEVICE_ID,
380 [this](haier_protocol::FrameType req, haier_protocol::FrameType msg, const uint8_t *data, size_t size) {
381 return this->get_device_id_answer_handler_(req, msg, data, size);
382 });
383 this->haier_protocol_.set_answer_handler(
384 haier_protocol::FrameType::CONTROL,
385 [this](haier_protocol::FrameType req, haier_protocol::FrameType msg, const uint8_t *data, size_t size) {
386 return this->status_handler_(req, msg, data, size);
387 });
388 this->haier_protocol_.set_answer_handler(
389 haier_protocol::FrameType::GET_MANAGEMENT_INFORMATION,
390 [this](haier_protocol::FrameType req, haier_protocol::FrameType msg, const uint8_t *data, size_t size) {
391 return this->get_management_information_answer_handler_(req, msg, data, size);
392 });
393 this->haier_protocol_.set_answer_handler(
394 haier_protocol::FrameType::GET_ALARM_STATUS,
395 [this](haier_protocol::FrameType req, haier_protocol::FrameType msg, const uint8_t *data, size_t size) {
396 return this->get_alarm_status_answer_handler_(req, msg, data, size);
397 });
398 this->haier_protocol_.set_answer_handler(
399 haier_protocol::FrameType::REPORT_NETWORK_STATUS,
400 [this](haier_protocol::FrameType req, haier_protocol::FrameType msg, const uint8_t *data, size_t size) {
401 return this->report_network_status_answer_handler_(req, msg, data, size);
402 });
403 this->haier_protocol_.set_message_handler(haier_protocol::FrameType::ALARM_STATUS,
404 [this](haier_protocol::FrameType type, const uint8_t *data, size_t size) {
405 return this->alarm_status_message_handler_(type, data, size);
406 });
407}
408
411 ESP_LOGCONFIG(TAG,
412 " Protocol version: hOn\n"
413 " Control method: %d",
414 (uint8_t) this->control_method_);
415 if (this->hvac_hardware_info_.has_value()) {
416 ESP_LOGCONFIG(TAG,
417 " Device protocol version: %s\n"
418 " Device software version: %s\n"
419 " Device hardware version: %s\n"
420 " Device name: %s",
421 this->hvac_hardware_info_.value().protocol_version_,
422 this->hvac_hardware_info_.value().software_version_,
423 this->hvac_hardware_info_.value().hardware_version_, this->hvac_hardware_info_.value().device_name_);
424 ESP_LOGCONFIG(TAG, " Device features:%s%s%s%s%s",
425 (this->hvac_hardware_info_.value().functions_[0] ? LOG_STR_LITERAL(" interactive") : ""),
426 (this->hvac_hardware_info_.value().functions_[1] ? LOG_STR_LITERAL(" controller-device") : ""),
427 (this->hvac_hardware_info_.value().functions_[2] ? LOG_STR_LITERAL(" crc") : ""),
428 (this->hvac_hardware_info_.value().functions_[3] ? LOG_STR_LITERAL(" multinode") : ""),
429 (this->hvac_hardware_info_.value().functions_[4] ? LOG_STR_LITERAL(" role") : ""));
430 ESP_LOGCONFIG(TAG, " Active alarms: %s", buf_to_hex(this->active_alarms_, sizeof(this->active_alarms_)).c_str());
431 }
432}
433
434void HonClimate::process_phase(std::chrono::steady_clock::time_point now) {
435 switch (this->protocol_phase_) {
438 // Indicate device capabilities:
439 // bit 0 - if 1 module support interactive mode
440 // bit 1 - if 1 module support controller-device mode
441 // bit 2 - if 1 module support crc
442 // bit 3 - if 1 module support multiple devices
443 // bit 4..bit 15 - not used
444 uint8_t module_capabilities[2] = {0b00000000, 0b00000111};
445 static const haier_protocol::HaierMessage DEVICE_VERSION_REQUEST(
446 haier_protocol::FrameType::GET_DEVICE_VERSION, module_capabilities, sizeof(module_capabilities));
447 this->send_message_(DEVICE_VERSION_REQUEST, this->use_crc_);
448 }
449 break;
451 if (this->can_send_message() && this->is_message_interval_exceeded_(now)) {
452 static const haier_protocol::HaierMessage DEVICEID_REQUEST(haier_protocol::FrameType::GET_DEVICE_ID);
453 this->send_message_(DEVICEID_REQUEST, this->use_crc_);
454 }
455 break;
458 if (this->can_send_message() && this->is_message_interval_exceeded_(now)) {
459 static const haier_protocol::HaierMessage STATUS_REQUEST(
460 haier_protocol::FrameType::CONTROL, (uint16_t) hon_protocol::SubcommandsControl::GET_USER_DATA);
461 static const haier_protocol::HaierMessage BIG_DATA_REQUEST(
462 haier_protocol::FrameType::CONTROL, (uint16_t) hon_protocol::SubcommandsControl::GET_BIG_DATA);
464 (!this->should_get_big_data_())) {
465 this->send_message_(STATUS_REQUEST, this->use_crc_);
466 } else {
467 this->send_message_(BIG_DATA_REQUEST, this->use_crc_);
468 }
469 this->last_status_request_ = now;
470 }
471 break;
472#ifdef USE_WIFI
474 if (this->can_send_message() && this->is_message_interval_exceeded_(now)) {
475 static const haier_protocol::HaierMessage UPDATE_SIGNAL_REQUEST(
476 haier_protocol::FrameType::GET_MANAGEMENT_INFORMATION);
477 this->send_message_(UPDATE_SIGNAL_REQUEST, this->use_crc_);
478 this->last_signal_request_ = now;
479 }
480 break;
482 if (this->can_send_message() && this->is_message_interval_exceeded_(now)) {
483 this->send_message_(this->get_wifi_signal_message_(), this->use_crc_);
484 }
485 break;
486#else
490 break;
491#endif
494 if (this->can_send_message() && this->is_message_interval_exceeded_(now)) {
495 static const haier_protocol::HaierMessage ALARM_STATUS_REQUEST(haier_protocol::FrameType::GET_ALARM_STATUS);
496 this->send_message_(ALARM_STATUS_REQUEST, this->use_crc_);
497 this->last_alarm_request_ = now;
498 }
499 break;
501 if (this->control_messages_queue_.empty()) {
502 switch (this->control_method_) {
504 haier_protocol::HaierMessage control_message = this->get_control_message();
505 this->control_messages_queue_.push(control_message);
506 } break;
509 break;
511 ESP_LOGI(TAG, "AC control is disabled, monitor only");
512 this->reset_to_idle_();
513 return;
514 default:
515 ESP_LOGW(TAG, "Unsupported control method for hOn protocol!");
516 this->reset_to_idle_();
517 return;
518 }
519 }
520 if (this->control_messages_queue_.empty()) {
521 ESP_LOGW(TAG, "Control message queue is empty!");
522 this->reset_to_idle_();
523 } else if (this->can_send_message() && this->is_control_message_interval_exceeded_(now)) {
524 ESP_LOGI(TAG, "Sending control packet, queue size %d", this->control_messages_queue_.size());
525 this->send_message_(this->control_messages_queue_.front(), this->use_crc_, CONTROL_MESSAGE_RETRIES,
527 }
528 break;
530 if (this->action_request_.has_value()) {
531 if (this->action_request_.value().message.has_value()) {
532 this->send_message_(this->action_request_.value().message.value(), this->use_crc_);
533 this->action_request_.value().message.reset(); // NOLINT(bugprone-unchecked-optional-access)
534 } else {
535 // Message already sent, reseting request and return to idle
536 this->action_request_.reset();
538 }
539 } else {
540 ESP_LOGW(TAG, "SENDING_ACTION_COMMAND phase without action request!");
542 }
543 break;
547 this->forced_request_status_ = false;
548 } else if (std::chrono::duration_cast<std::chrono::milliseconds>(now - this->last_alarm_request_).count() >
549 ALARM_STATUS_REQUEST_INTERVAL_MS) {
551 }
552#ifdef USE_WIFI
553 else if (this->send_wifi_signal_ &&
554 (std::chrono::duration_cast<std::chrono::milliseconds>(now - this->last_signal_request_).count() >
555 SIGNAL_LEVEL_UPDATE_INTERVAL_MS)) {
557 }
558#endif
559 } break;
560 default:
561 // Shouldn't get here
562 ESP_LOGE(TAG, "Wrong protocol handler state: %s (%d), resetting communication",
563 LOG_STR_ARG(phase_to_string_(this->protocol_phase_)), (int) this->protocol_phase_);
565 break;
566 }
567}
568
569haier_protocol::HaierMessage HonClimate::get_power_message(bool state) {
570 if (state) {
571 static haier_protocol::HaierMessage power_on_message(
572 haier_protocol::FrameType::CONTROL, ((uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER) + 1,
573 std::initializer_list<uint8_t>({0x00, 0x01}).begin(), 2);
574 return power_on_message;
575 } else {
576 static haier_protocol::HaierMessage power_off_message(
577 haier_protocol::FrameType::CONTROL, ((uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER) + 1,
578 std::initializer_list<uint8_t>({0x00, 0x00}).begin(), 2);
579 return power_off_message;
580 }
581}
582
585 constexpr uint32_t restore_settings_version = 0x57EB59DDUL;
586 this->hon_rtc_ = this->make_entity_preference<HonSettings>(restore_settings_version);
587 HonSettings recovered;
588 if (this->hon_rtc_.load(&recovered)) {
589 this->settings_ = recovered;
590 } else {
592 }
593 bool settings_fixed = false;
594 if (is_auto(this->settings_.last_vertiacal_swing)) {
596 settings_fixed = true;
597 }
598 if (is_auto(this->settings_.last_horizontal_swing)) {
600 settings_fixed = true;
601 }
602 if (settings_fixed) {
603 this->hon_rtc_.save(&this->settings_);
604 }
608}
609
610haier_protocol::HaierMessage HonClimate::get_control_message() {
611 uint8_t control_out_buffer[haier_protocol::MAX_FRAME_SIZE];
612 memcpy(control_out_buffer, this->last_status_message_.get(), this->real_control_packet_size_);
614 control_out_buffer[4] = 0; // This byte should be cleared before setting values
615 bool has_hvac_settings = false;
616 if (this->current_hvac_settings_.valid) {
617 has_hvac_settings = true;
618 HvacSettings &climate_control = this->current_hvac_settings_;
619 if (climate_control.mode.has_value()) {
620 switch (climate_control.mode.value()) {
621 case CLIMATE_MODE_OFF:
622 out_data->ac_power = 0;
623 break;
625 out_data->ac_power = 1;
626 out_data->ac_mode = (uint8_t) hon_protocol::ConditioningMode::AUTO;
627 out_data->fan_mode = this->other_modes_fan_speed_;
628 break;
630 out_data->ac_power = 1;
631 out_data->ac_mode = (uint8_t) hon_protocol::ConditioningMode::HEAT;
632 out_data->fan_mode = this->other_modes_fan_speed_;
633 break;
634 case CLIMATE_MODE_DRY:
635 out_data->ac_power = 1;
636 out_data->ac_mode = (uint8_t) hon_protocol::ConditioningMode::DRY;
637 out_data->fan_mode = this->other_modes_fan_speed_;
638 break;
640 out_data->ac_power = 1;
641 out_data->ac_mode = (uint8_t) hon_protocol::ConditioningMode::FAN;
642 out_data->fan_mode = this->fan_mode_speed_; // Auto doesn't work in fan only mode
643 // Disabling boost for Fan only
644 out_data->fast_mode = 0;
645 break;
647 out_data->ac_power = 1;
648 out_data->ac_mode = (uint8_t) hon_protocol::ConditioningMode::COOL;
649 out_data->fan_mode = this->other_modes_fan_speed_;
650 break;
651 default:
652 ESP_LOGE("Control", "Unsupported climate mode");
653 break;
654 }
655 }
656 // Set fan speed, if we are in fan mode, reject auto in fan mode
657 if (climate_control.fan_mode.has_value()) {
658 switch (climate_control.fan_mode.value()) {
659 case CLIMATE_FAN_LOW:
660 out_data->fan_mode = (uint8_t) hon_protocol::FanMode::FAN_LOW;
661 break;
663 out_data->fan_mode = (uint8_t) hon_protocol::FanMode::FAN_MID;
664 break;
665 case CLIMATE_FAN_HIGH:
666 out_data->fan_mode = (uint8_t) hon_protocol::FanMode::FAN_HIGH;
667 break;
668 case CLIMATE_FAN_AUTO:
669 if (mode != CLIMATE_MODE_FAN_ONLY) // if we are not in fan only mode
670 out_data->fan_mode = (uint8_t) hon_protocol::FanMode::FAN_AUTO;
671 break;
672 default:
673 ESP_LOGE("Control", "Unsupported fan mode");
674 break;
675 }
676 }
677 // Set swing mode
678 if (climate_control.swing_mode.has_value()) {
679 switch (climate_control.swing_mode.value()) {
681 out_data->horizontal_swing_mode = (uint8_t) this->settings_.last_horizontal_swing;
682 out_data->vertical_swing_mode = (uint8_t) this->settings_.last_vertiacal_swing;
683 break;
685 out_data->horizontal_swing_mode = (uint8_t) this->settings_.last_horizontal_swing;
687 break;
690 out_data->vertical_swing_mode = (uint8_t) this->settings_.last_vertiacal_swing;
691 break;
695 break;
696 }
697 }
698 if (climate_control.target_temperature.has_value()) {
699 float target_temp = climate_control.target_temperature.value();
700 out_data->set_point = ((int) target_temp) - 16; // set the temperature with offset 16
701 out_data->half_degree = (target_temp - ((int) target_temp) >= 0.49f) ? 1 : 0;
702 }
703 if (out_data->ac_power == 0) {
704 // If AC is off - no presets allowed
705 out_data->fast_mode = 0;
706 out_data->sleep_mode = 0;
707 } else if (climate_control.preset.has_value()) {
708 switch (climate_control.preset.value()) {
710 out_data->fast_mode = 0;
711 out_data->sleep_mode = 0;
712 out_data->ten_degree = 0;
713 break;
715 // Boost is not supported in Fan only mode
716 out_data->fast_mode = (this->mode != CLIMATE_MODE_FAN_ONLY) ? 1 : 0;
717 out_data->sleep_mode = 0;
718 out_data->ten_degree = 0;
719 break;
721 out_data->fast_mode = 0;
722 out_data->sleep_mode = 0;
723 // 10 degrees allowed only in heat mode
724 out_data->ten_degree = (this->mode == CLIMATE_MODE_HEAT) ? 1 : 0;
725 break;
727 out_data->fast_mode = 0;
728 out_data->sleep_mode = 1;
729 out_data->ten_degree = 0;
730 break;
731 default:
732 ESP_LOGE("Control", "Unsupported preset");
733 out_data->fast_mode = 0;
734 out_data->sleep_mode = 0;
735 out_data->ten_degree = 0;
736 break;
737 }
738 }
739 }
740 const ClimateSwingMode target_swing_mode = this->current_hvac_settings_.swing_mode.value_or(this->swing_mode);
741 if (this->pending_vertical_direction_.has_value()) {
742 if (!vertical_axis_is_auto(target_swing_mode)) {
743 out_data->vertical_swing_mode = (uint8_t) this->pending_vertical_direction_.value();
744 } else {
745 ESP_LOGD(TAG, "Vertical swing is on; the position is kept for when it is turned off");
746 }
747 this->pending_vertical_direction_.reset();
748 }
749 if (this->pending_horizontal_direction_.has_value()) {
750 if (!horizontal_axis_is_auto(target_swing_mode)) {
751 out_data->horizontal_swing_mode = (uint8_t) this->pending_horizontal_direction_.value();
752 } else {
753 ESP_LOGD(TAG, "Horizontal swing is on; the position is kept for when it is turned off");
754 }
755 this->pending_horizontal_direction_.reset();
756 }
757 {
758 // Quiet mode
759 if ((out_data->ac_power == 0) || (out_data->ac_mode == (uint8_t) hon_protocol::ConditioningMode::FAN)) {
760 // If AC is off or in fan only mode - no quiet mode allowed
761 out_data->quiet_mode = 0;
762 } else {
763 out_data->quiet_mode = this->get_quiet_mode_state() ? 1 : 0;
764 }
765 // Clean quiet mode state pending flag
766 this->quiet_mode_state_ = (SwitchState) ((uint8_t) this->quiet_mode_state_ & 0b01);
767 }
768 out_data->beeper_status = ((!this->get_beeper_state()) || (!has_hvac_settings)) ? 1 : 0;
769 out_data->display_status = this->get_display_state() ? 1 : 0;
770 this->display_status_ = (SwitchState) ((uint8_t) this->display_status_ & 0b01);
771 out_data->health_mode = this->get_health_mode() ? 1 : 0;
772 this->health_mode_ = (SwitchState) ((uint8_t) this->health_mode_ & 0b01);
773 return haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
775 control_out_buffer, this->real_control_packet_size_);
776}
777
778void HonClimate::process_alarm_message_(const uint8_t *packet, uint8_t size, bool check_new) {
779 constexpr size_t active_alarms_size = sizeof(this->active_alarms_);
780 if (size >= active_alarms_size + 2) {
781 if (check_new) {
782 size_t alarm_code = 0;
783 for (int i = active_alarms_size - 1; i >= 0; i--) {
784 if (packet[2 + i] != active_alarms_[i]) {
785 uint8_t alarm_bit = 1;
786 for (int b = 0; b < 8; b++) {
787 if ((packet[2 + i] & alarm_bit) != (this->active_alarms_[i] & alarm_bit)) {
788 bool alarm_status = (packet[2 + i] & alarm_bit) != 0;
789 int log_level = alarm_status ? ESPHOME_LOG_LEVEL_WARN : ESPHOME_LOG_LEVEL_INFO;
790#ifdef USE_ESP8266
791 // Static so a delayed on_alarm automation can still read it, but only until the next
792 // alarm change, including a later one in this packet; `code` stays correct
793 static char alarm_message[HonAlarmMessages::MAX_LENGTH + 1];
794 ESPHOME_strncpy_P(alarm_message,
795 reinterpret_cast<const char *>(
796 HonAlarmMessages::get_progmem_str(alarm_code, HonAlarmMessages::LAST_INDEX)),
797 sizeof(alarm_message));
798#else
799 const char *alarm_message = HonAlarmMessages::get_progmem_str(alarm_code, HonAlarmMessages::LAST_INDEX);
800#endif
801 esp_log_printf_(log_level, TAG, __LINE__, "Alarm %s (%d): %s", alarm_status ? "activated" : "deactivated",
802 alarm_code, alarm_message);
803 if (alarm_status) {
804 this->alarm_start_callback_.call(alarm_code, alarm_message);
805 this->active_alarm_count_ += 1.0f;
806 } else {
807 this->alarm_end_callback_.call(alarm_code, alarm_message);
808 this->active_alarm_count_ -= 1.0f;
809 }
810 }
811 alarm_bit <<= 1;
812 alarm_code++;
813 }
814 active_alarms_[i] = packet[2 + i];
815 } else {
816 alarm_code += 8;
817 }
818 }
819 } else {
820 float alarm_count = 0.0f;
821 static uint8_t nibble_bits_count[] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
822 for (size_t i = 0; i < sizeof(this->active_alarms_); i++) {
823 alarm_count += (float) (nibble_bits_count[packet[2 + i] & 0x0F] + nibble_bits_count[packet[2 + i] >> 4]);
824 }
825 this->active_alarm_count_ = alarm_count;
826 memcpy(this->active_alarms_, packet + 2, sizeof(this->active_alarms_));
827 }
828 }
829}
830
831#ifdef USE_SENSOR
835 if ((this->sub_sensors_[(size_t) type] != nullptr) && (sens == nullptr)) {
836 this->big_data_sensors_--;
837 } else if ((this->sub_sensors_[(size_t) type] == nullptr) && (sens != nullptr)) {
838 this->big_data_sensors_++;
839 }
840 }
841 this->sub_sensors_[(size_t) type] = sens;
842 }
843}
844
847 size_t index = (size_t) type;
848 if ((this->sub_sensors_[index] != nullptr) &&
849 ((!this->sub_sensors_[index]->has_state()) || (this->sub_sensors_[index]->get_raw_state() != value)))
850 this->sub_sensors_[index]->publish_state(value);
851 }
852}
853#endif // USE_SENSOR
854
855#ifdef USE_BINARY_SENSOR
858 if ((this->sub_binary_sensors_[(size_t) type] != nullptr) && (sens == nullptr)) {
859 this->big_data_sensors_--;
860 } else if ((this->sub_binary_sensors_[(size_t) type] == nullptr) && (sens != nullptr)) {
861 this->big_data_sensors_++;
862 }
863 this->sub_binary_sensors_[(size_t) type] = sens;
864 }
865}
866
868 if (value < 2) {
869 bool converted_value = value == 1;
870 size_t index = (size_t) type;
871 if ((this->sub_binary_sensors_[index] != nullptr) && ((!this->sub_binary_sensors_[index]->has_state()) ||
872 (this->sub_binary_sensors_[index]->state != converted_value)))
873 this->sub_binary_sensors_[index]->publish_state(converted_value);
874 }
875}
876#endif // USE_BINARY_SENSOR
877
878#ifdef USE_TEXT_SENSOR
880 this->sub_text_sensors_[(size_t) type] = sens;
881 switch (type) {
883 if (this->hvac_hardware_info_.has_value())
884 sens->publish_state(this->hvac_hardware_info_.value().device_name_);
885 break;
887 if (this->hvac_hardware_info_.has_value())
888 sens->publish_state(this->hvac_hardware_info_.value().protocol_version_);
889 break;
892 break;
893 default:
894 break;
895 }
896}
897
899 size_t index = (size_t) type;
900 PUBLISH_STATE(this->sub_text_sensors_[index], value);
901}
902#endif // USE_TEXT_SENSOR
903
904#ifdef USE_SWITCH
906 this->beeper_switch_ = sw;
907 PUBLISH_STATE(this->beeper_switch_, this->get_beeper_state());
908}
909
914#endif // USE_SWITCH
915
916#ifdef USE_SELECT
917template<typename Mode, size_t N>
918static void publish_airflow_index(select::Select *sel, const std::array<Mode, N> &order, Mode mode) {
919 if (sel == nullptr) {
920 return;
921 }
922 // Saved settings never hold AUTO after initialization(); any other value outside the table shows as Center
923 size_t index = N;
924 size_t center = 0;
925 for (size_t i = 0; i < N; i++) {
926 const Mode entry = airflow_order_at(order, i);
927 if (entry == mode) {
928 index = i;
929 } else if (entry == Mode::CENTER) {
930 center = i;
931 }
932 }
933 if (index == N) {
934 index = center;
935 }
936 const auto active = sel->active_index();
937 if (active.has_value() && *active == index) {
938 return;
939 }
940 sel->publish_state(index);
941}
942
943void HonClimate::publish_airflow_selects_() {
944 publish_airflow_index(this->vertical_airflow_select_, VERTICAL_SWING_MODES_ORDER,
946 publish_airflow_index(this->horizontal_airflow_select_, HORIZONTAL_SWING_MODES_ORDER,
948}
949#endif // USE_SELECT
950
951haier_protocol::HandlerError HonClimate::process_status_message_(const uint8_t *packet_buffer, uint8_t size) {
952 size_t expected_size =
954 if (size < expected_size) {
955 ESP_LOGW(TAG, "Unexpected message size %u (expexted >= %zu)", size, expected_size);
956 return haier_protocol::HandlerError::WRONG_MESSAGE_STRUCTURE;
957 }
958 uint16_t subtype = (((uint16_t) packet_buffer[0]) << 8) + packet_buffer[1];
959 if ((subtype == 0x7D01) && (size >= expected_size + sizeof(hon_protocol::HaierPacketBigData))) {
960 // Got BigData packet
961 const hon_protocol::HaierPacketBigData *bd_packet =
962 (const hon_protocol::HaierPacketBigData *) (&packet_buffer[expected_size]);
963#ifdef USE_SENSOR
969 this->update_sub_sensor_(SubSensorType::POWER, encode_uint16(bd_packet->power[0], bd_packet->power[1]));
972 encode_uint16(bd_packet->compressor_current[0], bd_packet->compressor_current[1]) / 10.0);
973 this->update_sub_sensor_(
975 encode_uint16(bd_packet->expansion_valve_open_degree[0], bd_packet->expansion_valve_open_degree[1]) / 4095.0);
976#endif // USE_SENSOR
977#ifdef USE_BINARY_SENSOR
985#endif // USE_BINARY_SENSOR
986 }
987 struct {
990 } packet;
991 memcpy(&packet.control, packet_buffer + 2 + this->status_message_header_size_,
993 memcpy(&packet.sensors, packet_buffer + 2 + this->status_message_header_size_ + this->real_control_packet_size_,
995 if (packet.sensors.error_status != 0) {
996 ESP_LOGW(TAG, "HVAC error, code=0x%02X", packet.sensors.error_status);
997 }
998#ifdef USE_SENSOR
999 if ((this->sub_sensors_[(size_t) SubSensorType::OUTDOOR_TEMPERATURE] != nullptr) &&
1000 (this->got_valid_outdoor_temp_ || (packet.sensors.outdoor_temperature > 0))) {
1001 this->got_valid_outdoor_temp_ = true;
1003 (float) (packet.sensors.outdoor_temperature + PROTOCOL_OUTDOOR_TEMPERATURE_OFFSET));
1004 }
1005 if ((this->sub_sensors_[(size_t) SubSensorType::HUMIDITY] != nullptr) && (packet.sensors.room_humidity <= 100)) {
1006 this->update_sub_sensor_(SubSensorType::HUMIDITY, (float) packet.sensors.room_humidity);
1007 }
1008#endif // USE_SENSOR
1009 bool should_publish = false;
1010 {
1011 // Extra modes/presets
1012 optional<ClimatePreset> old_preset = this->preset;
1013 if (packet.control.fast_mode != 0) {
1015 } else if (packet.control.sleep_mode != 0) {
1017 } else if (packet.control.ten_degree != 0) {
1019 } else {
1021 }
1022 should_publish = should_publish || (!old_preset.has_value()) ||
1023 (old_preset.value_or(CLIMATE_PRESET_NONE) != this->preset.value_or(CLIMATE_PRESET_NONE));
1024 }
1025 {
1026 // Target temperature
1027 float old_target_temperature = this->target_temperature;
1028 this->target_temperature = packet.control.set_point + 16.0f + ((packet.control.half_degree == 1) ? 0.5f : 0.0f);
1029 should_publish = should_publish || (old_target_temperature != this->target_temperature);
1030 }
1031 {
1032 // Current temperature
1033 float old_current_temperature = this->current_temperature;
1034 this->current_temperature = packet.sensors.room_temperature / 2.0f;
1035 should_publish = should_publish || (old_current_temperature != this->current_temperature);
1036 }
1037 {
1038 // Fan mode
1039 optional<ClimateFanMode> old_fan_mode = this->fan_mode;
1040 // remember the fan speed we last had for climate vs fan
1041 if (packet.control.ac_mode == (uint8_t) hon_protocol::ConditioningMode::FAN) {
1042 if (packet.control.fan_mode != (uint8_t) hon_protocol::FanMode::FAN_AUTO)
1043 this->fan_mode_speed_ = packet.control.fan_mode;
1044 } else {
1045 this->other_modes_fan_speed_ = packet.control.fan_mode;
1046 }
1047 switch (packet.control.fan_mode) {
1048 case (uint8_t) hon_protocol::FanMode::FAN_AUTO:
1049 if (packet.control.ac_mode != (uint8_t) hon_protocol::ConditioningMode::FAN) {
1050 this->fan_mode = CLIMATE_FAN_AUTO;
1051 } else {
1052 // Shouldn't accept fan speed auto in fan-only mode even if AC reports it
1053 ESP_LOGI(TAG, "Fan speed Auto is not supported in Fan only AC mode, ignoring");
1054 }
1055 break;
1056 case (uint8_t) hon_protocol::FanMode::FAN_MID:
1058 break;
1059 case (uint8_t) hon_protocol::FanMode::FAN_LOW:
1060 this->fan_mode = CLIMATE_FAN_LOW;
1061 break;
1062 case (uint8_t) hon_protocol::FanMode::FAN_HIGH:
1063 this->fan_mode = CLIMATE_FAN_HIGH;
1064 break;
1065 default:
1066 break;
1067 }
1068 should_publish = should_publish || (!old_fan_mode.has_value()) ||
1069 (old_fan_mode.value_or(CLIMATE_FAN_ON) != this->fan_mode.value_or(CLIMATE_FAN_ON));
1070 }
1071 // Display status
1072 // should be before "Climate mode" because it is changing this->mode
1073 if (packet.control.ac_power != 0) {
1074 // if AC is off display status always ON so process it only when AC is on
1075 bool disp_status = packet.control.display_status != 0;
1076 if (disp_status != this->get_display_state()) {
1077 // Do something only if display status changed
1078 if (this->mode == CLIMATE_MODE_OFF) {
1079 // AC just turned on from remote need to turn off display
1080 this->force_send_control_ = true;
1081 } else if ((((uint8_t) this->display_status_) & 0b10) == 0) {
1082 this->display_status_ = disp_status ? SwitchState::SWITCH_ON : SwitchState::SWITCH_OFF;
1083 }
1084 }
1085 }
1086 // Health mode
1087 if ((((uint8_t) this->health_mode_) & 0b10) == 0) {
1088 bool old_health_mode = this->get_health_mode();
1089 this->health_mode_ = packet.control.health_mode == 1 ? SwitchState::SWITCH_ON : SwitchState::SWITCH_OFF;
1090 should_publish = should_publish || (old_health_mode != this->get_health_mode());
1091 }
1092 {
1093 CleaningState new_cleaning;
1094 if (packet.control.steri_clean == 1) {
1095 // Steri-cleaning
1096 new_cleaning = CleaningState::STERI_CLEAN;
1097 } else if (packet.control.self_cleaning_status == 1) {
1098 // Self-cleaning
1099 new_cleaning = CleaningState::SELF_CLEAN;
1100 } else {
1101 // No cleaning
1102 new_cleaning = CleaningState::NO_CLEANING;
1103 }
1104 if (new_cleaning != this->cleaning_status_) {
1105 ESP_LOGD(TAG, "Cleaning status change: %d => %d", (uint8_t) this->cleaning_status_, (uint8_t) new_cleaning);
1106 if (new_cleaning == CleaningState::NO_CLEANING) {
1107 // Turning AC off after cleaning
1108 this->action_request_ =
1109 PendingAction({ActionRequest::TURN_POWER_OFF, esphome::optional<haier_protocol::HaierMessage>()});
1110 }
1111 this->cleaning_status_ = new_cleaning;
1112#ifdef USE_TEXT_SENSOR
1114#endif // USE_TEXT_SENSOR
1115 }
1116 }
1117 {
1118 // Climate mode
1119 ClimateMode old_mode = this->mode;
1120 if (packet.control.ac_power == 0) {
1121 this->mode = CLIMATE_MODE_OFF;
1122 } else {
1123 // Check current hvac mode
1124 switch (packet.control.ac_mode) {
1126 this->mode = CLIMATE_MODE_COOL;
1127 break;
1129 this->mode = CLIMATE_MODE_HEAT;
1130 break;
1132 this->mode = CLIMATE_MODE_DRY;
1133 break;
1135 this->mode = CLIMATE_MODE_FAN_ONLY;
1136 break;
1138 this->mode = CLIMATE_MODE_HEAT_COOL;
1139 break;
1140 default:
1141 break;
1142 }
1143 }
1144 should_publish = should_publish || (old_mode != this->mode);
1145 }
1146 {
1147 // Quiet mode, should be after climate mode
1148 if ((this->mode != CLIMATE_MODE_FAN_ONLY) && (this->mode != CLIMATE_MODE_OFF) &&
1149 ((((uint8_t) this->quiet_mode_state_) & 0b10) == 0)) {
1150 // In proper mode and not in pending state
1151 bool new_quiet_mode = packet.control.quiet_mode != 0;
1152 if (new_quiet_mode != this->get_quiet_mode_state()) {
1153 this->quiet_mode_state_ = new_quiet_mode ? SwitchState::SWITCH_ON : SwitchState::SWITCH_OFF;
1154 this->settings_.quiet_mode_state = new_quiet_mode;
1155#ifdef USE_SWITCH
1156 PUBLISH_STATE(this->quiet_mode_switch_, new_quiet_mode);
1157#endif // USE_SWITCH
1158 this->hon_rtc_.save(&this->settings_);
1159 }
1160 }
1161 }
1162 {
1163 // Swing mode
1164 ClimateSwingMode old_swing_mode = this->swing_mode;
1165 const auto &swing_modes = traits_.get_supported_swing_modes();
1166 bool vertical_swing_supported = swing_modes.count(CLIMATE_SWING_VERTICAL);
1167 bool horizontal_swing_supported = swing_modes.count(CLIMATE_SWING_HORIZONTAL);
1168 if (horizontal_swing_supported &&
1169 (packet.control.horizontal_swing_mode == (uint8_t) hon_protocol::HorizontalSwingMode::AUTO)) {
1170 if (vertical_swing_supported &&
1171 (packet.control.vertical_swing_mode == (uint8_t) hon_protocol::VerticalSwingMode::AUTO)) {
1172 this->swing_mode = CLIMATE_SWING_BOTH;
1173 } else {
1174 this->swing_mode = CLIMATE_SWING_HORIZONTAL;
1175 }
1176 } else {
1177 if (vertical_swing_supported &&
1178 (packet.control.vertical_swing_mode == (uint8_t) hon_protocol::VerticalSwingMode::AUTO)) {
1179 this->swing_mode = CLIMATE_SWING_VERTICAL;
1180 } else {
1181 this->swing_mode = CLIMATE_SWING_OFF;
1182 }
1183 }
1184 // Saving last known non auto mode for vertical and horizontal swing
1185 this->current_vertical_swing_ = (hon_protocol::VerticalSwingMode) packet.control.vertical_swing_mode;
1186 this->current_horizontal_swing_ = (hon_protocol::HorizontalSwingMode) packet.control.horizontal_swing_mode;
1188 bool save_vertical = !in_debounce(this->vertical_direction_set_time_, now_ms) &&
1189 !is_auto(this->current_vertical_swing_.value()) &&
1191 bool save_horizontal = !in_debounce(this->horizontal_direction_set_time_, now_ms) &&
1192 !is_auto(this->current_horizontal_swing_.value()) &&
1194 if (save_vertical || save_horizontal) {
1195 if (save_vertical) {
1197 }
1198 if (save_horizontal) {
1200 }
1201 this->hon_rtc_.save(&this->settings_);
1202 }
1203#ifdef USE_SELECT
1204 this->publish_airflow_selects_();
1205#endif
1206 should_publish = should_publish || (old_swing_mode != this->swing_mode);
1207 }
1208 this->last_valid_status_timestamp_ = std::chrono::steady_clock::now();
1209 if (should_publish) {
1210 this->publish_state();
1211 }
1212 if (should_publish) {
1213 ESP_LOGI(TAG, "HVAC values changed");
1214 }
1215 int log_level = should_publish ? ESPHOME_LOG_LEVEL_INFO : ESPHOME_LOG_LEVEL_DEBUG;
1216 esp_log_printf_(log_level, TAG, __LINE__, "HVAC Mode = 0x%X", packet.control.ac_mode);
1217 esp_log_printf_(log_level, TAG, __LINE__, "Fan speed Status = 0x%X", packet.control.fan_mode);
1218 esp_log_printf_(log_level, TAG, __LINE__, "Horizontal Swing Status = 0x%X", packet.control.horizontal_swing_mode);
1219 esp_log_printf_(log_level, TAG, __LINE__, "Vertical Swing Status = 0x%X", packet.control.vertical_swing_mode);
1220 esp_log_printf_(log_level, TAG, __LINE__, "Set Point Status = 0x%X", packet.control.set_point);
1221 return haier_protocol::HandlerError::HANDLER_OK;
1222}
1223
1225 if (!this->current_hvac_settings_.valid && !this->force_send_control_)
1226 return;
1228 HvacSettings climate_control;
1229 climate_control = this->current_hvac_settings_;
1230 // Beeper command
1231 {
1232 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1235 this->get_beeper_state() ? ZERO_BUF : ONE_BUF, 2);
1236 }
1237 // Health mode
1238 {
1239 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1242 this->get_health_mode() ? ONE_BUF : ZERO_BUF, 2);
1243 this->health_mode_ = (SwitchState) ((uint8_t) this->health_mode_ & 0b01);
1244 }
1245 // Climate mode
1246 ClimateMode climate_mode = this->mode;
1247 bool new_power = this->mode != CLIMATE_MODE_OFF;
1248 uint8_t fan_mode_buf[] = {0x00, 0xFF};
1249 uint8_t quiet_mode_buf[] = {0x00, 0xFF};
1250 if (climate_control.mode.has_value()) {
1251 climate_mode = climate_control.mode.value();
1252 uint8_t buffer[2] = {0x00, 0x00};
1253 switch (climate_control.mode.value()) {
1254 case CLIMATE_MODE_OFF:
1255 new_power = false;
1256 break;
1258 new_power = true;
1260 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1263 buffer, 2);
1264 fan_mode_buf[1] = this->other_modes_fan_speed_;
1265 break;
1266 case CLIMATE_MODE_HEAT:
1267 new_power = true;
1269 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1272 buffer, 2);
1273 fan_mode_buf[1] = this->other_modes_fan_speed_;
1274 break;
1275 case CLIMATE_MODE_DRY:
1276 new_power = true;
1278 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1281 buffer, 2);
1282 fan_mode_buf[1] = this->other_modes_fan_speed_;
1283 break;
1285 new_power = true;
1287 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1290 buffer, 2);
1291 fan_mode_buf[1] = this->other_modes_fan_speed_; // Auto doesn't work in fan only mode
1292 break;
1293 case CLIMATE_MODE_COOL:
1294 new_power = true;
1296 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1299 buffer, 2);
1300 fan_mode_buf[1] = this->other_modes_fan_speed_;
1301 break;
1302 default:
1303 ESP_LOGE("Control", "Unsupported climate mode");
1304 break;
1305 }
1306 }
1307 // Climate power
1308 {
1309 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1312 new_power ? ONE_BUF : ZERO_BUF, 2);
1313 }
1314 // CLimate preset
1315 {
1316 uint8_t fast_mode_buf[] = {0x00, 0xFF};
1317 uint8_t away_mode_buf[] = {0x00, 0xFF};
1318 if (!new_power) {
1319 // If AC is off - no presets allowed
1320 fast_mode_buf[1] = 0x00;
1321 away_mode_buf[1] = 0x00;
1322 } else if (climate_control.preset.has_value()) {
1323 switch (climate_control.preset.value()) {
1325 fast_mode_buf[1] = 0x00;
1326 away_mode_buf[1] = 0x00;
1327 break;
1329 // Boost is not supported in Fan only mode
1330 fast_mode_buf[1] = (this->mode != CLIMATE_MODE_FAN_ONLY) ? 0x01 : 0x00;
1331 away_mode_buf[1] = 0x00;
1332 break;
1334 fast_mode_buf[1] = 0x00;
1335 away_mode_buf[1] = (this->mode == CLIMATE_MODE_HEAT) ? 0x01 : 0x00;
1336 break;
1337 default:
1338 ESP_LOGE("Control", "Unsupported preset");
1339 break;
1340 }
1341 }
1342 {
1343 // Quiet mode
1344 if (new_power && (climate_mode != CLIMATE_MODE_FAN_ONLY) && this->get_quiet_mode_state()) {
1345 quiet_mode_buf[1] = 0x01;
1346 } else {
1347 quiet_mode_buf[1] = 0x00;
1348 }
1349 // Clean quiet mode state pending flag
1350 this->quiet_mode_state_ = (SwitchState) ((uint8_t) this->quiet_mode_state_ & 0b01);
1351 }
1352 auto presets = this->traits_.get_supported_presets();
1353 if (quiet_mode_buf[1] != 0xFF) {
1354 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1357 quiet_mode_buf, 2);
1358 }
1359 if ((fast_mode_buf[1] != 0xFF) && presets.count(climate::ClimatePreset::CLIMATE_PRESET_BOOST)) {
1360 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1363 fast_mode_buf, 2);
1364 }
1365 if ((away_mode_buf[1] != 0xFF) && presets.count(climate::ClimatePreset::CLIMATE_PRESET_AWAY)) {
1366 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1369 away_mode_buf, 2);
1370 }
1371 }
1372 // Target temperature
1373 if (climate_control.target_temperature.has_value() && (this->mode != ClimateMode::CLIMATE_MODE_FAN_ONLY)) {
1374 uint8_t buffer[2] = {0x00, 0x00};
1375 buffer[1] = ((uint8_t) climate_control.target_temperature.value()) - 16;
1376 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1379 buffer, 2);
1380 }
1381 ClimateSwingMode target_swing_mode = this->swing_mode;
1382 // Vertical swing mode
1383 if (climate_control.swing_mode.has_value()) {
1384 target_swing_mode = climate_control.swing_mode.value();
1385 uint8_t vertical_swing_buf[] = {0x00, (uint8_t) hon_protocol::VerticalSwingMode::AUTO};
1386 uint8_t horizontal_swing_buf[] = {0x00, (uint8_t) hon_protocol::HorizontalSwingMode::AUTO};
1387 switch (climate_control.swing_mode.value()) {
1388 case CLIMATE_SWING_OFF:
1389 horizontal_swing_buf[1] = (uint8_t) this->settings_.last_horizontal_swing;
1390 vertical_swing_buf[1] = (uint8_t) this->settings_.last_vertiacal_swing;
1391 break;
1393 horizontal_swing_buf[1] = (uint8_t) this->settings_.last_horizontal_swing;
1394 break;
1396 vertical_swing_buf[1] = (uint8_t) this->settings_.last_vertiacal_swing;
1397 break;
1398 case CLIMATE_SWING_BOTH:
1399 break;
1400 }
1401 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1404 horizontal_swing_buf, 2);
1405 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1408 vertical_swing_buf, 2);
1409 }
1410 // A swing change above already sent both axes from settings_.last_*, which set_*_airflow() updated
1411 const bool swing_sent = climate_control.swing_mode.has_value();
1412 if (this->pending_vertical_direction_.has_value()) {
1413 if (vertical_axis_is_auto(target_swing_mode)) {
1414 ESP_LOGD(TAG, "Vertical swing is on; the position is kept for when it is turned off");
1415 } else if (!swing_sent) {
1416 uint8_t vertical_swing_buf[] = {0x00, (uint8_t) this->pending_vertical_direction_.value()};
1417 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1420 vertical_swing_buf, 2);
1421 }
1422 this->pending_vertical_direction_.reset();
1423 }
1424 if (this->pending_horizontal_direction_.has_value()) {
1425 if (horizontal_axis_is_auto(target_swing_mode)) {
1426 ESP_LOGD(TAG, "Horizontal swing is on; the position is kept for when it is turned off");
1427 } else if (!swing_sent) {
1428 uint8_t horizontal_swing_buf[] = {0x00, (uint8_t) this->pending_horizontal_direction_.value()};
1429 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1432 horizontal_swing_buf, 2);
1433 }
1434 this->pending_horizontal_direction_.reset();
1435 }
1436 // Fan mode
1437 if (climate_control.fan_mode.has_value()) {
1438 switch (climate_control.fan_mode.value()) {
1439 case CLIMATE_FAN_LOW:
1440 fan_mode_buf[1] = (uint8_t) hon_protocol::FanMode::FAN_LOW;
1441 break;
1442 case CLIMATE_FAN_MEDIUM:
1443 fan_mode_buf[1] = (uint8_t) hon_protocol::FanMode::FAN_MID;
1444 break;
1445 case CLIMATE_FAN_HIGH:
1446 fan_mode_buf[1] = (uint8_t) hon_protocol::FanMode::FAN_HIGH;
1447 break;
1448 case CLIMATE_FAN_AUTO:
1449 if (mode != CLIMATE_MODE_FAN_ONLY) // if we are not in fan only mode
1450 fan_mode_buf[1] = (uint8_t) hon_protocol::FanMode::FAN_AUTO;
1451 break;
1452 default:
1453 ESP_LOGE("Control", "Unsupported fan mode");
1454 break;
1455 }
1456 if (fan_mode_buf[1] != 0xFF) {
1457 this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1460 fan_mode_buf, 2);
1461 }
1462 }
1463}
1464
1466 while (!this->control_messages_queue_.empty())
1467 this->control_messages_queue_.pop();
1468}
1469
1471 auto &action_request = this->action_request_.value(); // NOLINT(bugprone-unchecked-optional-access)
1472 switch (action_request.action) {
1475 uint8_t control_out_buffer[haier_protocol::MAX_FRAME_SIZE];
1476 memcpy(control_out_buffer, this->last_status_message_.get(), this->real_control_packet_size_);
1477 hon_protocol::HaierPacketControl *out_data = (hon_protocol::HaierPacketControl *) control_out_buffer;
1478 out_data->self_cleaning_status = 1;
1479 out_data->steri_clean = 0;
1480 out_data->set_point = 0x06;
1483 out_data->ac_power = 1;
1484 out_data->ac_mode = (uint8_t) hon_protocol::ConditioningMode::DRY;
1485 out_data->light_status = 0;
1486 action_request.message = haier_protocol::HaierMessage(
1487 haier_protocol::FrameType::CONTROL, (uint16_t) hon_protocol::SubcommandsControl::SET_GROUP_PARAMETERS,
1488 control_out_buffer, this->real_control_packet_size_);
1489 return true;
1491 action_request.message =
1492 haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1495 ONE_BUF, 2);
1496 return true;
1497 } else {
1498 this->action_request_.reset();
1499 return false;
1500 }
1503 uint8_t control_out_buffer[haier_protocol::MAX_FRAME_SIZE];
1504 memcpy(control_out_buffer, this->last_status_message_.get(), this->real_control_packet_size_);
1505 hon_protocol::HaierPacketControl *out_data = (hon_protocol::HaierPacketControl *) control_out_buffer;
1506 out_data->self_cleaning_status = 0;
1507 out_data->steri_clean = 1;
1508 out_data->set_point = 0x06;
1511 out_data->ac_power = 1;
1512 out_data->ac_mode = (uint8_t) hon_protocol::ConditioningMode::DRY;
1513 out_data->light_status = 0;
1514 action_request.message = haier_protocol::HaierMessage(
1515 haier_protocol::FrameType::CONTROL, (uint16_t) hon_protocol::SubcommandsControl::SET_GROUP_PARAMETERS,
1516 control_out_buffer, this->real_control_packet_size_);
1517 return true;
1518 } else {
1519 // No Steri clean support (yet?) in SET_SINGLE_PARAMETER
1520 this->action_request_.reset();
1521 return false;
1522 }
1523 default:
1525 }
1526}
1527
1530#ifdef USE_SENSOR
1531 for (auto &sub_sensor : this->sub_sensors_) {
1532 if ((sub_sensor != nullptr) && sub_sensor->has_state())
1533 sub_sensor->publish_state(NAN);
1534 }
1535#endif // USE_SENSOR
1536 this->got_valid_outdoor_temp_ = false;
1537 this->hvac_hardware_info_.reset();
1538 this->last_status_message_.reset(nullptr);
1539}
1540
1542 if (this->big_data_sensors_ > 0) {
1543 this->big_data_counter_ = (this->big_data_counter_ + 1) % 3;
1544 return this->big_data_counter_ == 1;
1545 }
1546 return false;
1547}
1548
1549} // namespace esphome::haier
BedjetMode mode
BedJet operating mode.
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
ESPPreferenceObject make_entity_preference(uint32_t version=0)
Create a preference object for storing this entity's state/settings.
bool has_state() const
constexpr size_t count(ValueType value) const
Check if the set contains a specific value (std::set compatibility) Returns 1 if present,...
Base class for all binary_sensor-type classes.
void publish_state(bool new_state)
Publish a new state to the front-end.
ClimateMode mode
The active mode of the climate device.
Definition climate.h:317
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
Definition climate.h:311
float target_temperature
The target temperature of the climate device.
Definition climate.h:298
ClimateSwingMode swing_mode
The active swing mode of the climate device.
Definition climate.h:323
float current_temperature
The current temperature of the climate device, as reported from the integration.
Definition climate.h:291
void publish_state()
Publish the state of the climate device, to be called from integrations.
Definition climate.cpp:432
optional< ClimatePreset > preset
The active preset of the climate device.
Definition climate.h:314
const ClimatePresetMask & get_supported_presets() const
const ClimateSwingModeMask & get_supported_swing_modes() const
const LogString * phase_to_string_(ProtocolPhases phase)
esphome::climate::ClimateTraits traits_
Definition haier_base.h:167
bool is_message_interval_exceeded_(std::chrono::steady_clock::time_point now)
CallbackManager< void(const char *, size_t)> status_message_callback_
Definition haier_base.h:175
bool is_protocol_initialisation_interval_exceeded_(std::chrono::steady_clock::time_point now)
bool is_status_request_interval_exceeded_(std::chrono::steady_clock::time_point now)
haier_protocol::HandlerError answer_preprocess_(haier_protocol::FrameType request_message_type, haier_protocol::FrameType expected_request_message_type, haier_protocol::FrameType answer_message_type, haier_protocol::FrameType expected_answer_message_type, ProtocolPhases expected_phase)
haier_protocol::ProtocolHandler haier_protocol_
Definition haier_base.h:155
std::unique_ptr< uint8_t[]> last_status_message_
Definition haier_base.h:170
void send_message_(const haier_protocol::HaierMessage &command, bool use_crc, uint8_t num_repeats=0, std::chrono::milliseconds interval=std::chrono::milliseconds::zero())
haier_protocol::HandlerError report_network_status_answer_handler_(haier_protocol::FrameType request_type, haier_protocol::FrameType message_type, const uint8_t *data, size_t data_size)
void control(const esphome::climate::ClimateCall &call) override
std::chrono::steady_clock::time_point last_valid_status_timestamp_
Definition haier_base.h:172
haier_protocol::HaierMessage get_wifi_signal_message_()
bool is_control_message_interval_exceeded_(std::chrono::steady_clock::time_point now)
esphome::optional< PendingAction > action_request_
Definition haier_base.h:157
std::chrono::steady_clock::time_point last_status_request_
Definition haier_base.h:173
virtual void set_phase(ProtocolPhases phase)
std::chrono::steady_clock::time_point last_signal_request_
Definition haier_base.h:174
void set_quiet_mode_switch(switch_::Switch *sw)
esphome::optional< hon_protocol::VerticalSwingMode > get_vertical_airflow() const
ESPPreferenceObject hon_rtc_
void set_sub_text_sensor(SubTextSensorType type, text_sensor::TextSensor *sens)
haier_protocol::HandlerError status_handler_(haier_protocol::FrameType request_type, haier_protocol::FrameType message_type, const uint8_t *data, size_t data_size)
HonControlMethod control_method_
void initialization() override
haier_protocol::HandlerError get_device_id_answer_handler_(haier_protocol::FrameType request_type, haier_protocol::FrameType message_type, const uint8_t *data, size_t data_size)
CallbackManager< void(uint8_t, const char *)> alarm_end_callback_
esphome::optional< HardwareInfo > hvac_hardware_info_
void set_sub_sensor(SubSensorType type, sensor::Sensor *sens)
CallbackManager< void(uint8_t, const char *)> alarm_start_callback_
void update_sub_sensor_(SubSensorType type, float value)
void set_sub_binary_sensor(SubBinarySensorType type, binary_sensor::BinarySensor *sens)
haier_protocol::HaierMessage get_power_message(bool state) override
text_sensor::TextSensor * sub_text_sensors_[(size_t) SubTextSensorType::SUB_TEXT_SENSOR_TYPE_COUNT]
haier_protocol::HandlerError get_alarm_status_answer_handler_(haier_protocol::FrameType request_type, haier_protocol::FrameType message_type, const uint8_t *data, size_t data_size)
switch_::Switch * beeper_switch_
std::chrono::steady_clock::time_point last_alarm_request_
sensor::Sensor * sub_sensors_[(size_t) SubSensorType::SUB_SENSOR_TYPE_COUNT]
Definition hon_climate.h:87
void set_beeper_state(bool state)
void set_horizontal_airflow(hon_protocol::HorizontalSwingMode direction)
haier_protocol::HandlerError process_status_message_(const uint8_t *packet, uint8_t size)
void set_vertical_airflow(hon_protocol::VerticalSwingMode direction)
CleaningState cleaning_status_
haier_protocol::HandlerError get_management_information_answer_handler_(haier_protocol::FrameType request_type, haier_protocol::FrameType message_type, const uint8_t *data, size_t data_size)
std::queue< haier_protocol::HaierMessage > control_messages_queue_
esphome::optional< hon_protocol::HorizontalSwingMode > current_horizontal_swing_
void set_quiet_mode_state(bool state)
uint32_t horizontal_direction_set_time_
haier_protocol::HandlerError get_device_version_answer_handler_(haier_protocol::FrameType request_type, haier_protocol::FrameType message_type, const uint8_t *data, size_t data_size)
binary_sensor::BinarySensor * sub_binary_sensors_[(size_t) SubBinarySensorType::SUB_BINARY_SENSOR_TYPE_COUNT]
haier_protocol::HandlerError alarm_status_message_handler_(haier_protocol::FrameType type, const uint8_t *buffer, size_t size)
const char * get_cleaning_status_text() const
void update_sub_binary_sensor_(SubBinarySensorType type, uint8_t value)
haier_protocol::HaierMessage get_control_message() override
void process_phase(std::chrono::steady_clock::time_point now) override
esphome::optional< hon_protocol::HorizontalSwingMode > pending_horizontal_direction_
static constexpr size_t HARDWARE_INFO_STR_SIZE
switch_::Switch * quiet_mode_switch_
void process_protocol_reset() override
CleaningState get_cleaning_status() const
esphome::optional< hon_protocol::HorizontalSwingMode > get_horizontal_airflow() const
void set_beeper_switch(switch_::Switch *sw)
esphome::optional< hon_protocol::VerticalSwingMode > current_vertical_swing_
void update_sub_text_sensor_(SubTextSensorType type, const char *value)
void process_alarm_message_(const uint8_t *packet, uint8_t size, bool check_new)
bool prepare_pending_action() override
esphome::optional< hon_protocol::VerticalSwingMode > pending_vertical_direction_
Base-class for all selects.
Definition select.h:28
optional< size_t > active_index() const
Return the (optional) index offset of the currently active option.
Definition select.cpp:45
void publish_state(const std::string &state)
Definition select.h:35
Base-class for all sensors.
Definition sensor.h:48
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:65
Base class for all switches.
Definition switch.h:43
void publish_state(const std::string &state)
Definition text_sensor.h:42
ClimateSwingMode swing_mode
Definition climate.h:11
uint8_t type
FanDirection direction
Definition fan.h:5
bool state
Definition fan.h:2
unsigned count
Definition gif.cpp:51
uint32_t buffer
Definition gif.cpp:50
@ CLIMATE_PRESET_NONE
No preset is active.
@ CLIMATE_PRESET_AWAY
Device is in away preset.
@ CLIMATE_PRESET_BOOST
Device is in boost preset.
@ CLIMATE_PRESET_SLEEP
Device is prepared for sleep.
ClimateSwingMode
Enum for all modes a climate swing can be in NOTE: If adding values, update ClimateSwingModeMask in c...
@ CLIMATE_SWING_OFF
The swing mode is set to Off.
@ CLIMATE_SWING_HORIZONTAL
The fan mode is set to Horizontal.
@ CLIMATE_SWING_VERTICAL
The fan mode is set to Vertical.
@ CLIMATE_SWING_BOTH
The fan mode is set to Both.
ClimateMode
Enum for all modes a climate device can be in.
@ CLIMATE_MODE_DRY
The climate device is set to dry/humidity mode.
@ CLIMATE_MODE_FAN_ONLY
The climate device only has the fan enabled, no heating or cooling is taking place.
@ CLIMATE_MODE_HEAT
The climate device is set to heat to reach the target temperature.
@ CLIMATE_MODE_COOL
The climate device is set to cool to reach the target temperature.
@ CLIMATE_MODE_HEAT_COOL
The climate device is set to heat/cool to reach the target temperature.
@ CLIMATE_MODE_OFF
The climate device is off.
@ CLIMATE_FAN_MEDIUM
The fan mode is set to Medium.
@ CLIMATE_FAN_ON
The fan mode is set to On.
@ CLIMATE_FAN_AUTO
The fan mode is set to Auto.
@ CLIMATE_FAN_LOW
The fan mode is set to Low.
@ CLIMATE_FAN_HIGH
The fan mode is set to High.
Mode airflow_order_at(const std::array< Mode, N > &order, size_t index)
Definition hon_climate.h:42
constexpr uint8_t CONTROL_MESSAGE_RETRIES
constexpr size_t ALARM_STATUS_REQUEST_INTERVAL_MS
constexpr std::chrono::milliseconds CONTROL_MESSAGE_RETRIES_INTERVAL
constexpr uint32_t AIRFLOW_SELECT_DEBOUNCE_MS
constexpr int PROTOCOL_OUTDOOR_TEMPERATURE_OFFSET
const uint8_t ZERO_BUF[]
ESPHOME_LOG_TAG(TAG, "haier.climate")
PROGMEM_STRING_TABLE(ProtocolPhaseStrings, "SENDING_INIT_1", "SENDING_INIT_2", "SENDING_FIRST_STATUS_REQUEST", "SENDING_FIRST_ALARM_STATUS_REQUEST", "IDLE", "SENDING_STATUS_REQUEST", "SENDING_UPDATE_SIGNAL_REQUEST", "SENDING_SIGNAL_LEVEL", "SENDING_CONTROL", "SENDING_ACTION_COMMAND", "SENDING_ALARM_STATUS_REQUEST", "UNKNOWN")
const uint8_t ONE_BUF[]
constexpr size_t SIGNAL_LEVEL_UPDATE_INTERVAL_MS
void HOT esp_log_printf_(int level, const char *tag, int line, const char *format,...)
Definition log.cpp:21
uint32_t value
Definition hal.cpp:41
uint16_t size
Definition helpers.cpp:34
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
Definition helpers.h:1043
Application App
Global storage of Application pointer - only one Application can exist.
static void uint32_t
esphome::optional< esphome::climate::ClimateFanMode > fan_mode
Definition haier_base.h:135
esphome::optional< esphome::climate::ClimateSwingMode > swing_mode
Definition haier_base.h:136
esphome::optional< esphome::climate::ClimateMode > mode
Definition haier_base.h:134
esphome::optional< esphome::climate::ClimatePreset > preset
Definition haier_base.h:138
esphome::optional< float > target_temperature
Definition haier_base.h:137
hon_protocol::HorizontalSwingMode last_horizontal_swing
Definition hon_climate.h:58
hon_protocol::VerticalSwingMode last_vertiacal_swing
Definition hon_climate.h:57