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
@@ -23,6 +23,7 @@ void DHT::dump_config() {
23
23
  } else {
24
24
  ESP_LOGCONFIG(TAG, " Model: DHT22 (or equivalent)");
25
25
  }
26
+ ESP_LOGCONFIG(TAG, " Internal Pull-up: %s", ONOFF(this->pin_->get_flags() & gpio::FLAG_PULLUP));
26
27
 
27
28
  LOG_UPDATE_INTERVAL(this);
28
29
 
@@ -101,7 +102,7 @@ bool HOT IRAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, bool r
101
102
  } else {
102
103
  delayMicroseconds(800);
103
104
  }
104
- this->pin_->pin_mode(gpio::FLAG_INPUT | gpio::FLAG_PULLUP);
105
+ this->pin_->pin_mode(this->pin_->get_flags());
105
106
 
106
107
  {
107
108
  InterruptLock lock;
@@ -157,8 +158,9 @@ bool HOT IRAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, bool r
157
158
  if (bit == 0) {
158
159
  bit = 7;
159
160
  byte++;
160
- } else
161
+ } else {
161
162
  bit--;
163
+ }
162
164
  }
163
165
  }
164
166
  if (!report_errors && error_code != 0)
@@ -34,7 +34,7 @@ DHT = dht_ns.class_("DHT", cg.PollingComponent)
34
34
  CONFIG_SCHEMA = cv.Schema(
35
35
  {
36
36
  cv.GenerateID(): cv.declare_id(DHT),
37
- cv.Required(CONF_PIN): pins.internal_gpio_input_pin_schema,
37
+ cv.Required(CONF_PIN): pins.internal_gpio_input_pullup_pin_schema,
38
38
  cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
39
39
  unit_of_measurement=UNIT_CELSIUS,
40
40
  accuracy_decimals=1,
@@ -39,6 +39,7 @@ DisplayOnPageChangeTrigger = display_ns.class_(
39
39
 
40
40
  CONF_ON_PAGE_CHANGE = "on_page_change"
41
41
  CONF_SHOW_TEST_CARD = "show_test_card"
42
+ CONF_UNSPECIFIED = "unspecified"
42
43
 
43
44
  DISPLAY_ROTATIONS = {
44
45
  0: display_ns.DISPLAY_ROTATION_0_DEGREES,
@@ -55,16 +56,22 @@ def validate_rotation(value):
55
56
  return cv.enum(DISPLAY_ROTATIONS, int=True)(value)
56
57
 
57
58
 
59
+ def validate_auto_clear(value):
60
+ if value == CONF_UNSPECIFIED:
61
+ return value
62
+ return cv.boolean(value)
63
+
64
+
58
65
  BASIC_DISPLAY_SCHEMA = cv.Schema(
59
66
  {
60
- cv.Optional(CONF_LAMBDA): cv.lambda_,
67
+ cv.Exclusive(CONF_LAMBDA, CONF_LAMBDA): cv.lambda_,
61
68
  }
62
69
  ).extend(cv.polling_component_schema("1s"))
63
70
 
64
71
  FULL_DISPLAY_SCHEMA = BASIC_DISPLAY_SCHEMA.extend(
65
72
  {
66
73
  cv.Optional(CONF_ROTATION): validate_rotation,
67
- cv.Optional(CONF_PAGES): cv.All(
74
+ cv.Exclusive(CONF_PAGES, CONF_LAMBDA): cv.All(
68
75
  cv.ensure_list(
69
76
  {
70
77
  cv.GenerateID(): cv.declare_id(DisplayPage),
@@ -82,7 +89,9 @@ FULL_DISPLAY_SCHEMA = BASIC_DISPLAY_SCHEMA.extend(
82
89
  cv.Optional(CONF_TO): cv.use_id(DisplayPage),
83
90
  }
84
91
  ),
85
- cv.Optional(CONF_AUTO_CLEAR_ENABLED, default=True): cv.boolean,
92
+ cv.Optional(
93
+ CONF_AUTO_CLEAR_ENABLED, default=CONF_UNSPECIFIED
94
+ ): validate_auto_clear,
86
95
  cv.Optional(CONF_SHOW_TEST_CARD): cv.boolean,
87
96
  }
88
97
  )
@@ -92,8 +101,12 @@ async def setup_display_core_(var, config):
92
101
  if CONF_ROTATION in config:
93
102
  cg.add(var.set_rotation(DISPLAY_ROTATIONS[config[CONF_ROTATION]]))
94
103
 
95
- if CONF_AUTO_CLEAR_ENABLED in config:
96
- cg.add(var.set_auto_clear(config[CONF_AUTO_CLEAR_ENABLED]))
104
+ if (auto_clear := config.get(CONF_AUTO_CLEAR_ENABLED)) is not None:
105
+ # Default to true if pages or lambda is specified. Ideally this would be done during validation, but
106
+ # the possible schemas are too complex to do this easily.
107
+ if auto_clear == CONF_UNSPECIFIED:
108
+ auto_clear = CONF_LAMBDA in config or CONF_PAGES in config
109
+ cg.add(var.set_auto_clear(auto_clear))
97
110
 
98
111
  if CONF_PAGES in config:
99
112
  pages = []
@@ -266,8 +266,9 @@ void Display::filled_gauge(int center_x, int center_y, int radius1, int radius2,
266
266
  if (dymax < float(-dxmax) * tan_a) {
267
267
  upd_dxmax = ceil(float(dymax) / tan_a);
268
268
  hline_width = -dxmax - upd_dxmax + 1;
269
- } else
269
+ } else {
270
270
  hline_width = 0;
271
+ }
271
272
  }
272
273
  if (hline_width > 0)
273
274
  this->horizontal_line(center_x + dxmax, center_y - dymax, hline_width, color);
@@ -814,8 +815,20 @@ void Display::test_card() {
814
815
 
815
816
  DisplayPage::DisplayPage(display_writer_t writer) : writer_(std::move(writer)) {}
816
817
  void DisplayPage::show() { this->parent_->show_page(this); }
817
- void DisplayPage::show_next() { this->next_->show(); }
818
- void DisplayPage::show_prev() { this->prev_->show(); }
818
+ void DisplayPage::show_next() {
819
+ if (this->next_ == nullptr) {
820
+ ESP_LOGE(TAG, "no next page");
821
+ return;
822
+ }
823
+ this->next_->show();
824
+ }
825
+ void DisplayPage::show_prev() {
826
+ if (this->prev_ == nullptr) {
827
+ ESP_LOGE(TAG, "no previous page");
828
+ return;
829
+ }
830
+ this->prev_->show();
831
+ }
819
832
  void DisplayPage::set_parent(Display *parent) { this->parent_ = parent; }
820
833
  void DisplayPage::set_prev(DisplayPage *prev) { this->prev_ = prev; }
821
834
  void DisplayPage::set_next(DisplayPage *next) { this->next_ = next; }
@@ -90,8 +90,9 @@ void Rect::info(const std::string &prefix) {
90
90
  if (this->is_set()) {
91
91
  ESP_LOGI(TAG, "%s [%3d,%3d,%3d,%3d] (%3d,%3d)", prefix.c_str(), this->x, this->y, this->w, this->h, this->x2(),
92
92
  this->y2());
93
- } else
93
+ } else {
94
94
  ESP_LOGI(TAG, "%s ** IS NOT SET **", prefix.c_str());
95
+ }
95
96
  }
96
97
 
97
98
  } // namespace display
File without changes
@@ -0,0 +1,51 @@
1
+ import esphome.codegen as cg
2
+ from esphome.components import i2c
3
+ from esphome.components.audio_adc import AudioAdc
4
+ import esphome.config_validation as cv
5
+ from esphome.const import CONF_BITS_PER_SAMPLE, CONF_ID, CONF_MIC_GAIN, CONF_SAMPLE_RATE
6
+
7
+ CODEOWNERS = ["@kahrendt"]
8
+ DEPENDENCIES = ["i2c"]
9
+
10
+ es7210_ns = cg.esphome_ns.namespace("es7210")
11
+ ES7210 = es7210_ns.class_("ES7210", AudioAdc, cg.Component, i2c.I2CDevice)
12
+
13
+
14
+ es7210_bits_per_sample = es7210_ns.enum("ES7210BitsPerSample")
15
+ ES7210_BITS_PER_SAMPLE_ENUM = {
16
+ 16: es7210_bits_per_sample.ES7210_BITS_PER_SAMPLE_16,
17
+ 24: es7210_bits_per_sample.ES7210_BITS_PER_SAMPLE_24,
18
+ 32: es7210_bits_per_sample.ES7210_BITS_PER_SAMPLE_32,
19
+ }
20
+
21
+
22
+ ES7210_MIC_GAINS = [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 34.5, 36, 37.5]
23
+
24
+ _validate_bits = cv.float_with_unit("bits", "bit")
25
+
26
+ CONFIG_SCHEMA = (
27
+ cv.Schema(
28
+ {
29
+ cv.GenerateID(): cv.declare_id(ES7210),
30
+ cv.Optional(CONF_BITS_PER_SAMPLE, default="16bit"): cv.All(
31
+ _validate_bits, cv.enum(ES7210_BITS_PER_SAMPLE_ENUM)
32
+ ),
33
+ cv.Optional(CONF_MIC_GAIN, default="24db"): cv.All(
34
+ cv.decibel, cv.one_of(*ES7210_MIC_GAINS)
35
+ ),
36
+ cv.Optional(CONF_SAMPLE_RATE, default=16000): cv.int_range(min=1),
37
+ }
38
+ )
39
+ .extend(cv.COMPONENT_SCHEMA)
40
+ .extend(i2c.i2c_device_schema(0x40))
41
+ )
42
+
43
+
44
+ async def to_code(config):
45
+ var = cg.new_Pvariable(config[CONF_ID])
46
+ await cg.register_component(var, config)
47
+ await i2c.register_i2c_device(var, config)
48
+
49
+ cg.add(var.set_bits_per_sample(config[CONF_BITS_PER_SAMPLE]))
50
+ cg.add(var.set_mic_gain(config[CONF_MIC_GAIN]))
51
+ cg.add(var.set_sample_rate(config[CONF_SAMPLE_RATE]))
@@ -0,0 +1,228 @@
1
+ #include "es7210.h"
2
+ #include "es7210_const.h"
3
+ #include "esphome/core/hal.h"
4
+ #include "esphome/core/log.h"
5
+ #include <cinttypes>
6
+
7
+ namespace esphome {
8
+ namespace es7210 {
9
+
10
+ static const char *const TAG = "es7210";
11
+
12
+ static const size_t MCLK_DIV_FRE = 256;
13
+
14
+ // Mark the component as failed; use only in setup
15
+ #define ES7210_ERROR_FAILED(func) \
16
+ if (!(func)) { \
17
+ this->mark_failed(); \
18
+ return; \
19
+ }
20
+
21
+ // Return false; use outside of setup
22
+ #define ES7210_ERROR_CHECK(func) \
23
+ if (!(func)) { \
24
+ return false; \
25
+ }
26
+
27
+ void ES7210::dump_config() {
28
+ ESP_LOGCONFIG(TAG, "ES7210 audio ADC:");
29
+ ESP_LOGCONFIG(TAG, " Bits Per Sample: %" PRIu8, this->bits_per_sample_);
30
+ ESP_LOGCONFIG(TAG, " Sample Rate: %" PRIu32, this->sample_rate_);
31
+
32
+ if (this->is_failed()) {
33
+ ESP_LOGE(TAG, " Failed to initialize");
34
+ return;
35
+ }
36
+ }
37
+
38
+ void ES7210::setup() {
39
+ ESP_LOGCONFIG(TAG, "Setting up ES7210...");
40
+
41
+ // Software reset
42
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_RESET_REG00, 0xff));
43
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_RESET_REG00, 0x32));
44
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_CLOCK_OFF_REG01, 0x3f));
45
+
46
+ // Set initialization time when device powers up
47
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_TIME_CONTROL0_REG09, 0x30));
48
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_TIME_CONTROL1_REG0A, 0x30));
49
+
50
+ // Configure HFP for all ADC channels
51
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_ADC12_HPF2_REG23, 0x2a));
52
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_ADC12_HPF1_REG22, 0x0a));
53
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_ADC34_HPF2_REG20, 0x0a));
54
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_ADC34_HPF1_REG21, 0x2a));
55
+
56
+ // Secondary I2S mode settings
57
+ ES7210_ERROR_FAILED(this->es7210_update_reg_bit_(ES7210_MODE_CONFIG_REG08, 0x01, 0x00));
58
+
59
+ // Configure analog power
60
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_ANALOG_REG40, 0xC3));
61
+
62
+ // Set mic bias
63
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC12_BIAS_REG41, 0x70));
64
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC34_BIAS_REG42, 0x70));
65
+
66
+ // Configure I2S settings, sample rate, and microphone gains
67
+ ES7210_ERROR_FAILED(this->configure_i2s_format_());
68
+ ES7210_ERROR_FAILED(this->configure_sample_rate_());
69
+ ES7210_ERROR_FAILED(this->configure_mic_gain_());
70
+
71
+ // Power on mics 1 through 4
72
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC1_POWER_REG47, 0x08));
73
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC2_POWER_REG48, 0x08));
74
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC3_POWER_REG49, 0x08));
75
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC4_POWER_REG4A, 0x08));
76
+
77
+ // Power down DLL
78
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_POWER_DOWN_REG06, 0x04));
79
+
80
+ // Power on MIC1-4 bias & ADC1-4 & PGA1-4 Power
81
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC12_POWER_REG4B, 0x0F));
82
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC34_POWER_REG4C, 0x0F));
83
+
84
+ // Enable device
85
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_RESET_REG00, 0x71));
86
+ ES7210_ERROR_FAILED(this->write_byte(ES7210_RESET_REG00, 0x41));
87
+
88
+ this->setup_complete_ = true;
89
+ }
90
+
91
+ bool ES7210::set_mic_gain(float mic_gain) {
92
+ this->mic_gain_ = clamp<float>(mic_gain, ES7210_MIC_GAIN_MIN, ES7210_MIC_GAIN_MAX);
93
+ if (this->setup_complete_) {
94
+ return this->configure_mic_gain_();
95
+ }
96
+ return true;
97
+ }
98
+
99
+ bool ES7210::configure_sample_rate_() {
100
+ int mclk_fre = this->sample_rate_ * MCLK_DIV_FRE;
101
+ int coeff = -1;
102
+
103
+ for (int i = 0; i < (sizeof(ES7210_COEFFICIENTS) / sizeof(ES7210_COEFFICIENTS[0])); ++i) {
104
+ if (ES7210_COEFFICIENTS[i].lrclk == this->sample_rate_ && ES7210_COEFFICIENTS[i].mclk == mclk_fre)
105
+ coeff = i;
106
+ }
107
+
108
+ if (coeff >= 0) {
109
+ // Set adc_div & doubler & dll
110
+ uint8_t regv;
111
+ ES7210_ERROR_CHECK(this->read_byte(ES7210_MAINCLK_REG02, &regv));
112
+ regv = regv & 0x00;
113
+ regv |= ES7210_COEFFICIENTS[coeff].adc_div;
114
+ regv |= ES7210_COEFFICIENTS[coeff].doubler << 6;
115
+ regv |= ES7210_COEFFICIENTS[coeff].dll << 7;
116
+
117
+ ES7210_ERROR_CHECK(this->write_byte(ES7210_MAINCLK_REG02, regv));
118
+
119
+ // Set osr
120
+ regv = ES7210_COEFFICIENTS[coeff].osr;
121
+ ES7210_ERROR_CHECK(this->write_byte(ES7210_OSR_REG07, regv));
122
+ // Set lrck
123
+ regv = ES7210_COEFFICIENTS[coeff].lrck_h;
124
+ ES7210_ERROR_CHECK(this->write_byte(ES7210_LRCK_DIVH_REG04, regv));
125
+ regv = ES7210_COEFFICIENTS[coeff].lrck_l;
126
+ ES7210_ERROR_CHECK(this->write_byte(ES7210_LRCK_DIVL_REG05, regv));
127
+ } else {
128
+ // Invalid sample frequency
129
+ ESP_LOGE(TAG, "Invalid sample rate");
130
+ return false;
131
+ }
132
+
133
+ return true;
134
+ }
135
+
136
+ bool ES7210::configure_mic_gain_() {
137
+ auto regv = this->es7210_gain_reg_value_(this->mic_gain_);
138
+ for (uint8_t i = 0; i < 4; ++i) {
139
+ ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC1_GAIN_REG43 + i, 0x10, 0x00));
140
+ }
141
+ ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC12_POWER_REG4B, 0xff));
142
+ ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC34_POWER_REG4C, 0xff));
143
+
144
+ // Configure mic 1
145
+ ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00));
146
+ ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC12_POWER_REG4B, 0x00));
147
+ ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC1_GAIN_REG43, 0x10, 0x10));
148
+ ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC1_GAIN_REG43, 0x0f, regv));
149
+
150
+ // Configure mic 2
151
+ ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00));
152
+ ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC12_POWER_REG4B, 0x00));
153
+ ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC2_GAIN_REG44, 0x10, 0x10));
154
+ ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC2_GAIN_REG44, 0x0f, regv));
155
+
156
+ // Configure mic 3
157
+ ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00));
158
+ ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC34_POWER_REG4C, 0x00));
159
+ ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC3_GAIN_REG45, 0x10, 0x10));
160
+ ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC3_GAIN_REG45, 0x0f, regv));
161
+
162
+ // Configure mic 4
163
+ ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00));
164
+ ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC34_POWER_REG4C, 0x00));
165
+ ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC4_GAIN_REG46, 0x10, 0x10));
166
+ ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC4_GAIN_REG46, 0x0f, regv));
167
+
168
+ return true;
169
+ }
170
+
171
+ uint8_t ES7210::es7210_gain_reg_value_(float mic_gain) {
172
+ // reg: 12 - 34.5dB, 13 - 36dB, 14 - 37.5dB
173
+ mic_gain += 0.5;
174
+ if (mic_gain <= 33.0) {
175
+ return (uint8_t) mic_gain / 3;
176
+ }
177
+ if (mic_gain < 36.0) {
178
+ return 12;
179
+ }
180
+ if (mic_gain < 37.0) {
181
+ return 13;
182
+ }
183
+ return 14;
184
+ }
185
+
186
+ bool ES7210::configure_i2s_format_() {
187
+ // Configure bits per sample
188
+ uint8_t reg_val = 0;
189
+ switch (this->bits_per_sample_) {
190
+ case ES7210_BITS_PER_SAMPLE_16:
191
+ reg_val = 0x60;
192
+ break;
193
+ case ES7210_BITS_PER_SAMPLE_18:
194
+ reg_val = 0x40;
195
+ break;
196
+ case ES7210_BITS_PER_SAMPLE_20:
197
+ reg_val = 0x20;
198
+ break;
199
+ case ES7210_BITS_PER_SAMPLE_24:
200
+ reg_val = 0x00;
201
+ break;
202
+ case ES7210_BITS_PER_SAMPLE_32:
203
+ reg_val = 0x80;
204
+ break;
205
+ default:
206
+ return false;
207
+ }
208
+ ES7210_ERROR_CHECK(this->write_byte(ES7210_SDP_INTERFACE1_REG11, reg_val));
209
+
210
+ if (this->enable_tdm_) {
211
+ ES7210_ERROR_CHECK(this->write_byte(ES7210_SDP_INTERFACE2_REG12, 0x02));
212
+ } else {
213
+ // Microphones 1 and 2 output on SDOUT1, microphones 3 and 4 output on SDOUT2
214
+ ES7210_ERROR_CHECK(this->write_byte(ES7210_SDP_INTERFACE2_REG12, 0x00));
215
+ }
216
+
217
+ return true;
218
+ }
219
+
220
+ bool ES7210::es7210_update_reg_bit_(uint8_t reg_addr, uint8_t update_bits, uint8_t data) {
221
+ uint8_t regv;
222
+ ES7210_ERROR_CHECK(this->read_byte(reg_addr, &regv));
223
+ regv = (regv & (~update_bits)) | (update_bits & data);
224
+ return this->write_byte(reg_addr, regv);
225
+ }
226
+
227
+ } // namespace es7210
228
+ } // namespace esphome
@@ -0,0 +1,62 @@
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
+ #include "es7210_const.h"
8
+
9
+ namespace esphome {
10
+ namespace es7210 {
11
+
12
+ enum ES7210BitsPerSample : uint8_t {
13
+ ES7210_BITS_PER_SAMPLE_16 = 16,
14
+ ES7210_BITS_PER_SAMPLE_18 = 18,
15
+ ES7210_BITS_PER_SAMPLE_20 = 20,
16
+ ES7210_BITS_PER_SAMPLE_24 = 24,
17
+ ES7210_BITS_PER_SAMPLE_32 = 32,
18
+ };
19
+
20
+ class ES7210 : public audio_adc::AudioAdc, public Component, public i2c::I2CDevice {
21
+ /* Class for configuring an ES7210 ADC for microphone input.
22
+ * Based on code from:
23
+ * - https://github.com/espressif/esp-bsp/ (accessed 20241219)
24
+ * - https://github.com/espressif/esp-adf/ (accessed 20241219)
25
+ */
26
+ public:
27
+ void setup() override;
28
+ float get_setup_priority() const override { return setup_priority::DATA; }
29
+ void dump_config() override;
30
+
31
+ void set_bits_per_sample(ES7210BitsPerSample bits_per_sample) { this->bits_per_sample_ = bits_per_sample; }
32
+ bool set_mic_gain(float mic_gain) override;
33
+ void set_sample_rate(uint32_t sample_rate) { this->sample_rate_ = sample_rate; }
34
+
35
+ float mic_gain() override { return this->mic_gain_; };
36
+
37
+ protected:
38
+ /// @brief Updates an I2C registry address by modifying the current state
39
+ /// @param reg_addr I2C register address
40
+ /// @param update_bits Mask of allowed bits to be modified
41
+ /// @param data Bit values to be written
42
+ /// @return True if successful, false otherwise
43
+ bool es7210_update_reg_bit_(uint8_t reg_addr, uint8_t update_bits, uint8_t data);
44
+
45
+ /// @brief Convert floating point mic gain value to register value
46
+ /// @param mic_gain Gain value to convert
47
+ /// @return Corresponding register value for specified gain
48
+ uint8_t es7210_gain_reg_value_(float mic_gain);
49
+
50
+ bool configure_i2s_format_();
51
+ bool configure_mic_gain_();
52
+ bool configure_sample_rate_();
53
+
54
+ bool setup_complete_{false};
55
+ bool enable_tdm_{false}; // TDM is unsupported in ESPHome as of version 2024.12
56
+ float mic_gain_{0};
57
+ ES7210BitsPerSample bits_per_sample_{ES7210_BITS_PER_SAMPLE_16};
58
+ uint32_t sample_rate_{0};
59
+ };
60
+
61
+ } // namespace es7210
62
+ } // namespace esphome
@@ -0,0 +1,129 @@
1
+ #pragma once
2
+
3
+ #include <cinttypes>
4
+
5
+ namespace esphome {
6
+ namespace es7210 {
7
+
8
+ // ES7210 register addresses
9
+ static const uint8_t ES7210_RESET_REG00 = 0x00; /* Reset control */
10
+ static const uint8_t ES7210_CLOCK_OFF_REG01 = 0x01; /* Used to turn off the ADC clock */
11
+ static const uint8_t ES7210_MAINCLK_REG02 = 0x02; /* Set ADC clock frequency division */
12
+
13
+ static const uint8_t ES7210_MASTER_CLK_REG03 = 0x03; /* MCLK source $ SCLK division */
14
+ static const uint8_t ES7210_LRCK_DIVH_REG04 = 0x04; /* lrck_divh */
15
+ static const uint8_t ES7210_LRCK_DIVL_REG05 = 0x05; /* lrck_divl */
16
+ static const uint8_t ES7210_POWER_DOWN_REG06 = 0x06; /* power down */
17
+ static const uint8_t ES7210_OSR_REG07 = 0x07;
18
+ static const uint8_t ES7210_MODE_CONFIG_REG08 = 0x08; /* Set primary/secondary & channels */
19
+ static const uint8_t ES7210_TIME_CONTROL0_REG09 = 0x09; /* Set Chip intial state period*/
20
+ static const uint8_t ES7210_TIME_CONTROL1_REG0A = 0x0A; /* Set Power up state period */
21
+ static const uint8_t ES7210_SDP_INTERFACE1_REG11 = 0x11; /* Set sample & fmt */
22
+ static const uint8_t ES7210_SDP_INTERFACE2_REG12 = 0x12; /* Pins state */
23
+ static const uint8_t ES7210_ADC_AUTOMUTE_REG13 = 0x13; /* Set mute */
24
+ static const uint8_t ES7210_ADC34_MUTERANGE_REG14 = 0x14; /* Set mute range */
25
+ static const uint8_t ES7210_ADC12_MUTERANGE_REG15 = 0x15; /* Set mute range */
26
+ static const uint8_t ES7210_ADC34_HPF2_REG20 = 0x20; /* HPF */
27
+ static const uint8_t ES7210_ADC34_HPF1_REG21 = 0x21; /* HPF */
28
+ static const uint8_t ES7210_ADC12_HPF1_REG22 = 0x22; /* HPF */
29
+ static const uint8_t ES7210_ADC12_HPF2_REG23 = 0x23; /* HPF */
30
+ static const uint8_t ES7210_ANALOG_REG40 = 0x40; /* ANALOG Power */
31
+ static const uint8_t ES7210_MIC12_BIAS_REG41 = 0x41;
32
+ static const uint8_t ES7210_MIC34_BIAS_REG42 = 0x42;
33
+ static const uint8_t ES7210_MIC1_GAIN_REG43 = 0x43;
34
+ static const uint8_t ES7210_MIC2_GAIN_REG44 = 0x44;
35
+ static const uint8_t ES7210_MIC3_GAIN_REG45 = 0x45;
36
+ static const uint8_t ES7210_MIC4_GAIN_REG46 = 0x46;
37
+ static const uint8_t ES7210_MIC1_POWER_REG47 = 0x47;
38
+ static const uint8_t ES7210_MIC2_POWER_REG48 = 0x48;
39
+ static const uint8_t ES7210_MIC3_POWER_REG49 = 0x49;
40
+ static const uint8_t ES7210_MIC4_POWER_REG4A = 0x4A;
41
+ static const uint8_t ES7210_MIC12_POWER_REG4B = 0x4B; /* MICBias & ADC & PGA Power */
42
+ static const uint8_t ES7210_MIC34_POWER_REG4C = 0x4C;
43
+
44
+ /*
45
+ * Clock coefficient structure
46
+ */
47
+ struct ES7210Coefficient {
48
+ uint32_t mclk; // mclk frequency
49
+ uint32_t lrclk;
50
+ uint8_t ss_ds;
51
+ uint8_t adc_div;
52
+ uint8_t dll; // dll_bypass
53
+ uint8_t doubler; // doubler_enable
54
+ uint8_t osr; // adc osr
55
+ uint8_t mclk_src; // sselect mclk source
56
+ uint8_t lrck_h; // High 4 bits of lrck
57
+ uint8_t lrck_l; // Low 8 bits of lrck
58
+ };
59
+
60
+ /* Codec hifi mclk clock divider coefficients
61
+ * MEMBER REG
62
+ * mclk: 0x03
63
+ * lrck: standard
64
+ * ss_ds: --
65
+ * adc_div: 0x02
66
+ * dll: 0x06
67
+ * doubler: 0x02
68
+ * osr: 0x07
69
+ * mclk_src: 0x03
70
+ * lrckh: 0x04
71
+ * lrckl: 0x05
72
+ */
73
+ static const ES7210Coefficient ES7210_COEFFICIENTS[] = {
74
+ // mclk lrck ss_ds adc_div dll doubler osr mclk_src lrckh lrckl
75
+ /* 8k */
76
+ {12288000, 8000, 0x00, 0x03, 0x01, 0x00, 0x20, 0x00, 0x06, 0x00},
77
+ {16384000, 8000, 0x00, 0x04, 0x01, 0x00, 0x20, 0x00, 0x08, 0x00},
78
+ {19200000, 8000, 0x00, 0x1e, 0x00, 0x01, 0x28, 0x00, 0x09, 0x60},
79
+ {4096000, 8000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
80
+
81
+ /* 11.025k */
82
+ {11289600, 11025, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x01, 0x00},
83
+
84
+ /* 12k */
85
+ {12288000, 12000, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x04, 0x00},
86
+ {19200000, 12000, 0x00, 0x14, 0x00, 0x01, 0x28, 0x00, 0x06, 0x40},
87
+
88
+ /* 16k */
89
+ {4096000, 16000, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00},
90
+ {19200000, 16000, 0x00, 0x0a, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x80},
91
+ {16384000, 16000, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x04, 0x00},
92
+ {12288000, 16000, 0x00, 0x03, 0x01, 0x01, 0x20, 0x00, 0x03, 0x00},
93
+
94
+ /* 22.05k */
95
+ {11289600, 22050, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
96
+
97
+ /* 24k */
98
+ {12288000, 24000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
99
+ {19200000, 24000, 0x00, 0x0a, 0x00, 0x01, 0x28, 0x00, 0x03, 0x20},
100
+
101
+ /* 32k */
102
+ {12288000, 32000, 0x00, 0x03, 0x00, 0x00, 0x20, 0x00, 0x01, 0x80},
103
+ {16384000, 32000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
104
+ {19200000, 32000, 0x00, 0x05, 0x00, 0x00, 0x1e, 0x00, 0x02, 0x58},
105
+
106
+ /* 44.1k */
107
+ {11289600, 44100, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00},
108
+
109
+ /* 48k */
110
+ {12288000, 48000, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00},
111
+ {19200000, 48000, 0x00, 0x05, 0x00, 0x01, 0x28, 0x00, 0x01, 0x90},
112
+
113
+ /* 64k */
114
+ {16384000, 64000, 0x01, 0x01, 0x01, 0x00, 0x20, 0x00, 0x01, 0x00},
115
+ {19200000, 64000, 0x00, 0x05, 0x00, 0x01, 0x1e, 0x00, 0x01, 0x2c},
116
+
117
+ /* 88.2k */
118
+ {11289600, 88200, 0x01, 0x01, 0x01, 0x01, 0x20, 0x00, 0x00, 0x80},
119
+
120
+ /* 96k */
121
+ {12288000, 96000, 0x01, 0x01, 0x01, 0x01, 0x20, 0x00, 0x00, 0x80},
122
+ {19200000, 96000, 0x01, 0x05, 0x00, 0x01, 0x28, 0x00, 0x00, 0xc8},
123
+ };
124
+
125
+ static const float ES7210_MIC_GAIN_MIN = 0.0;
126
+ static const float ES7210_MIC_GAIN_MAX = 37.5;
127
+
128
+ } // namespace es7210
129
+ } // namespace esphome
File without changes
@@ -0,0 +1,34 @@
1
+ import esphome.codegen as cg
2
+ from esphome.components import i2c
3
+ from esphome.components.audio_adc import AudioAdc
4
+ import esphome.config_validation as cv
5
+ from esphome.const import CONF_ID, CONF_MIC_GAIN
6
+
7
+ CODEOWNERS = ["@kbx81"]
8
+ DEPENDENCIES = ["i2c"]
9
+
10
+ es7243e_ns = cg.esphome_ns.namespace("es7243e")
11
+ ES7243E = es7243e_ns.class_("ES7243E", AudioAdc, cg.Component, i2c.I2CDevice)
12
+
13
+ ES7243E_MIC_GAINS = [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 34.5, 36, 37.5]
14
+
15
+ CONFIG_SCHEMA = (
16
+ cv.Schema(
17
+ {
18
+ cv.GenerateID(): cv.declare_id(ES7243E),
19
+ cv.Optional(CONF_MIC_GAIN, default="24db"): cv.All(
20
+ cv.decibel, cv.one_of(*ES7243E_MIC_GAINS)
21
+ ),
22
+ }
23
+ )
24
+ .extend(cv.COMPONENT_SCHEMA)
25
+ .extend(i2c.i2c_device_schema(0x10))
26
+ )
27
+
28
+
29
+ async def to_code(config):
30
+ var = cg.new_Pvariable(config[CONF_ID])
31
+ await cg.register_component(var, config)
32
+ await i2c.register_i2c_device(var, config)
33
+
34
+ cg.add(var.set_mic_gain(config[CONF_MIC_GAIN]))