esphome 2024.11.3__py3-none-any.whl → 2024.12.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. esphome/components/adc/adc_sensor.h +7 -8
  2. esphome/components/adc/adc_sensor_common.cpp +24 -0
  3. esphome/components/adc/{adc_sensor.cpp → adc_sensor_esp32.cpp} +10 -179
  4. esphome/components/adc/adc_sensor_esp8266.cpp +58 -0
  5. esphome/components/adc/adc_sensor_libretiny.cpp +48 -0
  6. esphome/components/adc/adc_sensor_rp2040.cpp +93 -0
  7. esphome/components/alarm_control_panel/alarm_control_panel_call.cpp +3 -4
  8. esphome/components/animation/__init__.py +1 -2
  9. esphome/components/apds9306/apds9306.cpp +2 -1
  10. esphome/components/audio/audio.h +1 -1
  11. esphome/components/bk72xx/__init__.py +1 -1
  12. esphome/components/cse7766/cse7766.cpp +1 -1
  13. esphome/components/deep_sleep/deep_sleep_esp32.cpp +2 -2
  14. esphome/components/dht/dht.cpp +2 -1
  15. esphome/components/display/display.cpp +10 -6
  16. esphome/components/display/display.h +14 -0
  17. esphome/components/display_menu_base/__init__.py +0 -2
  18. esphome/components/display_menu_base/display_menu_base.cpp +1 -1
  19. esphome/components/dsmr/dsmr.cpp +1 -1
  20. esphome/components/esp32/__init__.py +94 -12
  21. esphome/components/esp32/boards.py +222 -14
  22. esphome/components/esp32_ble/__init__.py +22 -2
  23. esphome/components/esp32_ble/ble.cpp +39 -12
  24. esphome/components/esp32_ble/ble.h +2 -0
  25. esphome/components/esp32_ble/ble_advertising.cpp +1 -1
  26. esphome/components/esp32_ble/ble_uuid.cpp +9 -10
  27. esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +4 -1
  28. esphome/components/esp32_camera_web_server/camera_web_server.h +1 -1
  29. esphome/components/esp32_rmt_led_strip/light.py +3 -3
  30. esphome/components/esp8266/__init__.py +5 -7
  31. esphome/components/ezo/ezo.cpp +14 -26
  32. esphome/components/font/__init__.py +10 -25
  33. esphome/components/font/font.cpp +5 -3
  34. esphome/components/graphical_display_menu/__init__.py +2 -0
  35. esphome/components/haier/hon_climate.cpp +79 -80
  36. esphome/components/hbridge/switch/__init__.py +44 -0
  37. esphome/components/hbridge/switch/hbridge_switch.cpp +95 -0
  38. esphome/components/hbridge/switch/hbridge_switch.h +50 -0
  39. esphome/components/hitachi_ac344/hitachi_ac344.cpp +4 -2
  40. esphome/components/hitachi_ac424/hitachi_ac424.cpp +4 -2
  41. esphome/components/homeassistant/number/homeassistant_number.cpp +3 -0
  42. esphome/components/hx711/hx711.cpp +1 -1
  43. esphome/components/hx711/hx711.h +1 -1
  44. esphome/components/i2c/i2c_bus_esp_idf.cpp +2 -2
  45. esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +61 -59
  46. esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +8 -17
  47. esphome/components/ili9xxx/display.py +1 -2
  48. esphome/components/ili9xxx/ili9xxx_display.cpp +3 -2
  49. esphome/components/image/__init__.py +1 -2
  50. esphome/components/logger/logger.cpp +1 -1
  51. esphome/components/ltr501/ltr501.cpp +1 -1
  52. esphome/components/lvgl/defines.py +8 -1
  53. esphome/components/lvgl/lv_validation.py +8 -3
  54. esphome/components/lvgl/lvgl_esphome.cpp +1 -1
  55. esphome/components/lvgl/lvgl_esphome.h +16 -0
  56. esphome/components/lvgl/widgets/animimg.py +12 -17
  57. esphome/components/lvgl/widgets/img.py +1 -3
  58. esphome/components/matrix_keypad/__init__.py +15 -3
  59. esphome/components/matrix_keypad/matrix_keypad.cpp +4 -0
  60. esphome/components/matrix_keypad/matrix_keypad.h +5 -0
  61. esphome/components/max31865/max31865.cpp +4 -2
  62. esphome/components/modbus_controller/modbus_controller.cpp +24 -24
  63. esphome/components/modbus_controller/modbus_controller.h +22 -22
  64. esphome/components/modbus_controller/number/modbus_number.cpp +8 -8
  65. esphome/components/modbus_controller/number/modbus_number.h +4 -4
  66. esphome/components/modbus_controller/output/modbus_output.cpp +7 -6
  67. esphome/components/modbus_controller/output/modbus_output.h +5 -5
  68. esphome/components/modbus_controller/select/modbus_select.cpp +4 -3
  69. esphome/components/modbus_controller/select/modbus_select.h +4 -4
  70. esphome/components/modbus_controller/switch/modbus_switch.cpp +5 -5
  71. esphome/components/modbus_controller/switch/modbus_switch.h +2 -2
  72. esphome/components/mqtt/__init__.py +4 -0
  73. esphome/components/mqtt/mqtt_alarm_control_panel.cpp +2 -5
  74. esphome/components/mqtt/mqtt_backend_esp32.cpp +3 -3
  75. esphome/components/mqtt/mqtt_client.cpp +4 -0
  76. esphome/components/mqtt/mqtt_client.h +6 -0
  77. esphome/components/mqtt/mqtt_climate.cpp +13 -3
  78. esphome/components/mqtt/mqtt_sensor.cpp +2 -0
  79. esphome/components/network/ip_address.h +1 -1
  80. esphome/components/nextion/__init__.py +2 -0
  81. esphome/components/nextion/automation.h +76 -0
  82. esphome/components/nextion/base_component.py +1 -0
  83. esphome/components/nextion/binary_sensor/__init__.py +43 -2
  84. esphome/components/nextion/display.py +15 -0
  85. esphome/components/nextion/nextion.cpp +8 -5
  86. esphome/components/nextion/nextion.h +7 -0
  87. esphome/components/nextion/nextion_upload_idf.cpp +2 -2
  88. esphome/components/nextion/sensor/__init__.py +38 -5
  89. esphome/components/nextion/switch/__init__.py +38 -2
  90. esphome/components/nextion/text_sensor/__init__.py +37 -2
  91. esphome/components/nfc/ndef_record.cpp +3 -3
  92. esphome/components/online_image/__init__.py +1 -0
  93. esphome/components/opentherm/opentherm.cpp +3 -3
  94. esphome/components/opentherm/opentherm.h +1 -1
  95. esphome/components/ota/automation.h +1 -1
  96. esphome/components/output/float_output.cpp +1 -1
  97. esphome/components/pca6416a/pca6416a.cpp +5 -3
  98. esphome/components/pca9554/pca9554.cpp +4 -4
  99. esphome/components/pipsolar/pipsolar.cpp +2 -2
  100. esphome/components/pipsolar/switch/pipsolar_switch.cpp +2 -2
  101. esphome/components/pn532/pn532_mifare_ultralight.cpp +2 -2
  102. esphome/components/pn7150/pn7150_mifare_ultralight.cpp +2 -2
  103. esphome/components/pn7160/pn7160_mifare_ultralight.cpp +2 -2
  104. esphome/components/qmc5883l/qmc5883l.cpp +45 -19
  105. esphome/components/qmc5883l/qmc5883l.h +1 -1
  106. esphome/components/qspi_dbi/qspi_dbi.cpp +2 -1
  107. esphome/components/remote_base/raw_protocol.cpp +1 -1
  108. esphome/components/remote_receiver/__init__.py +5 -6
  109. esphome/components/rotary_encoder/rotary_encoder.cpp +3 -1
  110. esphome/components/rp2040/__init__.py +1 -1
  111. esphome/components/rtl87xx/__init__.py +1 -1
  112. esphome/components/safe_mode/automation.h +1 -1
  113. esphome/components/seeed_mr60bha2/__init__.py +41 -0
  114. esphome/components/seeed_mr60bha2/seeed_mr60bha2.cpp +173 -0
  115. esphome/components/seeed_mr60bha2/seeed_mr60bha2.h +61 -0
  116. esphome/components/seeed_mr60bha2/sensor.py +57 -0
  117. esphome/components/seeed_mr60fda2/__init__.py +41 -0
  118. esphome/components/seeed_mr60fda2/binary_sensor.py +33 -0
  119. esphome/components/seeed_mr60fda2/button/__init__.py +45 -0
  120. esphome/components/seeed_mr60fda2/button/get_radar_parameters_button.cpp +9 -0
  121. esphome/components/seeed_mr60fda2/button/get_radar_parameters_button.h +18 -0
  122. esphome/components/seeed_mr60fda2/button/reset_radar_button.cpp +9 -0
  123. esphome/components/seeed_mr60fda2/button/reset_radar_button.h +18 -0
  124. esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp +368 -0
  125. esphome/components/seeed_mr60fda2/seeed_mr60fda2.h +101 -0
  126. esphome/components/seeed_mr60fda2/select/__init__.py +59 -0
  127. esphome/components/seeed_mr60fda2/select/height_threshold_select.cpp +15 -0
  128. esphome/components/seeed_mr60fda2/select/height_threshold_select.h +18 -0
  129. esphome/components/seeed_mr60fda2/select/install_height_select.cpp +15 -0
  130. esphome/components/seeed_mr60fda2/select/install_height_select.h +18 -0
  131. esphome/components/seeed_mr60fda2/select/sensitivity_select.cpp +15 -0
  132. esphome/components/seeed_mr60fda2/select/sensitivity_select.h +18 -0
  133. esphome/components/sen5x/sensor.py +5 -6
  134. esphome/components/sgp30/sensor.py +8 -9
  135. esphome/components/sgp30/sgp30.cpp +2 -6
  136. esphome/components/shelly_dimmer/shelly_dimmer.cpp +1 -1
  137. esphome/components/sim800l/sim800l.cpp +1 -1
  138. esphome/components/sntp/sntp_component.cpp +14 -20
  139. esphome/components/sntp/sntp_component.h +6 -9
  140. esphome/components/sntp/time.py +4 -7
  141. esphome/components/sprinkler/sprinkler.cpp +2 -2
  142. esphome/components/st7735/st7735.cpp +1 -1
  143. esphome/components/st7789v/st7789v.cpp +1 -1
  144. esphome/components/stepper/stepper.h +0 -1
  145. esphome/components/sun_gtil2/sun_gtil2.cpp +1 -1
  146. esphome/components/switch/binary_sensor/__init__.py +31 -0
  147. esphome/components/switch/binary_sensor/switch_binary_sensor.cpp +17 -0
  148. esphome/components/switch/binary_sensor/switch_binary_sensor.h +22 -0
  149. esphome/components/sx1509/sx1509_gpio_pin.cpp +2 -1
  150. esphome/components/sx1509/sx1509_gpio_pin.h +5 -5
  151. esphome/components/uart/uart.h +1 -1
  152. esphome/components/udp/udp_component.cpp +32 -16
  153. esphome/components/ufire_ec/sensor.py +4 -4
  154. esphome/components/uln2003/uln2003.cpp +4 -1
  155. esphome/components/waveshare_epaper/display.py +8 -0
  156. esphome/components/waveshare_epaper/waveshare_epaper.cpp +191 -0
  157. esphome/components/waveshare_epaper/waveshare_epaper.h +56 -0
  158. esphome/components/wiegand/__init__.py +3 -4
  159. esphome/components/wifi/__init__.py +42 -0
  160. esphome/components/wifi/wifi_component.cpp +2 -2
  161. esphome/components/wifi/wifi_component.h +82 -1
  162. esphome/components/wifi/wifi_component_esp32_arduino.cpp +1 -1
  163. esphome/components/wifi/wifi_component_esp8266.cpp +1 -1
  164. esphome/components/wifi/wifi_component_esp_idf.cpp +1 -1
  165. esphome/components/wifi/wifi_component_libretiny.cpp +1 -1
  166. esphome/components/wifi/wifi_component_pico_w.cpp +1 -1
  167. esphome/components/wireguard/wireguard.cpp +2 -2
  168. esphome/components/xiaomi_ble/xiaomi_ble.cpp +1 -1
  169. esphome/config_validation.py +15 -11
  170. esphome/const.py +11 -1
  171. esphome/core/component.cpp +1 -1
  172. esphome/core/config.py +1 -2
  173. esphome/core/defines.h +3 -1
  174. esphome/core/helpers.cpp +8 -2
  175. esphome/core/helpers.h +2 -1
  176. esphome/core/optional.h +2 -2
  177. esphome/dashboard/web_server.py +6 -0
  178. {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/METADATA +4 -4
  179. {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/RECORD +183 -153
  180. {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/LICENSE +0 -0
  181. {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/WHEEL +0 -0
  182. {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/entry_points.txt +0 -0
  183. {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/top_level.txt +0 -0
@@ -35,7 +35,9 @@ void HonClimate::set_beeper_state(bool state) {
35
35
  if (state != this->settings_.beeper_state) {
36
36
  this->settings_.beeper_state = state;
37
37
  #ifdef USE_SWITCH
38
- this->beeper_switch_->publish_state(state);
38
+ if (this->beeper_switch_ != nullptr) {
39
+ this->beeper_switch_->publish_state(state);
40
+ }
39
41
  #endif
40
42
  this->hon_rtc_.save(&this->settings_);
41
43
  }
@@ -45,10 +47,17 @@ bool HonClimate::get_beeper_state() const { return this->settings_.beeper_state;
45
47
 
46
48
  void HonClimate::set_quiet_mode_state(bool state) {
47
49
  if (state != this->get_quiet_mode_state()) {
48
- this->quiet_mode_state_ = state ? SwitchState::PENDING_ON : SwitchState::PENDING_OFF;
50
+ if ((this->mode != ClimateMode::CLIMATE_MODE_OFF) && (this->mode != ClimateMode::CLIMATE_MODE_FAN_ONLY)) {
51
+ this->quiet_mode_state_ = state ? SwitchState::PENDING_ON : SwitchState::PENDING_OFF;
52
+ this->force_send_control_ = true;
53
+ } else {
54
+ this->quiet_mode_state_ = state ? SwitchState::ON : SwitchState::OFF;
55
+ }
49
56
  this->settings_.quiet_mode_state = state;
50
57
  #ifdef USE_SWITCH
51
- this->quiet_mode_switch_->publish_state(state);
58
+ if (this->quiet_mode_switch_ != nullptr) {
59
+ this->quiet_mode_switch_->publish_state(state);
60
+ }
52
61
  #endif
53
62
  this->hon_rtc_.save(&this->settings_);
54
63
  }
@@ -509,7 +518,7 @@ void HonClimate::initialization() {
509
518
  }
510
519
  this->current_vertical_swing_ = this->settings_.last_vertiacal_swing;
511
520
  this->current_horizontal_swing_ = this->settings_.last_horizontal_swing;
512
- this->quiet_mode_state_ = this->settings_.quiet_mode_state ? SwitchState::PENDING_ON : SwitchState::PENDING_OFF;
521
+ this->quiet_mode_state_ = this->settings_.quiet_mode_state ? SwitchState::ON : SwitchState::OFF;
513
522
  }
514
523
 
515
524
  haier_protocol::HaierMessage HonClimate::get_control_message() {
@@ -932,7 +941,7 @@ haier_protocol::HandlerError HonClimate::process_status_message_(const uint8_t *
932
941
  if (this->mode == CLIMATE_MODE_OFF) {
933
942
  // AC just turned on from remote need to turn off display
934
943
  this->force_send_control_ = true;
935
- } else if ((((uint8_t) this->health_mode_) & 0b10) == 0) {
944
+ } else if ((((uint8_t) this->display_status_) & 0b10) == 0) {
936
945
  this->display_status_ = disp_status ? SwitchState::ON : SwitchState::OFF;
937
946
  }
938
947
  }
@@ -1004,6 +1013,11 @@ haier_protocol::HandlerError HonClimate::process_status_message_(const uint8_t *
1004
1013
  if (new_quiet_mode != this->get_quiet_mode_state()) {
1005
1014
  this->quiet_mode_state_ = new_quiet_mode ? SwitchState::ON : SwitchState::OFF;
1006
1015
  this->settings_.quiet_mode_state = new_quiet_mode;
1016
+ #ifdef USE_SWITCH
1017
+ if (this->quiet_mode_switch_ != nullptr) {
1018
+ this->quiet_mode_switch_->publish_state(new_quiet_mode);
1019
+ }
1020
+ #endif // USE_SWITCH
1007
1021
  this->hon_rtc_.save(&this->settings_);
1008
1022
  }
1009
1023
  }
@@ -1069,19 +1083,17 @@ void HonClimate::fill_control_messages_queue_() {
1069
1083
  climate_control = this->current_hvac_settings_;
1070
1084
  // Beeper command
1071
1085
  {
1072
- this->control_messages_queue_.push(
1073
- haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1074
- (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1075
- (uint8_t) hon_protocol::DataParameters::BEEPER_STATUS,
1076
- this->get_beeper_state() ? ZERO_BUF : ONE_BUF, 2));
1086
+ this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1087
+ (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1088
+ (uint8_t) hon_protocol::DataParameters::BEEPER_STATUS,
1089
+ this->get_beeper_state() ? ZERO_BUF : ONE_BUF, 2);
1077
1090
  }
1078
1091
  // Health mode
1079
1092
  {
1080
- this->control_messages_queue_.push(
1081
- haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1082
- (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1083
- (uint8_t) hon_protocol::DataParameters::HEALTH_MODE,
1084
- this->get_health_mode() ? ONE_BUF : ZERO_BUF, 2));
1093
+ this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1094
+ (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1095
+ (uint8_t) hon_protocol::DataParameters::HEALTH_MODE,
1096
+ this->get_health_mode() ? ONE_BUF : ZERO_BUF, 2);
1085
1097
  this->health_mode_ = (SwitchState) ((uint8_t) this->health_mode_ & 0b01);
1086
1098
  }
1087
1099
  // Climate mode
@@ -1099,51 +1111,46 @@ void HonClimate::fill_control_messages_queue_() {
1099
1111
  case CLIMATE_MODE_HEAT_COOL:
1100
1112
  new_power = true;
1101
1113
  buffer[1] = (uint8_t) hon_protocol::ConditioningMode::AUTO;
1102
- this->control_messages_queue_.push(
1103
- haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1104
- (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1105
- (uint8_t) hon_protocol::DataParameters::AC_MODE,
1106
- buffer, 2));
1114
+ this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1115
+ (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1116
+ (uint8_t) hon_protocol::DataParameters::AC_MODE,
1117
+ buffer, 2);
1107
1118
  fan_mode_buf[1] = this->other_modes_fan_speed_;
1108
1119
  break;
1109
1120
  case CLIMATE_MODE_HEAT:
1110
1121
  new_power = true;
1111
1122
  buffer[1] = (uint8_t) hon_protocol::ConditioningMode::HEAT;
1112
- this->control_messages_queue_.push(
1113
- haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1114
- (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1115
- (uint8_t) hon_protocol::DataParameters::AC_MODE,
1116
- buffer, 2));
1123
+ this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1124
+ (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1125
+ (uint8_t) hon_protocol::DataParameters::AC_MODE,
1126
+ buffer, 2);
1117
1127
  fan_mode_buf[1] = this->other_modes_fan_speed_;
1118
1128
  break;
1119
1129
  case CLIMATE_MODE_DRY:
1120
1130
  new_power = true;
1121
1131
  buffer[1] = (uint8_t) hon_protocol::ConditioningMode::DRY;
1122
- this->control_messages_queue_.push(
1123
- haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1124
- (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1125
- (uint8_t) hon_protocol::DataParameters::AC_MODE,
1126
- buffer, 2));
1132
+ this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1133
+ (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1134
+ (uint8_t) hon_protocol::DataParameters::AC_MODE,
1135
+ buffer, 2);
1127
1136
  fan_mode_buf[1] = this->other_modes_fan_speed_;
1128
1137
  break;
1129
1138
  case CLIMATE_MODE_FAN_ONLY:
1130
1139
  new_power = true;
1131
1140
  buffer[1] = (uint8_t) hon_protocol::ConditioningMode::FAN;
1132
- this->control_messages_queue_.push(
1133
- haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1134
- (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1135
- (uint8_t) hon_protocol::DataParameters::AC_MODE,
1136
- buffer, 2));
1141
+ this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1142
+ (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1143
+ (uint8_t) hon_protocol::DataParameters::AC_MODE,
1144
+ buffer, 2);
1137
1145
  fan_mode_buf[1] = this->other_modes_fan_speed_; // Auto doesn't work in fan only mode
1138
1146
  break;
1139
1147
  case CLIMATE_MODE_COOL:
1140
1148
  new_power = true;
1141
1149
  buffer[1] = (uint8_t) hon_protocol::ConditioningMode::COOL;
1142
- this->control_messages_queue_.push(
1143
- haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1144
- (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1145
- (uint8_t) hon_protocol::DataParameters::AC_MODE,
1146
- buffer, 2));
1150
+ this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1151
+ (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1152
+ (uint8_t) hon_protocol::DataParameters::AC_MODE,
1153
+ buffer, 2);
1147
1154
  fan_mode_buf[1] = this->other_modes_fan_speed_;
1148
1155
  break;
1149
1156
  default:
@@ -1153,11 +1160,10 @@ void HonClimate::fill_control_messages_queue_() {
1153
1160
  }
1154
1161
  // Climate power
1155
1162
  {
1156
- this->control_messages_queue_.push(
1157
- haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1158
- (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1159
- (uint8_t) hon_protocol::DataParameters::AC_POWER,
1160
- new_power ? ONE_BUF : ZERO_BUF, 2));
1163
+ this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1164
+ (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1165
+ (uint8_t) hon_protocol::DataParameters::AC_POWER,
1166
+ new_power ? ONE_BUF : ZERO_BUF, 2);
1161
1167
  }
1162
1168
  // CLimate preset
1163
1169
  {
@@ -1199,36 +1205,32 @@ void HonClimate::fill_control_messages_queue_() {
1199
1205
  }
1200
1206
  auto presets = this->traits_.get_supported_presets();
1201
1207
  if (quiet_mode_buf[1] != 0xFF) {
1202
- this->control_messages_queue_.push(
1203
- haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1204
- (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1205
- (uint8_t) hon_protocol::DataParameters::QUIET_MODE,
1206
- quiet_mode_buf, 2));
1208
+ this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1209
+ (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1210
+ (uint8_t) hon_protocol::DataParameters::QUIET_MODE,
1211
+ quiet_mode_buf, 2);
1207
1212
  }
1208
1213
  if ((fast_mode_buf[1] != 0xFF) && ((presets.find(climate::ClimatePreset::CLIMATE_PRESET_BOOST) != presets.end()))) {
1209
- this->control_messages_queue_.push(
1210
- haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1211
- (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1212
- (uint8_t) hon_protocol::DataParameters::FAST_MODE,
1213
- fast_mode_buf, 2));
1214
+ this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1215
+ (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1216
+ (uint8_t) hon_protocol::DataParameters::FAST_MODE,
1217
+ fast_mode_buf, 2);
1214
1218
  }
1215
1219
  if ((away_mode_buf[1] != 0xFF) && ((presets.find(climate::ClimatePreset::CLIMATE_PRESET_AWAY) != presets.end()))) {
1216
- this->control_messages_queue_.push(
1217
- haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1218
- (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1219
- (uint8_t) hon_protocol::DataParameters::TEN_DEGREE,
1220
- away_mode_buf, 2));
1220
+ this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1221
+ (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1222
+ (uint8_t) hon_protocol::DataParameters::TEN_DEGREE,
1223
+ away_mode_buf, 2);
1221
1224
  }
1222
1225
  }
1223
1226
  // Target temperature
1224
1227
  if (climate_control.target_temperature.has_value() && (this->mode != ClimateMode::CLIMATE_MODE_FAN_ONLY)) {
1225
1228
  uint8_t buffer[2] = {0x00, 0x00};
1226
1229
  buffer[1] = ((uint8_t) climate_control.target_temperature.value()) - 16;
1227
- this->control_messages_queue_.push(
1228
- haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1229
- (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1230
- (uint8_t) hon_protocol::DataParameters::SET_POINT,
1231
- buffer, 2));
1230
+ this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1231
+ (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1232
+ (uint8_t) hon_protocol::DataParameters::SET_POINT,
1233
+ buffer, 2);
1232
1234
  }
1233
1235
  // Vertical swing mode
1234
1236
  if (climate_control.swing_mode.has_value()) {
@@ -1248,16 +1250,14 @@ void HonClimate::fill_control_messages_queue_() {
1248
1250
  case CLIMATE_SWING_BOTH:
1249
1251
  break;
1250
1252
  }
1251
- this->control_messages_queue_.push(
1252
- haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1253
- (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1254
- (uint8_t) hon_protocol::DataParameters::HORIZONTAL_SWING_MODE,
1255
- horizontal_swing_buf, 2));
1256
- this->control_messages_queue_.push(
1257
- haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1258
- (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1259
- (uint8_t) hon_protocol::DataParameters::VERTICAL_SWING_MODE,
1260
- vertical_swing_buf, 2));
1253
+ this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1254
+ (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1255
+ (uint8_t) hon_protocol::DataParameters::HORIZONTAL_SWING_MODE,
1256
+ horizontal_swing_buf, 2);
1257
+ this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1258
+ (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1259
+ (uint8_t) hon_protocol::DataParameters::VERTICAL_SWING_MODE,
1260
+ vertical_swing_buf, 2);
1261
1261
  }
1262
1262
  // Fan mode
1263
1263
  if (climate_control.fan_mode.has_value()) {
@@ -1280,11 +1280,10 @@ void HonClimate::fill_control_messages_queue_() {
1280
1280
  break;
1281
1281
  }
1282
1282
  if (fan_mode_buf[1] != 0xFF) {
1283
- this->control_messages_queue_.push(
1284
- haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
1285
- (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1286
- (uint8_t) hon_protocol::DataParameters::FAN_MODE,
1287
- fan_mode_buf, 2));
1283
+ this->control_messages_queue_.emplace(haier_protocol::FrameType::CONTROL,
1284
+ (uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
1285
+ (uint8_t) hon_protocol::DataParameters::FAN_MODE,
1286
+ fan_mode_buf, 2);
1288
1287
  }
1289
1288
  }
1290
1289
  }
@@ -0,0 +1,44 @@
1
+ from esphome import pins
2
+ import esphome.codegen as cg
3
+ from esphome.components import switch
4
+ import esphome.config_validation as cv
5
+ from esphome.const import CONF_OPTIMISTIC, CONF_PULSE_LENGTH, CONF_WAIT_TIME
6
+
7
+ from .. import hbridge_ns
8
+
9
+ HBridgeSwitch = hbridge_ns.class_("HBridgeSwitch", switch.Switch, cg.Component)
10
+
11
+ CODEOWNERS = ["@dwmw2"]
12
+
13
+ CONF_OFF_PIN = "off_pin"
14
+ CONF_ON_PIN = "on_pin"
15
+
16
+ CONFIG_SCHEMA = (
17
+ switch.switch_schema(HBridgeSwitch)
18
+ .extend(
19
+ {
20
+ cv.Required(CONF_ON_PIN): pins.gpio_output_pin_schema,
21
+ cv.Required(CONF_OFF_PIN): pins.gpio_output_pin_schema,
22
+ cv.Optional(
23
+ CONF_PULSE_LENGTH, default="100ms"
24
+ ): cv.positive_time_period_milliseconds,
25
+ cv.Optional(CONF_WAIT_TIME): cv.positive_time_period_milliseconds,
26
+ cv.Optional(CONF_OPTIMISTIC, default=False): cv.boolean,
27
+ }
28
+ )
29
+ .extend(cv.COMPONENT_SCHEMA)
30
+ )
31
+
32
+
33
+ async def to_code(config):
34
+ var = await switch.new_switch(config)
35
+ await cg.register_component(var, config)
36
+
37
+ on_pin = await cg.gpio_pin_expression(config[CONF_ON_PIN])
38
+ cg.add(var.set_on_pin(on_pin))
39
+ off_pin = await cg.gpio_pin_expression(config[CONF_OFF_PIN])
40
+ cg.add(var.set_off_pin(off_pin))
41
+ cg.add(var.set_pulse_length(config[CONF_PULSE_LENGTH]))
42
+ cg.add(var.set_optimistic(config[CONF_OPTIMISTIC]))
43
+ if wait_time := config.get(CONF_WAIT_TIME):
44
+ cg.add(var.set_wait_time(wait_time))
@@ -0,0 +1,95 @@
1
+ #include "hbridge_switch.h"
2
+ #include "esphome/core/log.h"
3
+
4
+ #include <cinttypes>
5
+
6
+ namespace esphome {
7
+ namespace hbridge {
8
+
9
+ static const char *const TAG = "switch.hbridge";
10
+
11
+ float HBridgeSwitch::get_setup_priority() const { return setup_priority::HARDWARE; }
12
+ void HBridgeSwitch::setup() {
13
+ ESP_LOGCONFIG(TAG, "Setting up H-Bridge Switch '%s'...", this->name_.c_str());
14
+
15
+ optional<bool> initial_state = this->get_initial_state_with_restore_mode().value_or(false);
16
+
17
+ // Like GPIOSwitch does, set the pin state both before and after pin setup()
18
+ this->on_pin_->digital_write(false);
19
+ this->on_pin_->setup();
20
+ this->on_pin_->digital_write(false);
21
+
22
+ this->off_pin_->digital_write(false);
23
+ this->off_pin_->setup();
24
+ this->off_pin_->digital_write(false);
25
+
26
+ if (initial_state.has_value())
27
+ this->write_state(initial_state);
28
+ }
29
+
30
+ void HBridgeSwitch::dump_config() {
31
+ LOG_SWITCH("", "H-Bridge Switch", this);
32
+ LOG_PIN(" On Pin: ", this->on_pin_);
33
+ LOG_PIN(" Off Pin: ", this->off_pin_);
34
+ ESP_LOGCONFIG(TAG, " Pulse length: %" PRId32 " ms", this->pulse_length_);
35
+ if (this->wait_time_)
36
+ ESP_LOGCONFIG(TAG, " Wait time %" PRId32 " ms", this->wait_time_);
37
+ }
38
+
39
+ void HBridgeSwitch::write_state(bool state) {
40
+ this->desired_state_ = state;
41
+ if (!this->timer_running_)
42
+ this->timer_fn_();
43
+ }
44
+
45
+ void HBridgeSwitch::timer_fn_() {
46
+ uint32_t next_timeout = 0;
47
+
48
+ while ((uint8_t) this->desired_state_ != this->relay_state_) {
49
+ switch (this->relay_state_) {
50
+ case RELAY_STATE_ON:
51
+ case RELAY_STATE_OFF:
52
+ case RELAY_STATE_UNKNOWN:
53
+ if (this->desired_state_) {
54
+ this->on_pin_->digital_write(true);
55
+ this->relay_state_ = RELAY_STATE_SWITCHING_ON;
56
+ } else {
57
+ this->off_pin_->digital_write(true);
58
+ this->relay_state_ = RELAY_STATE_SWITCHING_OFF;
59
+ }
60
+ next_timeout = this->pulse_length_;
61
+ if (!this->optimistic_)
62
+ this->publish_state(this->desired_state_);
63
+ break;
64
+
65
+ case RELAY_STATE_SWITCHING_ON:
66
+ this->on_pin_->digital_write(false);
67
+ this->relay_state_ = RELAY_STATE_ON;
68
+ if (this->optimistic_)
69
+ this->publish_state(true);
70
+ next_timeout = this->wait_time_;
71
+ break;
72
+
73
+ case RELAY_STATE_SWITCHING_OFF:
74
+ this->off_pin_->digital_write(false);
75
+ this->relay_state_ = RELAY_STATE_OFF;
76
+ if (this->optimistic_)
77
+ this->publish_state(false);
78
+ next_timeout = this->wait_time_;
79
+ break;
80
+ }
81
+
82
+ if (next_timeout) {
83
+ this->timer_running_ = true;
84
+ this->set_timeout(next_timeout, [this]() { this->timer_fn_(); });
85
+ return;
86
+ }
87
+
88
+ // In the case where ON/OFF state has been reached but we need to
89
+ // immediately change back again to reach desired_state_, we loop.
90
+ }
91
+ this->timer_running_ = false;
92
+ }
93
+
94
+ } // namespace hbridge
95
+ } // namespace esphome
@@ -0,0 +1,50 @@
1
+ #pragma once
2
+
3
+ #include "esphome/core/component.h"
4
+ #include "esphome/core/hal.h"
5
+ #include "esphome/components/switch/switch.h"
6
+
7
+ #include <vector>
8
+
9
+ namespace esphome {
10
+ namespace hbridge {
11
+
12
+ enum RelayState : uint8_t {
13
+ RELAY_STATE_OFF = 0,
14
+ RELAY_STATE_ON = 1,
15
+ RELAY_STATE_SWITCHING_ON = 2,
16
+ RELAY_STATE_SWITCHING_OFF = 3,
17
+ RELAY_STATE_UNKNOWN = 4,
18
+ };
19
+
20
+ class HBridgeSwitch : public switch_::Switch, public Component {
21
+ public:
22
+ void set_on_pin(GPIOPin *pin) { this->on_pin_ = pin; }
23
+ void set_off_pin(GPIOPin *pin) { this->off_pin_ = pin; }
24
+ void set_pulse_length(uint32_t pulse_length) { this->pulse_length_ = pulse_length; }
25
+ void set_wait_time(uint32_t wait_time) { this->wait_time_ = wait_time; }
26
+ void set_optimistic(bool optimistic) { this->optimistic_ = optimistic; }
27
+
28
+ // ========== INTERNAL METHODS ==========
29
+ // (In most use cases you won't need these)
30
+ float get_setup_priority() const override;
31
+
32
+ void setup() override;
33
+ void dump_config() override;
34
+
35
+ protected:
36
+ void write_state(bool state) override;
37
+ void timer_fn_();
38
+
39
+ bool timer_running_{false};
40
+ bool desired_state_{false};
41
+ RelayState relay_state_{RELAY_STATE_UNKNOWN};
42
+ GPIOPin *on_pin_{nullptr};
43
+ GPIOPin *off_pin_{nullptr};
44
+ uint32_t pulse_length_{0};
45
+ uint32_t wait_time_{0};
46
+ bool optimistic_{false};
47
+ };
48
+
49
+ } // namespace hbridge
50
+ } // namespace esphome
@@ -133,8 +133,10 @@ bool HitachiClimate::get_swing_v_() {
133
133
  }
134
134
 
135
135
  void HitachiClimate::set_swing_h_(uint8_t position) {
136
- if (position > HITACHI_AC344_SWINGH_LEFT_MAX)
137
- return set_swing_h_(HITACHI_AC344_SWINGH_MIDDLE);
136
+ if (position > HITACHI_AC344_SWINGH_LEFT_MAX) {
137
+ set_swing_h_(HITACHI_AC344_SWINGH_MIDDLE);
138
+ return;
139
+ }
138
140
  set_bits(&remote_state_[HITACHI_AC344_SWINGH_BYTE], HITACHI_AC344_SWINGH_OFFSET, HITACHI_AC344_SWINGH_SIZE, position);
139
141
  set_button_(HITACHI_AC344_BUTTON_SWINGH);
140
142
  }
@@ -133,8 +133,10 @@ bool HitachiClimate::get_swing_v_() {
133
133
  }
134
134
 
135
135
  void HitachiClimate::set_swing_h_(uint8_t position) {
136
- if (position > HITACHI_AC424_SWINGH_LEFT_MAX)
137
- return set_swing_h_(HITACHI_AC424_SWINGH_MIDDLE);
136
+ if (position > HITACHI_AC424_SWINGH_LEFT_MAX) {
137
+ set_swing_h_(HITACHI_AC424_SWINGH_MIDDLE);
138
+ return;
139
+ }
138
140
  set_bits(&remote_state_[HITACHI_AC424_SWINGH_BYTE], HITACHI_AC424_SWINGH_OFFSET, HITACHI_AC424_SWINGH_SIZE, position);
139
141
  set_button_(HITACHI_AC424_BUTTON_SWINGH);
140
142
  }
@@ -27,6 +27,7 @@ void HomeassistantNumber::min_retrieved_(const std::string &min) {
27
27
  auto min_value = parse_number<float>(min);
28
28
  if (!min_value.has_value()) {
29
29
  ESP_LOGE(TAG, "'%s': Can't convert 'min' value '%s' to number!", this->entity_id_.c_str(), min.c_str());
30
+ return;
30
31
  }
31
32
  ESP_LOGD(TAG, "'%s': Min retrieved: %s", get_name().c_str(), min.c_str());
32
33
  this->traits.set_min_value(min_value.value());
@@ -36,6 +37,7 @@ void HomeassistantNumber::max_retrieved_(const std::string &max) {
36
37
  auto max_value = parse_number<float>(max);
37
38
  if (!max_value.has_value()) {
38
39
  ESP_LOGE(TAG, "'%s': Can't convert 'max' value '%s' to number!", this->entity_id_.c_str(), max.c_str());
40
+ return;
39
41
  }
40
42
  ESP_LOGD(TAG, "'%s': Max retrieved: %s", get_name().c_str(), max.c_str());
41
43
  this->traits.set_max_value(max_value.value());
@@ -45,6 +47,7 @@ void HomeassistantNumber::step_retrieved_(const std::string &step) {
45
47
  auto step_value = parse_number<float>(step);
46
48
  if (!step_value.has_value()) {
47
49
  ESP_LOGE(TAG, "'%s': Can't convert 'step' value '%s' to number!", this->entity_id_.c_str(), step.c_str());
50
+ return;
48
51
  }
49
52
  ESP_LOGD(TAG, "'%s': Step Retrieved %s", get_name().c_str(), step.c_str());
50
53
  this->traits.set_step(step_value.value());
@@ -53,7 +53,7 @@ bool HX711Sensor::read_sensor_(uint32_t *result) {
53
53
  }
54
54
 
55
55
  // Cycle clock pin for gain setting
56
- for (uint8_t i = 0; i < this->gain_; i++) {
56
+ for (uint8_t i = 0; i < static_cast<uint8_t>(this->gain_); i++) {
57
57
  this->sck_pin_->digital_write(true);
58
58
  delayMicroseconds(1);
59
59
  this->sck_pin_->digital_write(false);
@@ -9,7 +9,7 @@
9
9
  namespace esphome {
10
10
  namespace hx711 {
11
11
 
12
- enum HX711Gain {
12
+ enum HX711Gain : uint8_t {
13
13
  HX711_GAIN_128 = 1,
14
14
  HX711_GAIN_32 = 2,
15
15
  HX711_GAIN_64 = 3,
@@ -17,14 +17,14 @@ void IDFI2CBus::setup() {
17
17
  ESP_LOGCONFIG(TAG, "Setting up I2C bus...");
18
18
  static i2c_port_t next_port = I2C_NUM_0;
19
19
  port_ = next_port;
20
- #if I2C_NUM_MAX > 1
20
+ #if SOC_I2C_NUM > 1
21
21
  next_port = (next_port == I2C_NUM_0) ? I2C_NUM_1 : I2C_NUM_MAX;
22
22
  #else
23
23
  next_port = I2C_NUM_MAX;
24
24
  #endif
25
25
 
26
26
  if (port_ == I2C_NUM_MAX) {
27
- ESP_LOGE(TAG, "Too many I2C buses configured");
27
+ ESP_LOGE(TAG, "Too many I2C buses configured. Max %u supported.", SOC_I2C_NUM);
28
28
  this->mark_failed();
29
29
  return;
30
30
  }