esphome 2024.8.3__py3-none-any.whl → 2024.9.0b1__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 (198) hide show
  1. esphome/__main__.py +6 -2
  2. esphome/components/api/api_connection.cpp +19 -0
  3. esphome/components/api/api_connection.h +1 -0
  4. esphome/components/api/api_pb2.cpp +136 -0
  5. esphome/components/api/api_pb2.h +43 -0
  6. esphome/components/api/api_pb2_service.cpp +21 -0
  7. esphome/components/api/api_pb2_service.h +6 -0
  8. esphome/components/async_tcp/__init__.py +3 -3
  9. esphome/components/atm90e26/sensor.py +10 -10
  10. esphome/components/atm90e32/sensor.py +1 -1
  11. esphome/components/bl0906/__init__.py +1 -0
  12. esphome/components/bl0906/bl0906.cpp +238 -0
  13. esphome/components/bl0906/bl0906.h +96 -0
  14. esphome/components/bl0906/const.py +4 -0
  15. esphome/components/bl0906/constants.h +122 -0
  16. esphome/components/bl0906/sensor.py +184 -0
  17. esphome/components/bl0942/__init__.py +1 -1
  18. esphome/components/bl0942/bl0942.cpp +127 -34
  19. esphome/components/bl0942/bl0942.h +87 -3
  20. esphome/components/bl0942/sensor.py +46 -8
  21. esphome/components/ble_client/__init__.py +1 -3
  22. esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +5 -0
  23. esphome/components/bmp280/sensor.py +2 -93
  24. esphome/components/bmp280_base/__init__.py +88 -0
  25. esphome/components/{bmp280/bmp280.cpp → bmp280_base/bmp280_base.cpp} +11 -4
  26. esphome/components/{bmp280/bmp280.h → bmp280_base/bmp280_base.h} +9 -5
  27. esphome/components/bmp280_i2c/__init__.py +0 -0
  28. esphome/components/bmp280_i2c/bmp280_i2c.cpp +27 -0
  29. esphome/components/bmp280_i2c/bmp280_i2c.h +22 -0
  30. esphome/components/bmp280_i2c/sensor.py +22 -0
  31. esphome/components/bmp280_spi/__init__.py +0 -0
  32. esphome/components/bmp280_spi/bmp280_spi.cpp +65 -0
  33. esphome/components/bmp280_spi/bmp280_spi.h +20 -0
  34. esphome/components/bmp280_spi/sensor.py +22 -0
  35. esphome/components/captive_portal/captive_portal.cpp +2 -0
  36. esphome/components/captive_portal/captive_portal.h +3 -1
  37. esphome/components/ch422g/__init__.py +67 -0
  38. esphome/components/ch422g/ch422g.cpp +122 -0
  39. esphome/components/ch422g/ch422g.h +70 -0
  40. esphome/components/debug/debug_esp32.cpp +3 -1
  41. esphome/components/display/__init__.py +5 -4
  42. esphome/components/dsmr/dsmr.cpp +6 -0
  43. esphome/components/dsmr/dsmr.h +6 -0
  44. esphome/components/dsmr/text_sensor.py +7 -2
  45. esphome/components/e131/e131.cpp +2 -0
  46. esphome/components/e131/e131.h +3 -1
  47. esphome/components/e131/e131_addressable_light_effect.cpp +2 -0
  48. esphome/components/e131/e131_addressable_light_effect.h +2 -1
  49. esphome/components/e131/e131_packet.cpp +2 -0
  50. esphome/components/esp32_camera/__init__.py +4 -0
  51. esphome/components/esp32_camera/esp32_camera.cpp +9 -1
  52. esphome/components/esp32_camera/esp32_camera.h +3 -0
  53. esphome/components/esp32_can/canbus.py +18 -7
  54. esphome/components/esp32_can/esp32_can.cpp +8 -0
  55. esphome/components/esp32_can/esp32_can.h +4 -0
  56. esphome/components/esp32_rmt_led_strip/led_strip.cpp +14 -2
  57. esphome/components/esp32_rmt_led_strip/led_strip.h +3 -2
  58. esphome/components/esp32_rmt_led_strip/light.py +21 -4
  59. esphome/components/esphome/ota/ota_esphome.cpp +2 -1
  60. esphome/components/esphome/ota/ota_esphome.h +2 -0
  61. esphome/components/font/__init__.py +11 -22
  62. esphome/components/font/font.cpp +3 -2
  63. esphome/components/font/font.h +12 -3
  64. esphome/components/gree/climate.py +2 -1
  65. esphome/components/gree/gree.cpp +54 -3
  66. esphome/components/gree/gree.h +10 -2
  67. esphome/components/gt911/touchscreen/__init__.py +6 -4
  68. esphome/components/gt911/touchscreen/gt911_touchscreen.cpp +17 -0
  69. esphome/components/gt911/touchscreen/gt911_touchscreen.h +2 -0
  70. esphome/components/hmac_md5/__init__.py +2 -0
  71. esphome/components/hmac_md5/hmac_md5.cpp +56 -0
  72. esphome/components/hmac_md5/hmac_md5.h +48 -0
  73. esphome/components/homeassistant/__init__.py +13 -0
  74. esphome/components/homeassistant/switch/__init__.py +15 -2
  75. esphome/components/homeassistant/switch/homeassistant_switch.cpp +2 -2
  76. esphome/components/i2s_audio/__init__.py +88 -9
  77. esphome/components/i2s_audio/i2s_audio.h +20 -2
  78. esphome/components/i2s_audio/media_player/__init__.py +8 -4
  79. esphome/components/i2s_audio/media_player/i2s_audio_media_player.h +1 -1
  80. esphome/components/i2s_audio/microphone/__init__.py +19 -51
  81. esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp +18 -15
  82. esphome/components/i2s_audio/microphone/i2s_audio_microphone.h +0 -12
  83. esphome/components/i2s_audio/speaker/__init__.py +39 -27
  84. esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +49 -37
  85. esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +3 -4
  86. esphome/components/ili9xxx/display.py +16 -17
  87. esphome/components/ili9xxx/ili9xxx_display.cpp +1 -1
  88. esphome/components/ili9xxx/ili9xxx_display.h +18 -18
  89. esphome/components/ili9xxx/ili9xxx_init.h +0 -3
  90. esphome/components/improv_serial/improv_serial_component.cpp +2 -1
  91. esphome/components/improv_serial/improv_serial_component.h +2 -1
  92. esphome/components/ledc/ledc_output.cpp +11 -7
  93. esphome/components/libretiny/__init__.py +8 -13
  94. esphome/components/ltr501/__init__.py +1 -0
  95. esphome/components/ltr501/ltr501.cpp +542 -0
  96. esphome/components/ltr501/ltr501.h +184 -0
  97. esphome/components/ltr501/ltr_definitions_501.h +260 -0
  98. esphome/components/ltr501/sensor.py +274 -0
  99. esphome/components/ltr_als_ps/sensor.py +2 -2
  100. esphome/components/lvgl/__init__.py +19 -16
  101. esphome/components/lvgl/automation.py +90 -9
  102. esphome/components/lvgl/defines.py +29 -2
  103. esphome/components/lvgl/gradient.py +61 -0
  104. esphome/components/lvgl/lv_validation.py +45 -27
  105. esphome/components/lvgl/lvcode.py +8 -3
  106. esphome/components/lvgl/lvgl_esphome.cpp +54 -0
  107. esphome/components/lvgl/lvgl_esphome.h +9 -3
  108. esphome/components/lvgl/number/__init__.py +1 -0
  109. esphome/components/lvgl/number/lvgl_number.h +3 -1
  110. esphome/components/lvgl/schemas.py +16 -11
  111. esphome/components/lvgl/select/__init__.py +1 -0
  112. esphome/components/lvgl/select/lvgl_select.h +3 -1
  113. esphome/components/lvgl/switch/__init__.py +2 -1
  114. esphome/components/lvgl/switch/lvgl_switch.h +3 -1
  115. esphome/components/lvgl/text/__init__.py +1 -0
  116. esphome/components/lvgl/text/lvgl_text.h +3 -1
  117. esphome/components/lvgl/trigger.py +3 -2
  118. esphome/components/lvgl/types.py +2 -1
  119. esphome/components/lvgl/widgets/__init__.py +23 -8
  120. esphome/components/lvgl/widgets/arc.py +5 -1
  121. esphome/components/lvgl/widgets/buttonmatrix.py +5 -1
  122. esphome/components/lvgl/widgets/checkbox.py +8 -3
  123. esphome/components/lvgl/widgets/meter.py +8 -1
  124. esphome/components/lvgl/widgets/msgbox.py +26 -15
  125. esphome/components/lvgl/widgets/page.py +51 -7
  126. esphome/components/lvgl/widgets/tileview.py +2 -8
  127. esphome/components/max31856/max31856.cpp +12 -1
  128. esphome/components/max31856/max31856.h +5 -2
  129. esphome/components/max31856/sensor.py +20 -0
  130. esphome/components/mcp9600/sensor.py +2 -2
  131. esphome/components/mdns/__init__.py +6 -6
  132. esphome/components/media_player/media_player.h +15 -0
  133. esphome/components/micro_wake_word/__init__.py +2 -25
  134. esphome/components/microphone/microphone.h +1 -1
  135. esphome/components/mics_4514/mics_4514.cpp +26 -36
  136. esphome/components/modbus_controller/__init__.py +6 -0
  137. esphome/components/modbus_controller/const.py +2 -0
  138. esphome/components/modbus_controller/modbus_controller.cpp +30 -27
  139. esphome/components/modbus_controller/modbus_controller.h +22 -4
  140. esphome/components/network/__init__.py +11 -8
  141. esphome/components/pipsolar/pipsolar.cpp +3 -0
  142. esphome/components/pipsolar/pipsolar.h +1 -0
  143. esphome/components/pipsolar/switch/__init__.py +2 -0
  144. esphome/components/prometheus/prometheus_handler.cpp +2 -0
  145. esphome/components/prometheus/prometheus_handler.h +3 -1
  146. esphome/components/rp2040/__init__.py +7 -8
  147. esphome/components/rpi_dpi_rgb/display.py +20 -17
  148. esphome/components/rpi_dpi_rgb/rpi_dpi_rgb.cpp +36 -6
  149. esphome/components/rpi_dpi_rgb/rpi_dpi_rgb.h +4 -0
  150. esphome/components/socket/socket.cpp +2 -0
  151. esphome/components/socket/socket.h +2 -0
  152. esphome/components/speaker/speaker.h +1 -1
  153. esphome/components/st7701s/display.py +35 -37
  154. esphome/components/st7701s/st7701s.cpp +11 -6
  155. esphome/components/st7701s/st7701s.h +1 -0
  156. esphome/components/statsd/__init__.py +65 -0
  157. esphome/components/statsd/statsd.cpp +156 -0
  158. esphome/components/statsd/statsd.h +86 -0
  159. esphome/components/tuya/__init__.py +1 -0
  160. esphome/components/tuya/number/__init__.py +39 -2
  161. esphome/components/tuya/number/tuya_number.cpp +58 -2
  162. esphome/components/tuya/number/tuya_number.h +12 -3
  163. esphome/components/udp/__init__.py +158 -0
  164. esphome/components/udp/binary_sensor.py +27 -0
  165. esphome/components/udp/sensor.py +27 -0
  166. esphome/components/udp/udp_component.cpp +616 -0
  167. esphome/components/udp/udp_component.h +158 -0
  168. esphome/components/uponor_smatrix/uponor_smatrix.cpp +4 -6
  169. esphome/components/uponor_smatrix/uponor_smatrix.h +0 -1
  170. esphome/components/veml7700/sensor.py +2 -2
  171. esphome/components/voice_assistant/__init__.py +6 -0
  172. esphome/components/voice_assistant/voice_assistant.cpp +23 -1
  173. esphome/components/voice_assistant/voice_assistant.h +4 -0
  174. esphome/components/web_server/__init__.py +11 -11
  175. esphome/components/web_server/list_entities.cpp +2 -0
  176. esphome/components/web_server/list_entities.h +3 -1
  177. esphome/components/web_server/web_server.cpp +2 -1
  178. esphome/components/web_server/web_server.h +2 -0
  179. esphome/components/web_server_base/web_server_base.cpp +2 -0
  180. esphome/components/web_server_base/web_server_base.h +3 -1
  181. esphome/components/wifi/wifi_component_libretiny.cpp +15 -1
  182. esphome/components/wireguard/__init__.py +9 -6
  183. esphome/components/wireguard/wireguard.cpp +2 -1
  184. esphome/components/wireguard/wireguard.h +3 -1
  185. esphome/config_validation.py +8 -0
  186. esphome/const.py +8 -1
  187. esphome/core/bytebuffer.cpp +117 -84
  188. esphome/core/bytebuffer.h +69 -21
  189. esphome/core/defines.h +2 -0
  190. esphome/core/ring_buffer.cpp +13 -2
  191. esphome/core/ring_buffer.h +56 -0
  192. esphome/external_files.py +5 -3
  193. {esphome-2024.8.3.dist-info → esphome-2024.9.0b1.dist-info}/METADATA +1 -1
  194. {esphome-2024.8.3.dist-info → esphome-2024.9.0b1.dist-info}/RECORD +198 -163
  195. {esphome-2024.8.3.dist-info → esphome-2024.9.0b1.dist-info}/LICENSE +0 -0
  196. {esphome-2024.8.3.dist-info → esphome-2024.9.0b1.dist-info}/WHEEL +0 -0
  197. {esphome-2024.8.3.dist-info → esphome-2024.9.0b1.dist-info}/entry_points.txt +0 -0
  198. {esphome-2024.8.3.dist-info → esphome-2024.9.0b1.dist-info}/top_level.txt +0 -0
esphome/__main__.py CHANGED
@@ -38,7 +38,7 @@ from esphome.const import (
38
38
  SECRETS_FILES,
39
39
  )
40
40
  from esphome.core import CORE, EsphomeError, coroutine
41
- from esphome.helpers import indent, is_ip_address
41
+ from esphome.helpers import indent, is_ip_address, get_bool_env
42
42
  from esphome.log import Fore, color, setup_log
43
43
  from esphome.util import (
44
44
  get_serial_ports,
@@ -731,7 +731,11 @@ POST_CONFIG_ACTIONS = {
731
731
  def parse_args(argv):
732
732
  options_parser = argparse.ArgumentParser(add_help=False)
733
733
  options_parser.add_argument(
734
- "-v", "--verbose", help="Enable verbose ESPHome logs.", action="store_true"
734
+ "-v",
735
+ "--verbose",
736
+ help="Enable verbose ESPHome logs.",
737
+ action="store_true",
738
+ default=get_bool_env("ESPHOME_VERBOSE"),
735
739
  )
736
740
  options_parser.add_argument(
737
741
  "-q", "--quiet", help="Disable all ESPHome logs.", action="store_true"
@@ -1026,6 +1026,15 @@ bool APIConnection::send_media_player_info(media_player::MediaPlayer *media_play
1026
1026
  auto traits = media_player->get_traits();
1027
1027
  msg.supports_pause = traits.get_supports_pause();
1028
1028
 
1029
+ for (auto &supported_format : traits.get_supported_formats()) {
1030
+ MediaPlayerSupportedFormat media_format;
1031
+ media_format.format = supported_format.format;
1032
+ media_format.sample_rate = supported_format.sample_rate;
1033
+ media_format.num_channels = supported_format.num_channels;
1034
+ media_format.purpose = static_cast<enums::MediaPlayerFormatPurpose>(supported_format.purpose);
1035
+ msg.supported_formats.push_back(media_format);
1036
+ }
1037
+
1029
1038
  return this->send_list_entities_media_player_response(msg);
1030
1039
  }
1031
1040
  void APIConnection::media_player_command(const MediaPlayerCommandRequest &msg) {
@@ -1204,6 +1213,16 @@ void APIConnection::on_voice_assistant_timer_event_response(const VoiceAssistant
1204
1213
  }
1205
1214
  };
1206
1215
 
1216
+ void APIConnection::on_voice_assistant_announce_request(const VoiceAssistantAnnounceRequest &msg) {
1217
+ if (voice_assistant::global_voice_assistant != nullptr) {
1218
+ if (voice_assistant::global_voice_assistant->get_api_connection() != this) {
1219
+ return;
1220
+ }
1221
+
1222
+ voice_assistant::global_voice_assistant->on_announce(msg);
1223
+ }
1224
+ }
1225
+
1207
1226
  #endif
1208
1227
 
1209
1228
  #ifdef USE_ALARM_CONTROL_PANEL
@@ -151,6 +151,7 @@ class APIConnection : public APIServerConnection {
151
151
  void on_voice_assistant_event_response(const VoiceAssistantEventResponse &msg) override;
152
152
  void on_voice_assistant_audio(const VoiceAssistantAudio &msg) override;
153
153
  void on_voice_assistant_timer_event_response(const VoiceAssistantTimerEventResponse &msg) override;
154
+ void on_voice_assistant_announce_request(const VoiceAssistantAnnounceRequest &msg) override;
154
155
  #endif
155
156
 
156
157
  #ifdef USE_ALARM_CONTROL_PANEL
@@ -387,6 +387,18 @@ template<> const char *proto_enum_to_string<enums::MediaPlayerCommand>(enums::Me
387
387
  }
388
388
  #endif
389
389
  #ifdef HAS_PROTO_MESSAGE_DUMP
390
+ template<> const char *proto_enum_to_string<enums::MediaPlayerFormatPurpose>(enums::MediaPlayerFormatPurpose value) {
391
+ switch (value) {
392
+ case enums::MEDIA_PLAYER_FORMAT_PURPOSE_DEFAULT:
393
+ return "MEDIA_PLAYER_FORMAT_PURPOSE_DEFAULT";
394
+ case enums::MEDIA_PLAYER_FORMAT_PURPOSE_ANNOUNCEMENT:
395
+ return "MEDIA_PLAYER_FORMAT_PURPOSE_ANNOUNCEMENT";
396
+ default:
397
+ return "UNKNOWN";
398
+ }
399
+ }
400
+ #endif
401
+ #ifdef HAS_PROTO_MESSAGE_DUMP
390
402
  template<>
391
403
  const char *proto_enum_to_string<enums::BluetoothDeviceRequestType>(enums::BluetoothDeviceRequestType value) {
392
404
  switch (value) {
@@ -5123,6 +5135,64 @@ void ButtonCommandRequest::dump_to(std::string &out) const {
5123
5135
  out.append("}");
5124
5136
  }
5125
5137
  #endif
5138
+ bool MediaPlayerSupportedFormat::decode_varint(uint32_t field_id, ProtoVarInt value) {
5139
+ switch (field_id) {
5140
+ case 2: {
5141
+ this->sample_rate = value.as_uint32();
5142
+ return true;
5143
+ }
5144
+ case 3: {
5145
+ this->num_channels = value.as_uint32();
5146
+ return true;
5147
+ }
5148
+ case 4: {
5149
+ this->purpose = value.as_enum<enums::MediaPlayerFormatPurpose>();
5150
+ return true;
5151
+ }
5152
+ default:
5153
+ return false;
5154
+ }
5155
+ }
5156
+ bool MediaPlayerSupportedFormat::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
5157
+ switch (field_id) {
5158
+ case 1: {
5159
+ this->format = value.as_string();
5160
+ return true;
5161
+ }
5162
+ default:
5163
+ return false;
5164
+ }
5165
+ }
5166
+ void MediaPlayerSupportedFormat::encode(ProtoWriteBuffer buffer) const {
5167
+ buffer.encode_string(1, this->format);
5168
+ buffer.encode_uint32(2, this->sample_rate);
5169
+ buffer.encode_uint32(3, this->num_channels);
5170
+ buffer.encode_enum<enums::MediaPlayerFormatPurpose>(4, this->purpose);
5171
+ }
5172
+ #ifdef HAS_PROTO_MESSAGE_DUMP
5173
+ void MediaPlayerSupportedFormat::dump_to(std::string &out) const {
5174
+ __attribute__((unused)) char buffer[64];
5175
+ out.append("MediaPlayerSupportedFormat {\n");
5176
+ out.append(" format: ");
5177
+ out.append("'").append(this->format).append("'");
5178
+ out.append("\n");
5179
+
5180
+ out.append(" sample_rate: ");
5181
+ sprintf(buffer, "%" PRIu32, this->sample_rate);
5182
+ out.append(buffer);
5183
+ out.append("\n");
5184
+
5185
+ out.append(" num_channels: ");
5186
+ sprintf(buffer, "%" PRIu32, this->num_channels);
5187
+ out.append(buffer);
5188
+ out.append("\n");
5189
+
5190
+ out.append(" purpose: ");
5191
+ out.append(proto_enum_to_string<enums::MediaPlayerFormatPurpose>(this->purpose));
5192
+ out.append("\n");
5193
+ out.append("}");
5194
+ }
5195
+ #endif
5126
5196
  bool ListEntitiesMediaPlayerResponse::decode_varint(uint32_t field_id, ProtoVarInt value) {
5127
5197
  switch (field_id) {
5128
5198
  case 6: {
@@ -5159,6 +5229,10 @@ bool ListEntitiesMediaPlayerResponse::decode_length(uint32_t field_id, ProtoLeng
5159
5229
  this->icon = value.as_string();
5160
5230
  return true;
5161
5231
  }
5232
+ case 9: {
5233
+ this->supported_formats.push_back(value.as_message<MediaPlayerSupportedFormat>());
5234
+ return true;
5235
+ }
5162
5236
  default:
5163
5237
  return false;
5164
5238
  }
@@ -5182,6 +5256,9 @@ void ListEntitiesMediaPlayerResponse::encode(ProtoWriteBuffer buffer) const {
5182
5256
  buffer.encode_bool(6, this->disabled_by_default);
5183
5257
  buffer.encode_enum<enums::EntityCategory>(7, this->entity_category);
5184
5258
  buffer.encode_bool(8, this->supports_pause);
5259
+ for (auto &it : this->supported_formats) {
5260
+ buffer.encode_message<MediaPlayerSupportedFormat>(9, it, true);
5261
+ }
5185
5262
  }
5186
5263
  #ifdef HAS_PROTO_MESSAGE_DUMP
5187
5264
  void ListEntitiesMediaPlayerResponse::dump_to(std::string &out) const {
@@ -5219,6 +5296,12 @@ void ListEntitiesMediaPlayerResponse::dump_to(std::string &out) const {
5219
5296
  out.append(" supports_pause: ");
5220
5297
  out.append(YESNO(this->supports_pause));
5221
5298
  out.append("\n");
5299
+
5300
+ for (const auto &it : this->supported_formats) {
5301
+ out.append(" supported_formats: ");
5302
+ it.dump_to(out);
5303
+ out.append("\n");
5304
+ }
5222
5305
  out.append("}");
5223
5306
  }
5224
5307
  #endif
@@ -6978,6 +7061,59 @@ void VoiceAssistantTimerEventResponse::dump_to(std::string &out) const {
6978
7061
  out.append("}");
6979
7062
  }
6980
7063
  #endif
7064
+ bool VoiceAssistantAnnounceRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
7065
+ switch (field_id) {
7066
+ case 1: {
7067
+ this->media_id = value.as_string();
7068
+ return true;
7069
+ }
7070
+ case 2: {
7071
+ this->text = value.as_string();
7072
+ return true;
7073
+ }
7074
+ default:
7075
+ return false;
7076
+ }
7077
+ }
7078
+ void VoiceAssistantAnnounceRequest::encode(ProtoWriteBuffer buffer) const {
7079
+ buffer.encode_string(1, this->media_id);
7080
+ buffer.encode_string(2, this->text);
7081
+ }
7082
+ #ifdef HAS_PROTO_MESSAGE_DUMP
7083
+ void VoiceAssistantAnnounceRequest::dump_to(std::string &out) const {
7084
+ __attribute__((unused)) char buffer[64];
7085
+ out.append("VoiceAssistantAnnounceRequest {\n");
7086
+ out.append(" media_id: ");
7087
+ out.append("'").append(this->media_id).append("'");
7088
+ out.append("\n");
7089
+
7090
+ out.append(" text: ");
7091
+ out.append("'").append(this->text).append("'");
7092
+ out.append("\n");
7093
+ out.append("}");
7094
+ }
7095
+ #endif
7096
+ bool VoiceAssistantAnnounceFinished::decode_varint(uint32_t field_id, ProtoVarInt value) {
7097
+ switch (field_id) {
7098
+ case 1: {
7099
+ this->success = value.as_bool();
7100
+ return true;
7101
+ }
7102
+ default:
7103
+ return false;
7104
+ }
7105
+ }
7106
+ void VoiceAssistantAnnounceFinished::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->success); }
7107
+ #ifdef HAS_PROTO_MESSAGE_DUMP
7108
+ void VoiceAssistantAnnounceFinished::dump_to(std::string &out) const {
7109
+ __attribute__((unused)) char buffer[64];
7110
+ out.append("VoiceAssistantAnnounceFinished {\n");
7111
+ out.append(" success: ");
7112
+ out.append(YESNO(this->success));
7113
+ out.append("\n");
7114
+ out.append("}");
7115
+ }
7116
+ #endif
6981
7117
  bool ListEntitiesAlarmControlPanelResponse::decode_varint(uint32_t field_id, ProtoVarInt value) {
6982
7118
  switch (field_id) {
6983
7119
  case 6: {
@@ -156,6 +156,10 @@ enum MediaPlayerCommand : uint32_t {
156
156
  MEDIA_PLAYER_COMMAND_MUTE = 3,
157
157
  MEDIA_PLAYER_COMMAND_UNMUTE = 4,
158
158
  };
159
+ enum MediaPlayerFormatPurpose : uint32_t {
160
+ MEDIA_PLAYER_FORMAT_PURPOSE_DEFAULT = 0,
161
+ MEDIA_PLAYER_FORMAT_PURPOSE_ANNOUNCEMENT = 1,
162
+ };
159
163
  enum BluetoothDeviceRequestType : uint32_t {
160
164
  BLUETOOTH_DEVICE_REQUEST_TYPE_CONNECT = 0,
161
165
  BLUETOOTH_DEVICE_REQUEST_TYPE_DISCONNECT = 1,
@@ -1267,6 +1271,21 @@ class ButtonCommandRequest : public ProtoMessage {
1267
1271
  protected:
1268
1272
  bool decode_32bit(uint32_t field_id, Proto32Bit value) override;
1269
1273
  };
1274
+ class MediaPlayerSupportedFormat : public ProtoMessage {
1275
+ public:
1276
+ std::string format{};
1277
+ uint32_t sample_rate{0};
1278
+ uint32_t num_channels{0};
1279
+ enums::MediaPlayerFormatPurpose purpose{};
1280
+ void encode(ProtoWriteBuffer buffer) const override;
1281
+ #ifdef HAS_PROTO_MESSAGE_DUMP
1282
+ void dump_to(std::string &out) const override;
1283
+ #endif
1284
+
1285
+ protected:
1286
+ bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override;
1287
+ bool decode_varint(uint32_t field_id, ProtoVarInt value) override;
1288
+ };
1270
1289
  class ListEntitiesMediaPlayerResponse : public ProtoMessage {
1271
1290
  public:
1272
1291
  std::string object_id{};
@@ -1277,6 +1296,7 @@ class ListEntitiesMediaPlayerResponse : public ProtoMessage {
1277
1296
  bool disabled_by_default{false};
1278
1297
  enums::EntityCategory entity_category{};
1279
1298
  bool supports_pause{false};
1299
+ std::vector<MediaPlayerSupportedFormat> supported_formats{};
1280
1300
  void encode(ProtoWriteBuffer buffer) const override;
1281
1301
  #ifdef HAS_PROTO_MESSAGE_DUMP
1282
1302
  void dump_to(std::string &out) const override;
@@ -1805,6 +1825,29 @@ class VoiceAssistantTimerEventResponse : public ProtoMessage {
1805
1825
  bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override;
1806
1826
  bool decode_varint(uint32_t field_id, ProtoVarInt value) override;
1807
1827
  };
1828
+ class VoiceAssistantAnnounceRequest : public ProtoMessage {
1829
+ public:
1830
+ std::string media_id{};
1831
+ std::string text{};
1832
+ void encode(ProtoWriteBuffer buffer) const override;
1833
+ #ifdef HAS_PROTO_MESSAGE_DUMP
1834
+ void dump_to(std::string &out) const override;
1835
+ #endif
1836
+
1837
+ protected:
1838
+ bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override;
1839
+ };
1840
+ class VoiceAssistantAnnounceFinished : public ProtoMessage {
1841
+ public:
1842
+ bool success{false};
1843
+ void encode(ProtoWriteBuffer buffer) const override;
1844
+ #ifdef HAS_PROTO_MESSAGE_DUMP
1845
+ void dump_to(std::string &out) const override;
1846
+ #endif
1847
+
1848
+ protected:
1849
+ bool decode_varint(uint32_t field_id, ProtoVarInt value) override;
1850
+ };
1808
1851
  class ListEntitiesAlarmControlPanelResponse : public ProtoMessage {
1809
1852
  public:
1810
1853
  std::string object_id{};
@@ -486,6 +486,16 @@ bool APIServerConnectionBase::send_voice_assistant_audio(const VoiceAssistantAud
486
486
  #endif
487
487
  #ifdef USE_VOICE_ASSISTANT
488
488
  #endif
489
+ #ifdef USE_VOICE_ASSISTANT
490
+ #endif
491
+ #ifdef USE_VOICE_ASSISTANT
492
+ bool APIServerConnectionBase::send_voice_assistant_announce_finished(const VoiceAssistantAnnounceFinished &msg) {
493
+ #ifdef HAS_PROTO_MESSAGE_DUMP
494
+ ESP_LOGVV(TAG, "send_voice_assistant_announce_finished: %s", msg.dump().c_str());
495
+ #endif
496
+ return this->send_message_<VoiceAssistantAnnounceFinished>(msg, 120);
497
+ }
498
+ #endif
489
499
  #ifdef USE_ALARM_CONTROL_PANEL
490
500
  bool APIServerConnectionBase::send_list_entities_alarm_control_panel_response(
491
501
  const ListEntitiesAlarmControlPanelResponse &msg) {
@@ -1135,6 +1145,17 @@ bool APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
1135
1145
  ESP_LOGVV(TAG, "on_update_command_request: %s", msg.dump().c_str());
1136
1146
  #endif
1137
1147
  this->on_update_command_request(msg);
1148
+ #endif
1149
+ break;
1150
+ }
1151
+ case 119: {
1152
+ #ifdef USE_VOICE_ASSISTANT
1153
+ VoiceAssistantAnnounceRequest msg;
1154
+ msg.decode(msg_data, msg_size);
1155
+ #ifdef HAS_PROTO_MESSAGE_DUMP
1156
+ ESP_LOGVV(TAG, "on_voice_assistant_announce_request: %s", msg.dump().c_str());
1157
+ #endif
1158
+ this->on_voice_assistant_announce_request(msg);
1138
1159
  #endif
1139
1160
  break;
1140
1161
  }
@@ -247,6 +247,12 @@ class APIServerConnectionBase : public ProtoService {
247
247
  #ifdef USE_VOICE_ASSISTANT
248
248
  virtual void on_voice_assistant_timer_event_response(const VoiceAssistantTimerEventResponse &value){};
249
249
  #endif
250
+ #ifdef USE_VOICE_ASSISTANT
251
+ virtual void on_voice_assistant_announce_request(const VoiceAssistantAnnounceRequest &value){};
252
+ #endif
253
+ #ifdef USE_VOICE_ASSISTANT
254
+ bool send_voice_assistant_announce_finished(const VoiceAssistantAnnounceFinished &msg);
255
+ #endif
250
256
  #ifdef USE_ALARM_CONTROL_PANEL
251
257
  bool send_list_entities_alarm_control_panel_response(const ListEntitiesAlarmControlPanelResponse &msg);
252
258
  #endif
@@ -1,13 +1,13 @@
1
1
  # Dummy integration to allow relying on AsyncTCP
2
2
  import esphome.codegen as cg
3
3
  import esphome.config_validation as cv
4
- from esphome.core import CORE, coroutine_with_priority
5
4
  from esphome.const import (
5
+ PLATFORM_BK72XX,
6
6
  PLATFORM_ESP32,
7
7
  PLATFORM_ESP8266,
8
- PLATFORM_BK72XX,
9
8
  PLATFORM_RTL87XX,
10
9
  )
10
+ from esphome.core import CORE, coroutine_with_priority
11
11
 
12
12
  CODEOWNERS = ["@OttoWinter"]
13
13
 
@@ -22,7 +22,7 @@ CONFIG_SCHEMA = cv.All(
22
22
  async def to_code(config):
23
23
  if CORE.is_esp32 or CORE.is_libretiny:
24
24
  # https://github.com/esphome/AsyncTCP/blob/master/library.json
25
- cg.add_library("esphome/AsyncTCP-esphome", "2.1.3")
25
+ cg.add_library("esphome/AsyncTCP-esphome", "2.1.4")
26
26
  elif CORE.is_esp8266:
27
27
  # https://github.com/esphome/ESPAsyncTCP
28
28
  cg.add_library("esphome/ESPAsyncTCP-esphome", "2.0.0")
@@ -1,34 +1,34 @@
1
1
  import esphome.codegen as cg
2
- import esphome.config_validation as cv
3
2
  from esphome.components import sensor, spi
3
+ import esphome.config_validation as cv
4
4
  from esphome.const import (
5
- CONF_ID,
6
- CONF_REACTIVE_POWER,
7
- CONF_VOLTAGE,
8
5
  CONF_CURRENT,
6
+ CONF_FORWARD_ACTIVE_ENERGY,
7
+ CONF_FREQUENCY,
8
+ CONF_ID,
9
+ CONF_LINE_FREQUENCY,
9
10
  CONF_POWER,
10
11
  CONF_POWER_FACTOR,
11
- CONF_FREQUENCY,
12
- CONF_FORWARD_ACTIVE_ENERGY,
12
+ CONF_REACTIVE_POWER,
13
13
  CONF_REVERSE_ACTIVE_ENERGY,
14
+ CONF_VOLTAGE,
14
15
  DEVICE_CLASS_CURRENT,
15
16
  DEVICE_CLASS_ENERGY,
16
17
  DEVICE_CLASS_POWER,
17
18
  DEVICE_CLASS_POWER_FACTOR,
18
19
  DEVICE_CLASS_VOLTAGE,
19
- ICON_LIGHTBULB,
20
20
  ICON_CURRENT_AC,
21
+ ICON_LIGHTBULB,
21
22
  STATE_CLASS_MEASUREMENT,
22
23
  STATE_CLASS_TOTAL_INCREASING,
24
+ UNIT_AMPERE,
23
25
  UNIT_HERTZ,
24
26
  UNIT_VOLT,
25
- UNIT_AMPERE,
26
- UNIT_WATT,
27
27
  UNIT_VOLT_AMPS_REACTIVE,
28
+ UNIT_WATT,
28
29
  UNIT_WATT_HOURS,
29
30
  )
30
31
 
31
- CONF_LINE_FREQUENCY = "line_frequency"
32
32
  CONF_METER_CONSTANT = "meter_constant"
33
33
  CONF_PL_CONST = "pl_const"
34
34
  CONF_GAIN_PGA = "gain_pga"
@@ -7,6 +7,7 @@ from esphome.const import (
7
7
  CONF_FORWARD_ACTIVE_ENERGY,
8
8
  CONF_FREQUENCY,
9
9
  CONF_ID,
10
+ CONF_LINE_FREQUENCY,
10
11
  CONF_PHASE_A,
11
12
  CONF_PHASE_ANGLE,
12
13
  CONF_PHASE_B,
@@ -39,7 +40,6 @@ from esphome.const import (
39
40
 
40
41
  from . import atm90e32_ns
41
42
 
42
- CONF_LINE_FREQUENCY = "line_frequency"
43
43
  CONF_CHIP_TEMPERATURE = "chip_temperature"
44
44
  CONF_GAIN_PGA = "gain_pga"
45
45
  CONF_CURRENT_PHASES = "current_phases"
@@ -0,0 +1 @@
1
+ CODEOWNERS = ["@athom-tech", "@tarontop", "@jesserockz"]
@@ -0,0 +1,238 @@
1
+ #include "bl0906.h"
2
+ #include "constants.h"
3
+
4
+ #include "esphome/core/log.h"
5
+
6
+ namespace esphome {
7
+ namespace bl0906 {
8
+
9
+ static const char *const TAG = "bl0906";
10
+
11
+ constexpr uint32_t to_uint32_t(ube24_t input) { return input.h << 16 | input.m << 8 | input.l; }
12
+
13
+ constexpr int32_t to_int32_t(sbe24_t input) { return input.h << 16 | input.m << 8 | input.l; }
14
+
15
+ // The SUM byte is (Addr+Data_L+Data_M+Data_H)&0xFF negated;
16
+ constexpr uint8_t bl0906_checksum(const uint8_t address, const DataPacket *data) {
17
+ return (address + data->l + data->m + data->h) ^ 0xFF;
18
+ }
19
+
20
+ void BL0906::loop() {
21
+ if (this->current_channel_ == UINT8_MAX) {
22
+ return;
23
+ }
24
+
25
+ while (this->available())
26
+ this->flush();
27
+
28
+ if (this->current_channel_ == 0) {
29
+ // Temperature
30
+ this->read_data_(BL0906_TEMPERATURE, BL0906_TREF, this->temperature_sensor_);
31
+ } else if (this->current_channel_ == 1) {
32
+ this->read_data_(BL0906_I_1_RMS, BL0906_IREF, this->current_1_sensor_);
33
+ this->read_data_(BL0906_WATT_1, BL0906_PREF, this->power_1_sensor_);
34
+ this->read_data_(BL0906_CF_1_CNT, BL0906_EREF, this->energy_1_sensor_);
35
+ } else if (this->current_channel_ == 2) {
36
+ this->read_data_(BL0906_I_2_RMS, BL0906_IREF, this->current_2_sensor_);
37
+ this->read_data_(BL0906_WATT_2, BL0906_PREF, this->power_2_sensor_);
38
+ this->read_data_(BL0906_CF_2_CNT, BL0906_EREF, this->energy_2_sensor_);
39
+ } else if (this->current_channel_ == 3) {
40
+ this->read_data_(BL0906_I_3_RMS, BL0906_IREF, this->current_3_sensor_);
41
+ this->read_data_(BL0906_WATT_3, BL0906_PREF, this->power_3_sensor_);
42
+ this->read_data_(BL0906_CF_3_CNT, BL0906_EREF, this->energy_3_sensor_);
43
+ } else if (this->current_channel_ == 4) {
44
+ this->read_data_(BL0906_I_4_RMS, BL0906_IREF, this->current_4_sensor_);
45
+ this->read_data_(BL0906_WATT_4, BL0906_PREF, this->power_4_sensor_);
46
+ this->read_data_(BL0906_CF_4_CNT, BL0906_EREF, this->energy_4_sensor_);
47
+ } else if (this->current_channel_ == 5) {
48
+ this->read_data_(BL0906_I_5_RMS, BL0906_IREF, this->current_5_sensor_);
49
+ this->read_data_(BL0906_WATT_5, BL0906_PREF, this->power_5_sensor_);
50
+ this->read_data_(BL0906_CF_5_CNT, BL0906_EREF, this->energy_5_sensor_);
51
+ } else if (this->current_channel_ == 6) {
52
+ this->read_data_(BL0906_I_6_RMS, BL0906_IREF, this->current_6_sensor_);
53
+ this->read_data_(BL0906_WATT_6, BL0906_PREF, this->power_6_sensor_);
54
+ this->read_data_(BL0906_CF_6_CNT, BL0906_EREF, this->energy_6_sensor_);
55
+ } else if (this->current_channel_ == UINT8_MAX - 2) {
56
+ // Frequency
57
+ this->read_data_(BL0906_FREQUENCY, BL0906_FREF, frequency_sensor_);
58
+ // Voltage
59
+ this->read_data_(BL0906_V_RMS, BL0906_UREF, voltage_sensor_);
60
+ } else if (this->current_channel_ == UINT8_MAX - 1) {
61
+ // Total power
62
+ this->read_data_(BL0906_WATT_SUM, BL0906_WATT, this->total_power_sensor_);
63
+ // Total Energy
64
+ this->read_data_(BL0906_CF_SUM_CNT, BL0906_CF, this->total_energy_sensor_);
65
+ } else {
66
+ this->current_channel_ = UINT8_MAX - 2; // Go to frequency and voltage
67
+ return;
68
+ }
69
+ this->current_channel_++;
70
+ this->handle_actions_();
71
+ }
72
+
73
+ void BL0906::setup() {
74
+ while (this->available())
75
+ this->flush();
76
+ this->write_array(USR_WRPROT_WITABLE, sizeof(USR_WRPROT_WITABLE));
77
+ // Calibration (1: register address; 2: value before calibration; 3: value after calibration)
78
+ this->bias_correction_(BL0906_RMSOS_1, 0.01600, 0); // Calibration current_1
79
+ this->bias_correction_(BL0906_RMSOS_2, 0.01500, 0);
80
+ this->bias_correction_(BL0906_RMSOS_3, 0.01400, 0);
81
+ this->bias_correction_(BL0906_RMSOS_4, 0.01300, 0);
82
+ this->bias_correction_(BL0906_RMSOS_5, 0.01200, 0);
83
+ this->bias_correction_(BL0906_RMSOS_6, 0.01200, 0); // Calibration current_6
84
+
85
+ this->write_array(USR_WRPROT_ONLYREAD, sizeof(USR_WRPROT_ONLYREAD));
86
+ }
87
+
88
+ void BL0906::update() { this->current_channel_ = 0; }
89
+
90
+ size_t BL0906::enqueue_action_(ActionCallbackFuncPtr function) {
91
+ this->action_queue_.push_back(function);
92
+ return this->action_queue_.size();
93
+ }
94
+
95
+ void BL0906::handle_actions_() {
96
+ if (this->action_queue_.empty()) {
97
+ return;
98
+ }
99
+ ActionCallbackFuncPtr ptr_func = nullptr;
100
+ for (int i = 0; i < this->action_queue_.size(); i++) {
101
+ ptr_func = this->action_queue_[i];
102
+ if (ptr_func) {
103
+ ESP_LOGI(TAG, "HandleActionCallback[%d]...", i);
104
+ (this->*ptr_func)();
105
+ }
106
+ }
107
+
108
+ while (this->available()) {
109
+ this->read();
110
+ }
111
+
112
+ this->action_queue_.clear();
113
+ }
114
+
115
+ // Reset energy
116
+ void BL0906::reset_energy_() {
117
+ this->write_array(BL0906_INIT[0], 6);
118
+ delay(1);
119
+ this->flush();
120
+
121
+ ESP_LOGW(TAG, "RMSOS:%02X%02X%02X%02X%02X%02X", BL0906_INIT[0][0], BL0906_INIT[0][1], BL0906_INIT[0][2],
122
+ BL0906_INIT[0][3], BL0906_INIT[0][4], BL0906_INIT[0][5]);
123
+ }
124
+
125
+ // Read data
126
+ void BL0906::read_data_(const uint8_t address, const float reference, sensor::Sensor *sensor) {
127
+ if (sensor == nullptr) {
128
+ return;
129
+ }
130
+ DataPacket buffer;
131
+ ube24_t data_u24;
132
+ sbe24_t data_s24;
133
+ float value = 0;
134
+
135
+ bool signed_result = reference == BL0906_TREF || reference == BL0906_WATT || reference == BL0906_PREF;
136
+
137
+ this->write_byte(BL0906_READ_COMMAND);
138
+ this->write_byte(address);
139
+ if (this->read_array((uint8_t *) &buffer, sizeof(buffer) - 1)) {
140
+ if (bl0906_checksum(address, &buffer) == buffer.checksum) {
141
+ if (signed_result) {
142
+ data_s24.l = buffer.l;
143
+ data_s24.m = buffer.m;
144
+ data_s24.h = buffer.h;
145
+ } else {
146
+ data_u24.l = buffer.l;
147
+ data_u24.m = buffer.m;
148
+ data_u24.h = buffer.h;
149
+ }
150
+ } else {
151
+ ESP_LOGW(TAG, "Junk on wire. Throwing away partial message");
152
+ while (read() >= 0)
153
+ ;
154
+ return;
155
+ }
156
+ }
157
+ // Power
158
+ if (reference == BL0906_PREF) {
159
+ value = (float) to_int32_t(data_s24) * reference;
160
+ }
161
+
162
+ // Total power
163
+ if (reference == BL0906_WATT) {
164
+ value = (float) to_int32_t(data_s24) * reference;
165
+ }
166
+
167
+ // Voltage, current, power, total power
168
+ if (reference == BL0906_UREF || reference == BL0906_IREF || reference == BL0906_EREF || reference == BL0906_CF) {
169
+ value = (float) to_uint32_t(data_u24) * reference;
170
+ }
171
+
172
+ // Frequency
173
+ if (reference == BL0906_FREF) {
174
+ value = reference / (float) to_uint32_t(data_u24);
175
+ }
176
+ // Chip temperature
177
+ if (reference == BL0906_TREF) {
178
+ value = (float) to_int32_t(data_s24);
179
+ value = (value - 64) * 12.5 / 59 - 40;
180
+ }
181
+ sensor->publish_state(value);
182
+ }
183
+
184
+ // RMS offset correction
185
+ void BL0906::bias_correction_(uint8_t address, float measurements, float correction) {
186
+ DataPacket data;
187
+ float ki = 12875 * 1 * (5.1 + 5.1) * 1000 / 2000 / 1.097; // Current coefficient
188
+ float i_rms0 = measurements * ki;
189
+ float i_rms = correction * ki;
190
+ int32_t value = (i_rms * i_rms - i_rms0 * i_rms0) / 256;
191
+ data.l = value << 24 >> 24;
192
+ data.m = value << 16 >> 24;
193
+ if (value < 0) {
194
+ data.h = (value << 8 >> 24) | 0b10000000;
195
+ }
196
+ data.address = bl0906_checksum(address, &data);
197
+ ESP_LOGV(TAG, "RMSOS:%02X%02X%02X%02X%02X%02X", BL0906_WRITE_COMMAND, address, data.l, data.m, data.h, data.address);
198
+ this->write_byte(BL0906_WRITE_COMMAND);
199
+ this->write_byte(address);
200
+ this->write_byte(data.l);
201
+ this->write_byte(data.m);
202
+ this->write_byte(data.h);
203
+ this->write_byte(data.address);
204
+ }
205
+
206
+ void BL0906::dump_config() {
207
+ ESP_LOGCONFIG(TAG, "BL0906:");
208
+ LOG_SENSOR(" ", "Voltage", this->voltage_sensor_);
209
+
210
+ LOG_SENSOR(" ", "Current1", this->current_1_sensor_);
211
+ LOG_SENSOR(" ", "Current2", this->current_2_sensor_);
212
+ LOG_SENSOR(" ", "Current3", this->current_3_sensor_);
213
+ LOG_SENSOR(" ", "Current4", this->current_4_sensor_);
214
+ LOG_SENSOR(" ", "Current5", this->current_5_sensor_);
215
+ LOG_SENSOR(" ", "Current6", this->current_6_sensor_);
216
+
217
+ LOG_SENSOR(" ", "Power1", this->power_1_sensor_);
218
+ LOG_SENSOR(" ", "Power2", this->power_2_sensor_);
219
+ LOG_SENSOR(" ", "Power3", this->power_3_sensor_);
220
+ LOG_SENSOR(" ", "Power4", this->power_4_sensor_);
221
+ LOG_SENSOR(" ", "Power5", this->power_5_sensor_);
222
+ LOG_SENSOR(" ", "Power6", this->power_6_sensor_);
223
+
224
+ LOG_SENSOR(" ", "Energy1", this->energy_1_sensor_);
225
+ LOG_SENSOR(" ", "Energy2", this->energy_2_sensor_);
226
+ LOG_SENSOR(" ", "Energy3", this->energy_3_sensor_);
227
+ LOG_SENSOR(" ", "Energy4", this->energy_4_sensor_);
228
+ LOG_SENSOR(" ", "Energy5", this->energy_5_sensor_);
229
+ LOG_SENSOR(" ", "Energy6", this->energy_6_sensor_);
230
+
231
+ LOG_SENSOR(" ", "Total Power", this->total_power_sensor_);
232
+ LOG_SENSOR(" ", "Total Energy", this->total_energy_sensor_);
233
+ LOG_SENSOR(" ", "Frequency", this->frequency_sensor_);
234
+ LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
235
+ }
236
+
237
+ } // namespace bl0906
238
+ } // namespace esphome