esphome 2024.12.4__py3-none-any.whl → 2025.2.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 (366) hide show
  1. esphome/__main__.py +16 -3
  2. esphome/components/adc/__init__.py +17 -11
  3. esphome/components/adc/adc_sensor.h +17 -0
  4. esphome/components/adc/adc_sensor_common.cpp +55 -0
  5. esphome/components/adc/adc_sensor_esp32.cpp +8 -5
  6. esphome/components/adc/adc_sensor_esp8266.cpp +10 -6
  7. esphome/components/adc/adc_sensor_libretiny.cpp +11 -6
  8. esphome/components/adc/adc_sensor_rp2040.cpp +13 -10
  9. esphome/components/adc/sensor.py +9 -3
  10. esphome/components/ads1115/ads1115.cpp +56 -7
  11. esphome/components/ads1115/ads1115.h +13 -1
  12. esphome/components/ads1115/sensor/__init__.py +16 -0
  13. esphome/components/ads1115/sensor/ads1115_sensor.cpp +2 -1
  14. esphome/components/ads1115/sensor/ads1115_sensor.h +2 -0
  15. esphome/components/animation/__init__.py +23 -261
  16. esphome/components/animation/animation.cpp +2 -2
  17. esphome/components/animation/animation.h +2 -1
  18. esphome/components/api/api_pb2.cpp +14 -0
  19. esphome/components/api/api_pb2.h +1 -0
  20. esphome/components/api/client.py +8 -3
  21. esphome/components/audio/__init__.py +112 -0
  22. esphome/components/audio/audio.cpp +67 -0
  23. esphome/components/audio/audio.h +125 -7
  24. esphome/components/audio/audio_decoder.cpp +361 -0
  25. esphome/components/audio/audio_decoder.h +135 -0
  26. esphome/components/audio/audio_reader.cpp +308 -0
  27. esphome/components/audio/audio_reader.h +85 -0
  28. esphome/components/audio/audio_resampler.cpp +159 -0
  29. esphome/components/audio/audio_resampler.h +101 -0
  30. esphome/components/audio/audio_transfer_buffer.cpp +165 -0
  31. esphome/components/audio/audio_transfer_buffer.h +139 -0
  32. esphome/components/audio_adc/__init__.py +41 -0
  33. esphome/components/audio_adc/audio_adc.h +17 -0
  34. esphome/components/audio_adc/automation.h +23 -0
  35. esphome/components/bk72xx/__init__.py +1 -0
  36. esphome/components/ble_client/ble_client.cpp +1 -2
  37. esphome/components/ble_client/sensor/__init__.py +1 -1
  38. esphome/components/ble_client/text_sensor/__init__.py +1 -1
  39. esphome/components/bluetooth_proxy/bluetooth_connection.cpp +5 -0
  40. esphome/components/bluetooth_proxy/bluetooth_connection.h +1 -0
  41. esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +5 -0
  42. esphome/components/ch422g/ch422g.h +2 -0
  43. esphome/components/climate/__init__.py +1 -1
  44. esphome/components/climate_ir/climate_ir.cpp +2 -1
  45. esphome/components/coolix/coolix.cpp +2 -1
  46. esphome/components/cse7766/cse7766.cpp +8 -16
  47. esphome/components/custom/__init__.py +0 -3
  48. esphome/components/custom/binary_sensor/__init__.py +2 -28
  49. esphome/components/custom/climate/__init__.py +2 -27
  50. esphome/components/custom/cover/__init__.py +2 -27
  51. esphome/components/custom/light/__init__.py +2 -27
  52. esphome/components/custom/output/__init__.py +2 -58
  53. esphome/components/custom/sensor/__init__.py +2 -24
  54. esphome/components/custom/switch/__init__.py +2 -24
  55. esphome/components/custom/text_sensor/__init__.py +2 -29
  56. esphome/components/custom_component/__init__.py +3 -27
  57. esphome/components/daly_bms/daly_bms.cpp +6 -0
  58. esphome/components/daly_bms/daly_bms.h +2 -0
  59. esphome/components/daly_bms/sensor.py +6 -0
  60. esphome/components/debug/debug_component.cpp +4 -0
  61. esphome/components/debug/debug_component.h +14 -0
  62. esphome/components/debug/debug_esp32.cpp +154 -74
  63. esphome/components/dfplayer/dfplayer.cpp +15 -2
  64. esphome/components/dfrobot_sen0395/dfrobot_sen0395.cpp +2 -1
  65. esphome/components/dht/dht.cpp +4 -2
  66. esphome/components/dht/sensor.py +1 -1
  67. esphome/components/display/__init__.py +18 -5
  68. esphome/components/display/display.cpp +16 -3
  69. esphome/components/display/rect.cpp +2 -1
  70. esphome/components/es7210/__init__.py +0 -0
  71. esphome/components/es7210/audio_adc.py +51 -0
  72. esphome/components/es7210/es7210.cpp +228 -0
  73. esphome/components/es7210/es7210.h +62 -0
  74. esphome/components/es7210/es7210_const.h +129 -0
  75. esphome/components/es7243e/__init__.py +0 -0
  76. esphome/components/es7243e/audio_adc.py +34 -0
  77. esphome/components/es7243e/es7243e.cpp +125 -0
  78. esphome/components/es7243e/es7243e.h +37 -0
  79. esphome/components/es7243e/es7243e_const.h +54 -0
  80. esphome/components/es8156/__init__.py +0 -0
  81. esphome/components/es8156/audio_dac.py +27 -0
  82. esphome/components/es8156/es8156.cpp +87 -0
  83. esphome/components/es8156/es8156.h +51 -0
  84. esphome/components/es8156/es8156_const.h +68 -0
  85. esphome/components/es8311/audio_dac.py +1 -2
  86. esphome/components/esp32/__init__.py +1 -0
  87. esphome/components/esp32/core.cpp +5 -1
  88. esphome/components/esp32/gpio.h +2 -0
  89. esphome/components/esp32_ble/__init__.py +39 -0
  90. esphome/components/esp32_ble/queue.h +4 -4
  91. esphome/components/esp32_ble_client/ble_client_base.cpp +46 -0
  92. esphome/components/esp32_ble_client/ble_client_base.h +2 -0
  93. esphome/components/esp32_ble_server/__init__.py +582 -12
  94. esphome/components/esp32_ble_server/ble_characteristic.cpp +48 -60
  95. esphome/components/esp32_ble_server/ble_characteristic.h +24 -17
  96. esphome/components/esp32_ble_server/ble_descriptor.cpp +21 -9
  97. esphome/components/esp32_ble_server/ble_descriptor.h +17 -6
  98. esphome/components/esp32_ble_server/ble_server.cpp +62 -67
  99. esphome/components/esp32_ble_server/ble_server.h +28 -32
  100. esphome/components/esp32_ble_server/ble_server_automations.cpp +77 -0
  101. esphome/components/esp32_ble_server/ble_server_automations.h +115 -0
  102. esphome/components/esp32_ble_server/ble_service.cpp +17 -15
  103. esphome/components/esp32_ble_server/ble_service.h +10 -14
  104. esphome/components/esp32_ble_tracker/__init__.py +6 -39
  105. esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +33 -10
  106. esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +8 -4
  107. esphome/components/esp32_dac/esp32_dac.cpp +16 -7
  108. esphome/components/esp32_dac/esp32_dac.h +8 -0
  109. esphome/components/esp32_dac/output.py +16 -4
  110. esphome/components/esp32_improv/__init__.py +2 -8
  111. esphome/components/esp32_improv/esp32_improv_component.cpp +21 -20
  112. esphome/components/esp32_improv/esp32_improv_component.h +3 -4
  113. esphome/components/esp32_rmt/__init__.py +28 -3
  114. esphome/components/esp32_rmt_led_strip/led_strip.cpp +73 -6
  115. esphome/components/esp32_rmt_led_strip/led_strip.h +21 -3
  116. esphome/components/esp32_rmt_led_strip/light.py +72 -7
  117. esphome/components/esp32_touch/esp32_touch.cpp +5 -0
  118. esphome/components/esp8266/__init__.py +1 -0
  119. esphome/components/esp8266/gpio.h +1 -0
  120. esphome/components/ethernet/__init__.py +10 -10
  121. esphome/components/event/event.cpp +4 -2
  122. esphome/components/event/event.h +2 -0
  123. esphome/components/event_emitter/__init__.py +5 -0
  124. esphome/components/event_emitter/event_emitter.cpp +14 -0
  125. esphome/components/event_emitter/event_emitter.h +63 -0
  126. esphome/components/font/__init__.py +1 -1
  127. esphome/components/gcja5/gcja5.cpp +2 -1
  128. esphome/components/graph/graph.cpp +4 -9
  129. esphome/components/haier/haier_base.cpp +2 -1
  130. esphome/components/haier/hon_climate.cpp +2 -1
  131. esphome/components/heatpumpir/heatpumpir.cpp +2 -1
  132. esphome/components/host/__init__.py +1 -0
  133. esphome/components/host/gpio.h +1 -0
  134. esphome/components/http_request/http_request.h +2 -2
  135. esphome/components/http_request/http_request_arduino.cpp +1 -1
  136. esphome/components/http_request/http_request_idf.cpp +1 -1
  137. esphome/components/i2c/i2c_bus_esp_idf.cpp +4 -0
  138. esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp +7 -5
  139. esphome/components/i2s_audio/speaker/__init__.py +53 -6
  140. esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +92 -46
  141. esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +8 -0
  142. esphome/components/ili9xxx/display.py +29 -11
  143. esphome/components/ili9xxx/ili9xxx_display.cpp +2 -5
  144. esphome/components/ili9xxx/ili9xxx_display.h +2 -1
  145. esphome/components/image/__init__.py +443 -255
  146. esphome/components/image/image.cpp +115 -61
  147. esphome/components/image/image.h +15 -24
  148. esphome/components/json/json_util.cpp +8 -34
  149. esphome/components/libretiny/__init__.py +1 -0
  150. esphome/components/libretiny/gpio_arduino.h +1 -0
  151. esphome/components/light/light_color_values.h +1 -1
  152. esphome/components/logger/__init__.py +45 -9
  153. esphome/components/logger/logger.cpp +16 -14
  154. esphome/components/logger/logger.h +11 -7
  155. esphome/components/logger/select/__init__.py +29 -0
  156. esphome/components/logger/select/logger_level_select.cpp +27 -0
  157. esphome/components/logger/select/logger_level_select.h +15 -0
  158. esphome/components/lvgl/__init__.py +96 -73
  159. esphome/components/lvgl/automation.py +39 -7
  160. esphome/components/lvgl/defines.py +8 -2
  161. esphome/components/lvgl/lvgl_esphome.cpp +8 -15
  162. esphome/components/lvgl/lvgl_esphome.h +20 -5
  163. esphome/components/lvgl/schemas.py +25 -14
  164. esphome/components/lvgl/trigger.py +27 -3
  165. esphome/components/lvgl/widgets/dropdown.py +1 -1
  166. esphome/components/lvgl/widgets/keyboard.py +8 -1
  167. esphome/components/lvgl/widgets/meter.py +2 -1
  168. esphome/components/lvgl/widgets/msgbox.py +1 -1
  169. esphome/components/lvgl/widgets/obj.py +1 -12
  170. esphome/components/lvgl/widgets/page.py +37 -2
  171. esphome/components/lvgl/widgets/tabview.py +1 -1
  172. esphome/components/max6956/max6956.h +2 -0
  173. esphome/components/mcp23016/mcp23016.h +2 -0
  174. esphome/components/mcp23xxx_base/mcp23xxx_base.h +2 -0
  175. esphome/components/mdns/__init__.py +1 -1
  176. esphome/components/media_player/__init__.py +37 -8
  177. esphome/components/media_player/automation.h +11 -2
  178. esphome/components/media_player/media_player.cpp +8 -0
  179. esphome/components/media_player/media_player.h +8 -4
  180. esphome/components/micronova/switch/micronova_switch.cpp +4 -2
  181. esphome/components/midea/ac_automations.h +3 -1
  182. esphome/components/midea/air_conditioner.cpp +7 -5
  183. esphome/components/midea/air_conditioner.h +1 -1
  184. esphome/components/midea/climate.py +4 -2
  185. esphome/components/midea/ir_transmitter.h +36 -5
  186. esphome/components/mixer/__init__.py +0 -0
  187. esphome/components/mixer/speaker/__init__.py +172 -0
  188. esphome/components/mixer/speaker/automation.h +19 -0
  189. esphome/components/mixer/speaker/mixer_speaker.cpp +624 -0
  190. esphome/components/mixer/speaker/mixer_speaker.h +207 -0
  191. esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp +7 -13
  192. esphome/components/mpr121/mpr121.h +2 -0
  193. esphome/components/mqtt/__init__.py +1 -1
  194. esphome/components/mqtt/mqtt_client.cpp +7 -1
  195. esphome/components/mqtt/mqtt_client.h +1 -1
  196. esphome/components/mqtt/mqtt_climate.cpp +2 -2
  197. esphome/components/network/ip_address.h +2 -0
  198. esphome/components/nextion/automation.h +17 -0
  199. esphome/components/nextion/display.py +42 -17
  200. esphome/components/nextion/nextion.cpp +4 -10
  201. esphome/components/nextion/nextion.h +89 -82
  202. esphome/components/nextion/nextion_commands.cpp +10 -10
  203. esphome/components/ntc/sensor.py +2 -4
  204. esphome/components/online_image/__init__.py +98 -46
  205. esphome/components/online_image/bmp_image.cpp +101 -0
  206. esphome/components/online_image/bmp_image.h +40 -0
  207. esphome/components/online_image/image_decoder.cpp +31 -2
  208. esphome/components/online_image/image_decoder.h +24 -15
  209. esphome/components/online_image/jpeg_image.cpp +92 -0
  210. esphome/components/online_image/jpeg_image.h +34 -0
  211. esphome/components/online_image/online_image.cpp +118 -58
  212. esphome/components/online_image/online_image.h +39 -9
  213. esphome/components/online_image/png_image.cpp +7 -3
  214. esphome/components/online_image/png_image.h +2 -1
  215. esphome/components/opentherm/__init__.py +73 -7
  216. esphome/components/opentherm/automation.h +25 -0
  217. esphome/components/opentherm/const.py +1 -0
  218. esphome/components/opentherm/generate.py +39 -6
  219. esphome/components/opentherm/hub.cpp +117 -79
  220. esphome/components/opentherm/hub.h +31 -15
  221. esphome/components/opentherm/opentherm.cpp +47 -23
  222. esphome/components/opentherm/opentherm.h +27 -6
  223. esphome/components/opentherm/opentherm_macros.h +11 -0
  224. esphome/components/opentherm/schema.py +78 -1
  225. esphome/components/opentherm/validate.py +7 -2
  226. esphome/components/pca6416a/pca6416a.h +2 -0
  227. esphome/components/pca9554/pca9554.h +2 -0
  228. esphome/components/pcf8574/pcf8574.h +2 -0
  229. esphome/components/preferences/__init__.py +2 -4
  230. esphome/components/preferences/syncer.h +10 -3
  231. esphome/components/prometheus/prometheus_handler.cpp +313 -0
  232. esphome/components/prometheus/prometheus_handler.h +48 -7
  233. esphome/components/psram/psram.cpp +8 -1
  234. esphome/components/pulse_counter/pulse_counter_sensor.cpp +14 -9
  235. esphome/components/pulse_counter/pulse_counter_sensor.h +4 -4
  236. esphome/components/pulse_meter/pulse_meter_sensor.cpp +2 -0
  237. esphome/components/qspi_dbi/__init__.py +3 -0
  238. esphome/components/qspi_dbi/display.py +74 -47
  239. esphome/components/qspi_dbi/models.py +245 -2
  240. esphome/components/qspi_dbi/qspi_dbi.cpp +9 -16
  241. esphome/components/qspi_dbi/qspi_dbi.h +2 -2
  242. esphome/components/remote_base/__init__.py +77 -25
  243. esphome/components/remote_base/remote_base.cpp +1 -1
  244. esphome/components/remote_base/remote_base.h +20 -2
  245. esphome/components/remote_base/toto_protocol.cpp +100 -0
  246. esphome/components/remote_base/toto_protocol.h +45 -0
  247. esphome/components/remote_receiver/__init__.py +55 -10
  248. esphome/components/remote_receiver/remote_receiver.h +36 -3
  249. esphome/components/remote_receiver/remote_receiver_esp32.cpp +145 -6
  250. esphome/components/remote_transmitter/__init__.py +62 -4
  251. esphome/components/remote_transmitter/remote_transmitter.h +21 -2
  252. esphome/components/remote_transmitter/remote_transmitter_esp32.cpp +140 -4
  253. esphome/components/remote_transmitter/remote_transmitter_esp8266.cpp +3 -3
  254. esphome/components/remote_transmitter/remote_transmitter_libretiny.cpp +3 -3
  255. esphome/components/resampler/__init__.py +0 -0
  256. esphome/components/resampler/speaker/__init__.py +103 -0
  257. esphome/components/resampler/speaker/resampler_speaker.cpp +318 -0
  258. esphome/components/resampler/speaker/resampler_speaker.h +107 -0
  259. esphome/components/resistance/resistance_sensor.h +2 -3
  260. esphome/components/resistance/sensor.py +2 -9
  261. esphome/components/rotary_encoder/rotary_encoder.cpp +8 -4
  262. esphome/components/rp2040/__init__.py +1 -0
  263. esphome/components/rp2040/gpio.h +1 -0
  264. esphome/components/rtl87xx/__init__.py +2 -0
  265. esphome/components/scd30/sensor.py +1 -1
  266. esphome/components/sdl/binary_sensor.py +270 -0
  267. esphome/components/sdl/sdl_esphome.cpp +16 -0
  268. esphome/components/sdl/sdl_esphome.h +9 -0
  269. esphome/components/seeed_mr60bha2/binary_sensor.py +25 -0
  270. esphome/components/seeed_mr60bha2/seeed_mr60bha2.cpp +26 -2
  271. esphome/components/seeed_mr60bha2/seeed_mr60bha2.h +9 -20
  272. esphome/components/seeed_mr60bha2/sensor.py +9 -1
  273. esphome/components/sn74hc165/sn74hc165.h +3 -0
  274. esphome/components/sn74hc595/sn74hc595.h +3 -0
  275. esphome/components/speaker/__init__.py +5 -4
  276. esphome/components/speaker/media_player/__init__.py +458 -0
  277. esphome/components/speaker/media_player/audio_pipeline.cpp +568 -0
  278. esphome/components/speaker/media_player/audio_pipeline.h +159 -0
  279. esphome/components/speaker/media_player/automation.h +26 -0
  280. esphome/components/speaker/media_player/speaker_media_player.cpp +577 -0
  281. esphome/components/speaker/media_player/speaker_media_player.h +160 -0
  282. esphome/components/speaker/speaker.h +20 -0
  283. esphome/components/spi/__init__.py +1 -5
  284. esphome/components/spi/spi.cpp +7 -1
  285. esphome/components/spi/spi.h +21 -2
  286. esphome/components/spi_led_strip/light.py +3 -5
  287. esphome/components/spi_led_strip/spi_led_strip.cpp +67 -0
  288. esphome/components/spi_led_strip/spi_led_strip.h +8 -60
  289. esphome/components/sprinkler/sprinkler.cpp +3 -1
  290. esphome/components/sx1509/sx1509_gpio_pin.h +2 -0
  291. esphome/components/tca9555/tca9555.h +2 -0
  292. esphome/components/toshiba/toshiba.cpp +2 -1
  293. esphome/components/tuya/light/tuya_light.cpp +4 -2
  294. esphome/components/uart/uart_component_esp32_arduino.cpp +2 -2
  295. esphome/components/uart/uart_component_esp_idf.cpp +2 -2
  296. esphome/components/udp/__init__.py +8 -2
  297. esphome/components/udp/udp_component.cpp +25 -56
  298. esphome/components/udp/udp_component.h +3 -0
  299. esphome/components/uponor_smatrix/sensor/__init__.py +14 -4
  300. esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.cpp +5 -0
  301. esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.h +1 -0
  302. esphome/components/uptime/text_sensor/__init__.py +19 -0
  303. esphome/components/uptime/text_sensor/uptime_text_sensor.cpp +63 -0
  304. esphome/components/uptime/text_sensor/uptime_text_sensor.h +25 -0
  305. esphome/components/voice_assistant/voice_assistant.cpp +24 -14
  306. esphome/components/voice_assistant/voice_assistant.h +8 -0
  307. esphome/components/waveshare_epaper/display.py +22 -1
  308. esphome/components/waveshare_epaper/waveshare_213v3.cpp +9 -3
  309. esphome/components/waveshare_epaper/waveshare_epaper.cpp +1155 -44
  310. esphome/components/waveshare_epaper/waveshare_epaper.h +208 -7
  311. esphome/components/web_server/web_server.cpp +28 -6
  312. esphome/components/weikai/weikai.h +2 -0
  313. esphome/components/wifi/__init__.py +6 -6
  314. esphome/components/wifi/wifi_component.cpp +1 -1
  315. esphome/components/wifi/wifi_component_esp32_arduino.cpp +30 -1
  316. esphome/components/wireguard/__init__.py +2 -2
  317. esphome/components/xl9535/xl9535.h +2 -0
  318. esphome/components/xxtea/__init__.py +3 -0
  319. esphome/components/xxtea/xxtea.cpp +46 -0
  320. esphome/components/xxtea/xxtea.h +26 -0
  321. esphome/components/yashima/yashima.cpp +2 -1
  322. esphome/config.py +9 -5
  323. esphome/config_validation.py +55 -17
  324. esphome/const.py +7 -10
  325. esphome/core/__init__.py +6 -13
  326. esphome/core/base_automation.h +1 -0
  327. esphome/core/config.py +59 -72
  328. esphome/core/defines.h +9 -1
  329. esphome/core/gpio.h +7 -0
  330. esphome/core/helpers.cpp +19 -15
  331. esphome/core/helpers.h +57 -8
  332. esphome/core/log.h +9 -7
  333. esphome/cpp_generator.py +2 -2
  334. esphome/dashboard/web_server.py +1 -1
  335. esphome/espota2.py +3 -2
  336. esphome/loader.py +12 -4
  337. esphome/log.py +5 -7
  338. esphome/yaml_util.py +2 -2
  339. {esphome-2024.12.4.dist-info → esphome-2025.2.0.dist-info}/METADATA +14 -9
  340. {esphome-2024.12.4.dist-info → esphome-2025.2.0.dist-info}/RECORD +349 -300
  341. esphome/components/custom/binary_sensor/custom_binary_sensor.cpp +0 -16
  342. esphome/components/custom/binary_sensor/custom_binary_sensor.h +0 -26
  343. esphome/components/custom/climate/custom_climate.h +0 -22
  344. esphome/components/custom/cover/custom_cover.h +0 -21
  345. esphome/components/custom/light/custom_light_output.h +0 -24
  346. esphome/components/custom/output/custom_output.h +0 -37
  347. esphome/components/custom/sensor/custom_sensor.cpp +0 -16
  348. esphome/components/custom/sensor/custom_sensor.h +0 -24
  349. esphome/components/custom/switch/custom_switch.cpp +0 -16
  350. esphome/components/custom/switch/custom_switch.h +0 -24
  351. esphome/components/custom/text_sensor/custom_text_sensor.cpp +0 -16
  352. esphome/components/custom/text_sensor/custom_text_sensor.h +0 -26
  353. esphome/components/custom_component/custom_component.h +0 -28
  354. esphome/components/esp32_ble_server/ble_2901.cpp +0 -18
  355. esphome/components/esp32_ble_server/ble_2901.h +0 -19
  356. esphome/components/resistance_sampler/__init__.py +0 -6
  357. esphome/components/resistance_sampler/resistance_sampler.h +0 -10
  358. esphome/components/uptime/{sensor.py → sensor/__init__.py} +3 -3
  359. /esphome/components/uptime/{uptime_seconds_sensor.cpp → sensor/uptime_seconds_sensor.cpp} +0 -0
  360. /esphome/components/uptime/{uptime_seconds_sensor.h → sensor/uptime_seconds_sensor.h} +0 -0
  361. /esphome/components/uptime/{uptime_timestamp_sensor.cpp → sensor/uptime_timestamp_sensor.cpp} +0 -0
  362. /esphome/components/uptime/{uptime_timestamp_sensor.h → sensor/uptime_timestamp_sensor.h} +0 -0
  363. {esphome-2024.12.4.dist-info → esphome-2025.2.0.dist-info}/LICENSE +0 -0
  364. {esphome-2024.12.4.dist-info → esphome-2025.2.0.dist-info}/WHEEL +0 -0
  365. {esphome-2024.12.4.dist-info → esphome-2025.2.0.dist-info}/entry_points.txt +0 -0
  366. {esphome-2024.12.4.dist-info → esphome-2025.2.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,125 @@
1
+ #include "es7243e.h"
2
+ #include "es7243e_const.h"
3
+
4
+ #include "esphome/core/hal.h"
5
+ #include "esphome/core/log.h"
6
+
7
+ #include <cinttypes>
8
+
9
+ namespace esphome {
10
+ namespace es7243e {
11
+
12
+ static const char *const TAG = "es7243e";
13
+
14
+ // Mark the component as failed; use only in setup
15
+ #define ES7243E_ERROR_FAILED(func) \
16
+ if (!(func)) { \
17
+ this->mark_failed(); \
18
+ return; \
19
+ }
20
+
21
+ // Return false; use outside of setup
22
+ #define ES7243E_ERROR_CHECK(func) \
23
+ if (!(func)) { \
24
+ return false; \
25
+ }
26
+
27
+ void ES7243E::dump_config() {
28
+ ESP_LOGCONFIG(TAG, "ES7243E audio ADC:");
29
+
30
+ if (this->is_failed()) {
31
+ ESP_LOGE(TAG, " Failed to initialize");
32
+ return;
33
+ }
34
+ }
35
+
36
+ void ES7243E::setup() {
37
+ ESP_LOGCONFIG(TAG, "Setting up ES7243E...");
38
+
39
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG01, 0x3A));
40
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_RESET_REG00, 0x80));
41
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_TEST_MODE_REGF9, 0x00));
42
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG04, 0x02));
43
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG04, 0x01));
44
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_TEST_MODE_REGF9, 0x01));
45
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_RESET_REG00, 0x1E));
46
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG01, 0x00));
47
+
48
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG02, 0x00));
49
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG03, 0x20));
50
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG04, 0x01));
51
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ADC_CTRL_REG0D, 0x00));
52
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG05, 0x00));
53
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG06, 0x03)); // SCLK=MCLK/4
54
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG07, 0x00)); // LRCK=MCLK/256
55
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG08, 0xFF)); // LRCK=MCLK/256
56
+
57
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG09, 0xCA));
58
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_SDP_REG0A, 0x85));
59
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_SDP_REG0B, 0x00));
60
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ADC_CTRL_REG0E, 0xBF));
61
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ADC_CTRL_REG0F, 0x80));
62
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ADC_CTRL_REG14, 0x0C));
63
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ADC_CTRL_REG15, 0x0C));
64
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG17, 0x02));
65
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG18, 0x26));
66
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG19, 0x77));
67
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG1A, 0xF4));
68
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG1B, 0x66));
69
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG1C, 0x44));
70
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG1E, 0x00));
71
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG1F, 0x0C));
72
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG20, 0x1A)); // PGA gain +30dB
73
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG21, 0x1A));
74
+
75
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_RESET_REG00, 0x80));
76
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG01, 0x3A));
77
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG16, 0x3F));
78
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG16, 0x00));
79
+
80
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_TEST_MODE_REGF9, 0x00));
81
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG04, 0x01));
82
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG17, 0x01));
83
+ ES7243E_ERROR_FAILED(this->configure_mic_gain_());
84
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_RESET_REG00, 0x80));
85
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG01, 0x3A));
86
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG16, 0x3F));
87
+ ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG16, 0x00));
88
+
89
+ this->setup_complete_ = true;
90
+ }
91
+
92
+ bool ES7243E::set_mic_gain(float mic_gain) {
93
+ this->mic_gain_ = clamp<float>(mic_gain, 0, 37.5);
94
+ if (this->setup_complete_) {
95
+ return this->configure_mic_gain_();
96
+ }
97
+ return true;
98
+ }
99
+
100
+ bool ES7243E::configure_mic_gain_() {
101
+ auto regv = this->es7243e_gain_reg_value_(this->mic_gain_);
102
+
103
+ ES7243E_ERROR_CHECK(this->write_byte(ES7243E_ANALOG_REG20, 0x10 | regv));
104
+ ES7243E_ERROR_CHECK(this->write_byte(ES7243E_ANALOG_REG21, 0x10 | regv));
105
+
106
+ return true;
107
+ }
108
+
109
+ uint8_t ES7243E::es7243e_gain_reg_value_(float mic_gain) {
110
+ // reg: 12 - 34.5dB, 13 - 36dB, 14 - 37.5dB
111
+ mic_gain += 0.5;
112
+ if (mic_gain <= 33.0) {
113
+ return (uint8_t) mic_gain / 3;
114
+ }
115
+ if (mic_gain < 36.0) {
116
+ return 12;
117
+ }
118
+ if (mic_gain < 37.0) {
119
+ return 13;
120
+ }
121
+ return 14;
122
+ }
123
+
124
+ } // namespace es7243e
125
+ } // namespace esphome
@@ -0,0 +1,37 @@
1
+ #pragma once
2
+
3
+ #include "esphome/components/audio_adc/audio_adc.h"
4
+ #include "esphome/components/i2c/i2c.h"
5
+ #include "esphome/core/component.h"
6
+
7
+ namespace esphome {
8
+ namespace es7243e {
9
+
10
+ class ES7243E : public audio_adc::AudioAdc, public Component, public i2c::I2CDevice {
11
+ /* Class for configuring an ES7243E ADC for microphone input.
12
+ * Based on code from:
13
+ * - https://github.com/espressif/esp-adf/ (accessed 20250116)
14
+ */
15
+ public:
16
+ void setup() override;
17
+ float get_setup_priority() const override { return setup_priority::DATA; }
18
+ void dump_config() override;
19
+
20
+ bool set_mic_gain(float mic_gain) override;
21
+
22
+ float mic_gain() override { return this->mic_gain_; };
23
+
24
+ protected:
25
+ /// @brief Convert floating point mic gain value to register value
26
+ /// @param mic_gain Gain value to convert
27
+ /// @return Corresponding register value for specified gain
28
+ uint8_t es7243e_gain_reg_value_(float mic_gain);
29
+
30
+ bool configure_mic_gain_();
31
+
32
+ bool setup_complete_{false};
33
+ float mic_gain_{0};
34
+ };
35
+
36
+ } // namespace es7243e
37
+ } // namespace esphome
@@ -0,0 +1,54 @@
1
+ #pragma once
2
+
3
+ #include <cinttypes>
4
+
5
+ namespace esphome {
6
+ namespace es7243e {
7
+
8
+ // ES7243E register addresses
9
+ static const uint8_t ES7243E_RESET_REG00 = 0x00; // Reset control
10
+ static const uint8_t ES7243E_CLOCK_MGR_REG01 = 0x01; // MCLK/BCLK/ADCCLK/Analog clocks on/off
11
+ static const uint8_t ES7243E_CLOCK_MGR_REG02 = 0x02; // MCLK & BCLK configuration, source selection
12
+
13
+ static const uint8_t ES7243E_CLOCK_MGR_REG03 = 0x03; // ADC Over-sample rate control
14
+ static const uint8_t ES7243E_CLOCK_MGR_REG04 = 0x04; // Pre-divide/Pre-multiplication
15
+ static const uint8_t ES7243E_CLOCK_MGR_REG05 = 0x05; // CF/DSP clock divider
16
+ static const uint8_t ES7243E_CLOCK_MGR_REG06 = 0x06; // BCLK divider at master mode
17
+ static const uint8_t ES7243E_CLOCK_MGR_REG07 = 0x07; // BCLK/LRCK/SDOUT tri-state control/LRCK divider bit 11->8
18
+ static const uint8_t ES7243E_CLOCK_MGR_REG08 = 0x08; // Master LRCK divider bit 7 to bit 0
19
+ static const uint8_t ES7243E_CLOCK_MGR_REG09 = 0x09; // SEL S1/Timer for S1
20
+ static const uint8_t ES7243E_SDP_REG0A = 0x0A; // SEL S3/Timer for S3
21
+ static const uint8_t ES7243E_SDP_REG0B = 0x0B; // SDP out mute control/I2S/left-justify case/word length/format
22
+ static const uint8_t ES7243E_SDP_REG0C = 0x0C; // NFS flag at slot0/LSB/TDM mode selection
23
+ static const uint8_t ES7243E_ADC_CTRL_REG0D = 0x0D; // data mux/pol. inv./ram clear on lrck/mclk active/gain scale up
24
+ static const uint8_t ES7243E_ADC_CTRL_REG0E = 0x0E; // volume control
25
+ static const uint8_t ES7243E_ADC_CTRL_REG0F = 0x0F; // offset freeze/auto level control/automute control/VC ramp rate
26
+ static const uint8_t ES7243E_ADC_CTRL_REG10 = 0x10; // automute noise gate/detection
27
+ static const uint8_t ES7243E_ADC_CTRL_REG11 = 0x11; // automute SDP control/out gain select
28
+ static const uint8_t ES7243E_ADC_CTRL_REG12 = 0x12; // controls for automute PDN_PGA/MOD/reset/digital circuit
29
+ static const uint8_t ES7243E_ADC_CTRL_REG13 = 0x13; // ALC rate selection/ALC target level
30
+ static const uint8_t ES7243E_ADC_CTRL_REG14 = 0x14; // ADCHPF stage1 coeff
31
+ static const uint8_t ES7243E_ADC_CTRL_REG15 = 0x15; // ADCHPF stage2 coeff
32
+ static const uint8_t ES7243E_ANALOG_REG16 = 0x16; // power-down/reset
33
+ static const uint8_t ES7243E_ANALOG_REG17 = 0x17; // VMIDSEL
34
+ static const uint8_t ES7243E_ANALOG_REG18 = 0x18; // ADC/ADCFL bias
35
+ static const uint8_t ES7243E_ANALOG_REG19 = 0x19; // PGA1/PGA2 bias
36
+ static const uint8_t ES7243E_ANALOG_REG1A = 0x1A; // ADCI1/ADCI23 bias
37
+ static const uint8_t ES7243E_ANALOG_REG1B = 0x1B; // ADCSM/ADCCM bias
38
+ static const uint8_t ES7243E_ANALOG_REG1C = 0x1C; // ADCVRP/ADCCPP bias
39
+ static const uint8_t ES7243E_ANALOG_REG1D = 0x1D; // low power bits
40
+ static const uint8_t ES7243E_ANALOG_REG1E = 0x1E; // low power bits
41
+ static const uint8_t ES7243E_ANALOG_REG1F = 0x1F; // ADC_DMIC_ON/REFSEL/VX2OFF/VX1SEL/VMIDLVL
42
+ static const uint8_t ES7243E_ANALOG_REG20 = 0x20; // select MIC1 as PGA1 input/PGA1 gain
43
+ static const uint8_t ES7243E_ANALOG_REG21 = 0x21; // select MIC2 as PGA1 input/PGA2 gain
44
+ static const uint8_t ES7243E_TEST_MODE_REGF7 = 0xF7;
45
+ static const uint8_t ES7243E_TEST_MODE_REGF8 = 0xF8;
46
+ static const uint8_t ES7243E_TEST_MODE_REGF9 = 0xF9;
47
+ static const uint8_t ES7243E_I2C_CONF_REGFA = 0xFA; // I2C signals retime/reset registers to default
48
+ static const uint8_t ES7243E_FLAG_REGFC = 0xFC; // CSM flag/ADC automute flag (RO)
49
+ static const uint8_t ES7243E_CHIP_ID1_REGFD = 0xFD; // chip ID 1, reads 0x7A (RO)
50
+ static const uint8_t ES7243E_CHIP_ID2_REGFE = 0xFE; // chip ID 2, reads 0x43 (RO)
51
+ static const uint8_t ES7243E_CHIP_VERSION_REGFF = 0xFF; // chip version, reads 0x00 (RO)
52
+
53
+ } // namespace es7243e
54
+ } // namespace esphome
File without changes
@@ -0,0 +1,27 @@
1
+ import esphome.codegen as cg
2
+ from esphome.components import i2c
3
+ from esphome.components.audio_dac import AudioDac
4
+ import esphome.config_validation as cv
5
+ from esphome.const import CONF_ID
6
+
7
+ CODEOWNERS = ["@kbx81"]
8
+ DEPENDENCIES = ["i2c"]
9
+
10
+ es8156_ns = cg.esphome_ns.namespace("es8156")
11
+ ES8156 = es8156_ns.class_("ES8156", AudioDac, cg.Component, i2c.I2CDevice)
12
+
13
+ CONFIG_SCHEMA = (
14
+ cv.Schema(
15
+ {
16
+ cv.GenerateID(): cv.declare_id(ES8156),
17
+ }
18
+ )
19
+ .extend(cv.COMPONENT_SCHEMA)
20
+ .extend(i2c.i2c_device_schema(0x08))
21
+ )
22
+
23
+
24
+ async def to_code(config):
25
+ var = cg.new_Pvariable(config[CONF_ID])
26
+ await cg.register_component(var, config)
27
+ await i2c.register_i2c_device(var, config)
@@ -0,0 +1,87 @@
1
+ #include "es8156.h"
2
+ #include "es8156_const.h"
3
+ #include "esphome/core/hal.h"
4
+ #include "esphome/core/log.h"
5
+ #include <cinttypes>
6
+
7
+ namespace esphome {
8
+ namespace es8156 {
9
+
10
+ static const char *const TAG = "es8156";
11
+
12
+ // Mark the component as failed; use only in setup
13
+ #define ES8156_ERROR_FAILED(func) \
14
+ if (!(func)) { \
15
+ this->mark_failed(); \
16
+ return; \
17
+ }
18
+
19
+ void ES8156::setup() {
20
+ ESP_LOGCONFIG(TAG, "Setting up ES8156...");
21
+
22
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG02_SCLK_MODE, 0x04));
23
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG20_ANALOG_SYS1, 0x2A));
24
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG21_ANALOG_SYS2, 0x3C));
25
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG22_ANALOG_SYS3, 0x00));
26
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG24_ANALOG_LP, 0x07));
27
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG23_ANALOG_SYS4, 0x00));
28
+
29
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG0A_TIME_CONTROL1, 0x01));
30
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG0B_TIME_CONTROL2, 0x01));
31
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG11_DAC_SDP, 0x00));
32
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG19_EQ_CONTROL1, 0x20));
33
+
34
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG0D_P2S_CONTROL, 0x14));
35
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG09_MISC_CONTROL2, 0x00));
36
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG18_MISC_CONTROL3, 0x00));
37
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG08_CLOCK_ON_OFF, 0x3F));
38
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG00_RESET, 0x02));
39
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG00_RESET, 0x03));
40
+ ES8156_ERROR_FAILED(this->write_byte(ES8156_REG25_ANALOG_SYS5, 0x20));
41
+ }
42
+
43
+ void ES8156::dump_config() {
44
+ ESP_LOGCONFIG(TAG, "ES8156 Audio Codec:");
45
+
46
+ if (this->is_failed()) {
47
+ ESP_LOGCONFIG(TAG, " Failed to initialize");
48
+ return;
49
+ }
50
+ }
51
+
52
+ bool ES8156::set_volume(float volume) {
53
+ volume = clamp(volume, 0.0f, 1.0f);
54
+ uint8_t reg = remap<uint8_t, float>(volume, 0.0f, 1.0f, 0, 255);
55
+ ESP_LOGV(TAG, "Setting ES8156_REG14_VOLUME_CONTROL to %u (volume: %f)", reg, volume);
56
+ return this->write_byte(ES8156_REG14_VOLUME_CONTROL, reg);
57
+ }
58
+
59
+ float ES8156::volume() {
60
+ uint8_t reg;
61
+ this->read_byte(ES8156_REG14_VOLUME_CONTROL, &reg);
62
+ return remap<float, uint8_t>(reg, 0, 255, 0.0f, 1.0f);
63
+ }
64
+
65
+ bool ES8156::set_mute_state_(bool mute_state) {
66
+ uint8_t reg13;
67
+
68
+ this->is_muted_ = mute_state;
69
+
70
+ if (!this->read_byte(ES8156_REG13_DAC_MUTE, &reg13)) {
71
+ return false;
72
+ }
73
+
74
+ ESP_LOGV(TAG, "Read ES8156_REG13_DAC_MUTE: %u", reg13);
75
+
76
+ if (mute_state) {
77
+ reg13 |= BIT(1) | BIT(2);
78
+ } else {
79
+ reg13 &= ~(BIT(1) | BIT(2));
80
+ }
81
+
82
+ ESP_LOGV(TAG, "Setting ES8156_REG13_DAC_MUTE to %u (muted: %s)", reg13, YESNO(mute_state));
83
+ return this->write_byte(ES8156_REG13_DAC_MUTE, reg13);
84
+ }
85
+
86
+ } // namespace es8156
87
+ } // namespace esphome
@@ -0,0 +1,51 @@
1
+ #pragma once
2
+
3
+ #include "esphome/components/audio_dac/audio_dac.h"
4
+ #include "esphome/components/i2c/i2c.h"
5
+ #include "esphome/core/component.h"
6
+
7
+ namespace esphome {
8
+ namespace es8156 {
9
+
10
+ class ES8156 : public audio_dac::AudioDac, public Component, public i2c::I2CDevice {
11
+ public:
12
+ /////////////////////////
13
+ // Component overrides //
14
+ /////////////////////////
15
+
16
+ void setup() override;
17
+ float get_setup_priority() const override { return setup_priority::DATA; }
18
+ void dump_config() override;
19
+
20
+ ////////////////////////
21
+ // AudioDac overrides //
22
+ ////////////////////////
23
+
24
+ /// @brief Writes the volume out to the DAC
25
+ /// @param volume floating point between 0.0 and 1.0
26
+ /// @return True if successful and false otherwise
27
+ bool set_volume(float volume) override;
28
+
29
+ /// @brief Gets the current volume out from the DAC
30
+ /// @return floating point between 0.0 and 1.0
31
+ float volume() override;
32
+
33
+ /// @brief Disables mute for audio out
34
+ /// @return True if successful and false otherwise
35
+ bool set_mute_off() override { return this->set_mute_state_(false); }
36
+
37
+ /// @brief Enables mute for audio out
38
+ /// @return True if successful and false otherwise
39
+ bool set_mute_on() override { return this->set_mute_state_(true); }
40
+
41
+ bool is_muted() override { return this->is_muted_; }
42
+
43
+ protected:
44
+ /// @brief Mutes or unmutes the DAC audio out
45
+ /// @param mute_state True to mute, false to unmute
46
+ /// @return True if successful and false otherwise
47
+ bool set_mute_state_(bool mute_state);
48
+ };
49
+
50
+ } // namespace es8156
51
+ } // namespace esphome
@@ -0,0 +1,68 @@
1
+ #pragma once
2
+
3
+ #include "es8156.h"
4
+
5
+ namespace esphome {
6
+ namespace es8156 {
7
+
8
+ /* ES8156 register addresses */
9
+ /*
10
+ * RESET Control
11
+ */
12
+ static const uint8_t ES8156_REG00_RESET = 0x00;
13
+ /*
14
+ * Clock Managerment
15
+ */
16
+ static const uint8_t ES8156_REG01_MAINCLOCK_CTL = 0x01;
17
+ static const uint8_t ES8156_REG02_SCLK_MODE = 0x02;
18
+ static const uint8_t ES8156_REG03_LRCLK_DIV_H = 0x03;
19
+ static const uint8_t ES8156_REG04_LRCLK_DIV_L = 0x04;
20
+ static const uint8_t ES8156_REG05_SCLK_DIV = 0x05;
21
+ static const uint8_t ES8156_REG06_NFS_CONFIG = 0x06;
22
+ static const uint8_t ES8156_REG07_MISC_CONTROL1 = 0x07;
23
+ static const uint8_t ES8156_REG08_CLOCK_ON_OFF = 0x08;
24
+ static const uint8_t ES8156_REG09_MISC_CONTROL2 = 0x09;
25
+ static const uint8_t ES8156_REG0A_TIME_CONTROL1 = 0x0a;
26
+ static const uint8_t ES8156_REG0B_TIME_CONTROL2 = 0x0b;
27
+ /*
28
+ * System Control
29
+ */
30
+ static const uint8_t ES8156_REG0C_CHIP_STATUS = 0x0c;
31
+ static const uint8_t ES8156_REG0D_P2S_CONTROL = 0x0d;
32
+ static const uint8_t ES8156_REG10_DAC_OSR_COUNTER = 0x10;
33
+ /*
34
+ * SDP Control
35
+ */
36
+ static const uint8_t ES8156_REG11_DAC_SDP = 0x11;
37
+ static const uint8_t ES8156_REG12_AUTOMUTE_SET = 0x12;
38
+ static const uint8_t ES8156_REG13_DAC_MUTE = 0x13;
39
+ static const uint8_t ES8156_REG14_VOLUME_CONTROL = 0x14;
40
+
41
+ /*
42
+ * ALC Control
43
+ */
44
+ static const uint8_t ES8156_REG15_ALC_CONFIG1 = 0x15;
45
+ static const uint8_t ES8156_REG16_ALC_CONFIG2 = 0x16;
46
+ static const uint8_t ES8156_REG17_ALC_CONFIG3 = 0x17;
47
+ static const uint8_t ES8156_REG18_MISC_CONTROL3 = 0x18;
48
+ static const uint8_t ES8156_REG19_EQ_CONTROL1 = 0x19;
49
+ static const uint8_t ES8156_REG1A_EQ_CONTROL2 = 0x1a;
50
+ /*
51
+ * Analog System Control
52
+ */
53
+ static const uint8_t ES8156_REG20_ANALOG_SYS1 = 0x20;
54
+ static const uint8_t ES8156_REG21_ANALOG_SYS2 = 0x21;
55
+ static const uint8_t ES8156_REG22_ANALOG_SYS3 = 0x22;
56
+ static const uint8_t ES8156_REG23_ANALOG_SYS4 = 0x23;
57
+ static const uint8_t ES8156_REG24_ANALOG_LP = 0x24;
58
+ static const uint8_t ES8156_REG25_ANALOG_SYS5 = 0x25;
59
+ /*
60
+ * Chip Information
61
+ */
62
+ static const uint8_t ES8156_REGFC_I2C_PAGESEL = 0xFC;
63
+ static const uint8_t ES8156_REGFD_CHIPID1 = 0xFD;
64
+ static const uint8_t ES8156_REGFE_CHIPID0 = 0xFE;
65
+ static const uint8_t ES8156_REGFF_CHIP_VERSION = 0xFF;
66
+
67
+ } // namespace es8156
68
+ } // namespace esphome
@@ -2,7 +2,7 @@ import esphome.codegen as cg
2
2
  from esphome.components import i2c
3
3
  from esphome.components.audio_dac import AudioDac
4
4
  import esphome.config_validation as cv
5
- from esphome.const import CONF_BITS_PER_SAMPLE, CONF_ID, CONF_SAMPLE_RATE
5
+ from esphome.const import CONF_BITS_PER_SAMPLE, CONF_ID, CONF_MIC_GAIN, CONF_SAMPLE_RATE
6
6
 
7
7
  CODEOWNERS = ["@kroimon", "@kahrendt"]
8
8
  DEPENDENCIES = ["i2c"]
@@ -10,7 +10,6 @@ DEPENDENCIES = ["i2c"]
10
10
  es8311_ns = cg.esphome_ns.namespace("es8311")
11
11
  ES8311 = es8311_ns.class_("ES8311", AudioDac, cg.Component, i2c.I2CDevice)
12
12
 
13
- CONF_MIC_GAIN = "mic_gain"
14
13
  CONF_USE_MCLK = "use_mclk"
15
14
  CONF_USE_MICROPHONE = "use_microphone"
16
15
 
@@ -64,6 +64,7 @@ from .gpio import esp32_pin_to_code # noqa
64
64
  _LOGGER = logging.getLogger(__name__)
65
65
  CODEOWNERS = ["@esphome/core"]
66
66
  AUTO_LOAD = ["preferences"]
67
+ IS_TARGET_PLATFORM = True
67
68
 
68
69
  CONF_RELEASE = "release"
69
70
 
@@ -58,7 +58,11 @@ uint32_t arch_get_cpu_cycle_count() { return esp_cpu_get_cycle_count(); }
58
58
  #else
59
59
  uint32_t arch_get_cpu_cycle_count() { return cpu_hal_get_cycle_count(); }
60
60
  #endif
61
- uint32_t arch_get_cpu_freq_hz() { return rtc_clk_apb_freq_get(); }
61
+ uint32_t arch_get_cpu_freq_hz() {
62
+ rtc_cpu_freq_config_t config;
63
+ rtc_clk_cpu_freq_get_config(&config);
64
+ return config.freq_mhz * 1000000U;
65
+ }
62
66
 
63
67
  #ifdef USE_ESP_IDF
64
68
  TaskHandle_t loop_task_handle = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
@@ -13,6 +13,7 @@ class ESP32InternalGPIOPin : public InternalGPIOPin {
13
13
  void set_inverted(bool inverted) { inverted_ = inverted; }
14
14
  void set_drive_strength(gpio_drive_cap_t drive_strength) { drive_strength_ = drive_strength; }
15
15
  void set_flags(gpio::Flags flags) { flags_ = flags; }
16
+
16
17
  void setup() override;
17
18
  void pin_mode(gpio::Flags flags) override;
18
19
  bool digital_read() override;
@@ -21,6 +22,7 @@ class ESP32InternalGPIOPin : public InternalGPIOPin {
21
22
  void detach_interrupt() const override;
22
23
  ISRInternalGPIOPin to_isr() const override;
23
24
  uint8_t get_pin() const override { return (uint8_t) pin_; }
25
+ gpio::Flags get_flags() const override { return flags_; }
24
26
  bool is_inverted() const override { return inverted_; }
25
27
 
26
28
  protected:
@@ -1,3 +1,5 @@
1
+ import re
2
+
1
3
  from esphome import automation
2
4
  import esphome.codegen as cg
3
5
  from esphome.components.esp32 import add_idf_sdkconfig_option, const, get_esp32_variant
@@ -64,6 +66,43 @@ CONFIG_SCHEMA = cv.Schema(
64
66
  ).extend(cv.COMPONENT_SCHEMA)
65
67
 
66
68
 
69
+ bt_uuid16_format = "XXXX"
70
+ bt_uuid32_format = "XXXXXXXX"
71
+ bt_uuid128_format = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
72
+
73
+
74
+ def bt_uuid(value):
75
+ in_value = cv.string_strict(value)
76
+ value = in_value.upper()
77
+
78
+ if len(value) == len(bt_uuid16_format):
79
+ pattern = re.compile("^[A-F|0-9]{4,}$")
80
+ if not pattern.match(value):
81
+ raise cv.Invalid(
82
+ f"Invalid hexadecimal value for 16 bit UUID format: '{in_value}'"
83
+ )
84
+ return value
85
+ if len(value) == len(bt_uuid32_format):
86
+ pattern = re.compile("^[A-F|0-9]{8,}$")
87
+ if not pattern.match(value):
88
+ raise cv.Invalid(
89
+ f"Invalid hexadecimal value for 32 bit UUID format: '{in_value}'"
90
+ )
91
+ return value
92
+ if len(value) == len(bt_uuid128_format):
93
+ pattern = re.compile(
94
+ "^[A-F|0-9]{8,}-[A-F|0-9]{4,}-[A-F|0-9]{4,}-[A-F|0-9]{4,}-[A-F|0-9]{12,}$"
95
+ )
96
+ if not pattern.match(value):
97
+ raise cv.Invalid(
98
+ f"Invalid hexadecimal value for 128 UUID format: '{in_value}'"
99
+ )
100
+ return value
101
+ raise cv.Invalid(
102
+ f"Bluetooth UUID must be in 16 bit '{bt_uuid16_format}', 32 bit '{bt_uuid32_format}', or 128 bit '{bt_uuid128_format}' format"
103
+ )
104
+
105
+
67
106
  def validate_variant(_):
68
107
  variant = get_esp32_variant()
69
108
  if variant in NO_BLUETOOTH_VARIANTS:
@@ -26,10 +26,10 @@ template<class T> class Queue {
26
26
  void push(T *element) {
27
27
  if (element == nullptr)
28
28
  return;
29
- if (xSemaphoreTake(m_, 5L / portTICK_PERIOD_MS)) {
30
- q_.push(element);
31
- xSemaphoreGive(m_);
32
- }
29
+ // It is not called from main loop. Thus it won't block main thread.
30
+ xSemaphoreTake(m_, portMAX_DELAY);
31
+ q_.push(element);
32
+ xSemaphoreGive(m_);
33
33
  }
34
34
 
35
35
  T *pop() {
@@ -44,6 +44,50 @@ void BLEClientBase::loop() {
44
44
 
45
45
  float BLEClientBase::get_setup_priority() const { return setup_priority::AFTER_BLUETOOTH; }
46
46
 
47
+ void BLEClientBase::dump_config() {
48
+ ESP_LOGCONFIG(TAG, " Address: %s", this->address_str().c_str());
49
+ ESP_LOGCONFIG(TAG, " Auto-Connect: %s", TRUEFALSE(this->auto_connect_));
50
+ std::string state_name;
51
+ switch (this->state()) {
52
+ case espbt::ClientState::INIT:
53
+ state_name = "INIT";
54
+ break;
55
+ case espbt::ClientState::DISCONNECTING:
56
+ state_name = "DISCONNECTING";
57
+ break;
58
+ case espbt::ClientState::IDLE:
59
+ state_name = "IDLE";
60
+ break;
61
+ case espbt::ClientState::SEARCHING:
62
+ state_name = "SEARCHING";
63
+ break;
64
+ case espbt::ClientState::DISCOVERED:
65
+ state_name = "DISCOVERED";
66
+ break;
67
+ case espbt::ClientState::READY_TO_CONNECT:
68
+ state_name = "READY_TO_CONNECT";
69
+ break;
70
+ case espbt::ClientState::CONNECTING:
71
+ state_name = "CONNECTING";
72
+ break;
73
+ case espbt::ClientState::CONNECTED:
74
+ state_name = "CONNECTED";
75
+ break;
76
+ case espbt::ClientState::ESTABLISHED:
77
+ state_name = "ESTABLISHED";
78
+ break;
79
+ default:
80
+ state_name = "UNKNOWN_STATE";
81
+ break;
82
+ }
83
+ ESP_LOGCONFIG(TAG, " State: %s", state_name.c_str());
84
+ if (this->status_ == ESP_GATT_NO_RESOURCES) {
85
+ ESP_LOGE(TAG, " Failed due to no resources. Try to reduce number of BLE clients in config.");
86
+ } else if (this->status_ != ESP_GATT_OK) {
87
+ ESP_LOGW(TAG, " Failed due to error code %d", this->status_);
88
+ }
89
+ }
90
+
47
91
  bool BLEClientBase::parse_device(const espbt::ESPBTDevice &device) {
48
92
  if (!this->auto_connect_)
49
93
  return false;
@@ -129,6 +173,8 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
129
173
  } else {
130
174
  ESP_LOGE(TAG, "[%d] [%s] gattc app registration failed id=%d code=%d", this->connection_index_,
131
175
  this->address_str_.c_str(), param->reg.app_id, param->reg.status);
176
+ this->status_ = param->reg.status;
177
+ this->mark_failed();
132
178
  }
133
179
  break;
134
180
  }
@@ -26,6 +26,7 @@ class BLEClientBase : public espbt::ESPBTClient, public Component {
26
26
  void setup() override;
27
27
  void loop() override;
28
28
  float get_setup_priority() const override;
29
+ void dump_config() override;
29
30
 
30
31
  void run_later(std::function<void()> &&f); // NOLINT
31
32
  bool parse_device(const espbt::ESPBTDevice &device) override;
@@ -103,6 +104,7 @@ class BLEClientBase : public espbt::ESPBTClient, public Component {
103
104
  bool paired_{false};
104
105
  espbt::ConnectionType connection_type_{espbt::ConnectionType::V1};
105
106
  std::vector<BLEService *> services_;
107
+ esp_gatt_status_t status_{ESP_GATT_OK};
106
108
 
107
109
  void log_event_(const char *name);
108
110
  };