esphome 2024.12.3__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.3.dist-info → esphome-2025.2.0.dist-info}/METADATA +14 -9
  340. {esphome-2024.12.3.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.3.dist-info → esphome-2025.2.0.dist-info}/LICENSE +0 -0
  364. {esphome-2024.12.3.dist-info → esphome-2025.2.0.dist-info}/WHEEL +0 -0
  365. {esphome-2024.12.3.dist-info → esphome-2025.2.0.dist-info}/entry_points.txt +0 -0
  366. {esphome-2024.12.3.dist-info → esphome-2025.2.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,207 @@
1
+ #pragma once
2
+
3
+ #ifdef USE_ESP32
4
+
5
+ #include "esphome/components/audio/audio.h"
6
+ #include "esphome/components/audio/audio_transfer_buffer.h"
7
+ #include "esphome/components/speaker/speaker.h"
8
+
9
+ #include "esphome/core/component.h"
10
+
11
+ #include <freertos/event_groups.h>
12
+ #include <freertos/FreeRTOS.h>
13
+
14
+ namespace esphome {
15
+ namespace mixer_speaker {
16
+
17
+ /* Classes for mixing several source speaker audio streams and writing it to another speaker component.
18
+ * - Volume controls are passed through to the output speaker
19
+ * - Directly handles pausing at the SourceSpeaker level; pause state is not passed through to the output speaker.
20
+ * - Audio sent to the SourceSpeaker's must have 16 bits per sample.
21
+ * - Audio sent to the SourceSpeaker can have any number of channels. They are duplicated or ignored as needed to match
22
+ * the number of channels required for the output speaker.
23
+ * - In queue mode, the audio sent to the SoureSpeakers can have different sample rates.
24
+ * - In non-queue mode, the audio sent to the SourceSpeakers must have the same sample rates.
25
+ * - SourceSpeaker has an internal ring buffer. It also allocates a shared_ptr for an AudioTranserBuffer object.
26
+ * - Audio Data Flow:
27
+ * - Audio data played on a SourceSpeaker first writes to its internal ring buffer.
28
+ * - MixerSpeaker task temporarily takes shared ownership of each SourceSpeaker's AudioTransferBuffer.
29
+ * - MixerSpeaker calls SourceSpeaker's `process_data_from_source`, which tranfers audio from the SourceSpeaker's
30
+ * ring buffer to its AudioTransferBuffer. Audio ducking is applied at this step.
31
+ * - In queue mode, MixerSpeaker prioritizes the earliest configured SourceSpeaker with audio data. Audio data is
32
+ * sent to the output speaker.
33
+ * - In non-queue mode, MixerSpeaker adds all the audio data in each SourceSpeaker into one stream that is written
34
+ * to the output speaker.
35
+ */
36
+
37
+ class MixerSpeaker;
38
+
39
+ class SourceSpeaker : public speaker::Speaker, public Component {
40
+ public:
41
+ void dump_config() override;
42
+ void setup() override;
43
+ void loop() override;
44
+
45
+ size_t play(const uint8_t *data, size_t length, TickType_t ticks_to_wait) override;
46
+ size_t play(const uint8_t *data, size_t length) override { return this->play(data, length, 0); }
47
+
48
+ void start() override;
49
+ void stop() override;
50
+ void finish() override;
51
+
52
+ bool has_buffered_data() const override;
53
+
54
+ /// @brief Mute state changes are passed to the parent's output speaker
55
+ void set_mute_state(bool mute_state) override;
56
+
57
+ /// @brief Volume state changes are passed to the parent's output speaker
58
+ void set_volume(float volume) override;
59
+
60
+ void set_pause_state(bool pause_state) override { this->pause_state_ = pause_state; }
61
+ bool get_pause_state() const override { return this->pause_state_; }
62
+
63
+ /// @brief Transfers audio from the ring buffer into the transfer buffer. Ducks audio while transferring.
64
+ /// @param ticks_to_wait FreeRTOS ticks to wait while waiting to read from the ring buffer.
65
+ /// @return Number of bytes transferred from the ring buffer.
66
+ size_t process_data_from_source(TickType_t ticks_to_wait);
67
+
68
+ /// @brief Sets the ducking level for the source speaker.
69
+ /// @param decibel_reduction (uint8_t) The dB reduction level. For example, 0 is no change, 10 is a reduction by 10 dB
70
+ /// @param duration (uint32_t) The number of milliseconds to transition from the current level to the new level
71
+ void apply_ducking(uint8_t decibel_reduction, uint32_t duration);
72
+
73
+ void set_buffer_duration(uint32_t buffer_duration_ms) { this->buffer_duration_ms_ = buffer_duration_ms; }
74
+ void set_parent(MixerSpeaker *parent) { this->parent_ = parent; }
75
+ void set_timeout(uint32_t ms) { this->timeout_ms_ = ms; }
76
+
77
+ std::weak_ptr<audio::AudioSourceTransferBuffer> get_transfer_buffer() { return this->transfer_buffer_; }
78
+
79
+ protected:
80
+ friend class MixerSpeaker;
81
+ esp_err_t start_();
82
+ void stop_();
83
+
84
+ /// @brief Ducks audio samples by a specified amount. When changing the ducking amount, it can transition gradually
85
+ /// over a specified amount of samples.
86
+ /// @param input_buffer buffer with audio samples to be ducked in place
87
+ /// @param input_samples_to_duck number of samples to process in ``input_buffer``
88
+ /// @param current_ducking_db_reduction pointer to the current dB reduction
89
+ /// @param ducking_transition_samples_remaining pointer to the total number of samples left before the the
90
+ /// transition is finished
91
+ /// @param samples_per_ducking_step total number of samples per ducking step for the transition
92
+ /// @param db_change_per_ducking_step the change in dB reduction per step
93
+ static void duck_samples(int16_t *input_buffer, uint32_t input_samples_to_duck, int8_t *current_ducking_db_reduction,
94
+ uint32_t *ducking_transition_samples_remaining, uint32_t samples_per_ducking_step,
95
+ int8_t db_change_per_ducking_step);
96
+
97
+ MixerSpeaker *parent_;
98
+
99
+ std::shared_ptr<audio::AudioSourceTransferBuffer> transfer_buffer_;
100
+ std::weak_ptr<RingBuffer> ring_buffer_;
101
+
102
+ uint32_t buffer_duration_ms_;
103
+ uint32_t last_seen_data_ms_{0};
104
+ optional<uint32_t> timeout_ms_;
105
+ bool stop_gracefully_{false};
106
+
107
+ bool pause_state_{false};
108
+
109
+ int8_t target_ducking_db_reduction_{0};
110
+ int8_t current_ducking_db_reduction_{0};
111
+ int8_t db_change_per_ducking_step_{1};
112
+ uint32_t ducking_transition_samples_remaining_{0};
113
+ uint32_t samples_per_ducking_step_{0};
114
+
115
+ uint32_t accumulated_frames_read_{0};
116
+
117
+ uint32_t pending_playback_ms_{0};
118
+ };
119
+
120
+ class MixerSpeaker : public Component {
121
+ public:
122
+ void dump_config() override;
123
+ void setup() override;
124
+ void loop() override;
125
+
126
+ void add_source_speaker(SourceSpeaker *source_speaker) { this->source_speakers_.push_back(source_speaker); }
127
+
128
+ /// @brief Starts the mixer task. Called by a source speaker giving the current audio stream information
129
+ /// @param stream_info The calling source speakers audio stream information
130
+ /// @return ESP_ERR_NOT_SUPPORTED if the incoming stream is incompatible due to unsupported bits per sample
131
+ /// ESP_ERR_INVALID_ARG if the incoming stream is incompatible to be mixed with the other input audio stream
132
+ /// ESP_ERR_NO_MEM if there isn't enough memory for the task's stack
133
+ /// ESP_ERR_INVALID_STATE if the task fails to start
134
+ /// ESP_OK if the incoming stream is compatible and the mixer task starts
135
+ esp_err_t start(audio::AudioStreamInfo &stream_info);
136
+
137
+ void stop();
138
+
139
+ void set_output_channels(uint8_t output_channels) { this->output_channels_ = output_channels; }
140
+ void set_output_speaker(speaker::Speaker *speaker) { this->output_speaker_ = speaker; }
141
+ void set_queue_mode(bool queue_mode) { this->queue_mode_ = queue_mode; }
142
+ void set_task_stack_in_psram(bool task_stack_in_psram) { this->task_stack_in_psram_ = task_stack_in_psram; }
143
+
144
+ speaker::Speaker *get_output_speaker() const { return this->output_speaker_; }
145
+
146
+ protected:
147
+ /// @brief Copies audio frames from the input buffer to the output buffer taking into account the number of channels
148
+ /// in each stream. If the output stream has more channels, the input samples are duplicated. If the output stream has
149
+ /// less channels, the extra channel input samples are dropped.
150
+ /// @param input_buffer
151
+ /// @param input_stream_info
152
+ /// @param output_buffer
153
+ /// @param output_stream_info
154
+ /// @param frames_to_transfer number of frames (consisting of a sample for each channel) to copy from the input buffer
155
+ static void copy_frames(const int16_t *input_buffer, audio::AudioStreamInfo input_stream_info, int16_t *output_buffer,
156
+ audio::AudioStreamInfo output_stream_info, uint32_t frames_to_transfer);
157
+
158
+ /// @brief Mixes the primary and secondary streams taking into account the number of channels in each stream. Primary
159
+ /// and secondary samples are duplicated or dropped as necessary to ensure the output stream has the configured number
160
+ /// of channels. Output samples are clamped to the corresponding int16 min or max values if the mixed sample
161
+ /// overflows.
162
+ /// @param primary_buffer (int16_t *) samples buffer for the primary stream
163
+ /// @param primary_stream_info stream info for the primary stream
164
+ /// @param secondary_buffer (int16_t *) samples buffer for secondary stream
165
+ /// @param secondary_stream_info stream info for the secondary stream
166
+ /// @param output_buffer (int16_t *) buffer for the mixed samples
167
+ /// @param output_stream_info stream info for the output buffer
168
+ /// @param frames_to_mix number of frames in the primary and secondary buffers to mix together
169
+ static void mix_audio_samples(const int16_t *primary_buffer, audio::AudioStreamInfo primary_stream_info,
170
+ const int16_t *secondary_buffer, audio::AudioStreamInfo secondary_stream_info,
171
+ int16_t *output_buffer, audio::AudioStreamInfo output_stream_info,
172
+ uint32_t frames_to_mix);
173
+
174
+ static void audio_mixer_task(void *params);
175
+
176
+ /// @brief Starts the mixer task after allocating memory for the task stack.
177
+ /// @return ESP_ERR_NO_MEM if there isn't enough memory for the task's stack
178
+ /// ESP_ERR_INVALID_STATE if the task didn't start
179
+ /// ESP_OK if successful
180
+ esp_err_t start_task_();
181
+
182
+ /// @brief If the task is stopped, it sets the task handle to the nullptr and deallocates its stack
183
+ /// @return ESP_OK if the task was stopped, ESP_ERR_INVALID_STATE otherwise.
184
+ esp_err_t delete_task_();
185
+
186
+ EventGroupHandle_t event_group_{nullptr};
187
+
188
+ std::vector<SourceSpeaker *> source_speakers_;
189
+ speaker::Speaker *output_speaker_{nullptr};
190
+
191
+ uint8_t output_channels_;
192
+ bool queue_mode_;
193
+ bool task_stack_in_psram_{false};
194
+
195
+ bool task_created_{false};
196
+
197
+ TaskHandle_t task_handle_{nullptr};
198
+ StaticTask_t task_stack_;
199
+ StackType_t *task_stack_buffer_{nullptr};
200
+
201
+ optional<audio::AudioStreamInfo> audio_stream_info_;
202
+ };
203
+
204
+ } // namespace mixer_speaker
205
+ } // namespace esphome
206
+
207
+ #endif
@@ -1,8 +1,6 @@
1
1
 
2
2
  #include "modbus_textsensor.h"
3
3
  #include "esphome/core/log.h"
4
- #include <iomanip>
5
- #include <sstream>
6
4
 
7
5
  namespace esphome {
8
6
  namespace modbus_controller {
@@ -12,20 +10,17 @@ static const char *const TAG = "modbus_controller.text_sensor";
12
10
  void ModbusTextSensor::dump_config() { LOG_TEXT_SENSOR("", "Modbus Controller Text Sensor", this); }
13
11
 
14
12
  void ModbusTextSensor::parse_and_publish(const std::vector<uint8_t> &data) {
15
- std::ostringstream output;
13
+ std::string output_str{};
16
14
  uint8_t items_left = this->response_bytes;
17
15
  uint8_t index = this->offset;
18
- char buffer[5];
19
16
  while ((items_left > 0) && index < data.size()) {
20
17
  uint8_t b = data[index];
21
18
  switch (this->encode_) {
22
19
  case RawEncoding::HEXBYTES:
23
- sprintf(buffer, "%02x", b);
24
- output << buffer;
20
+ output_str += str_snprintf("%02x", 2, b);
25
21
  break;
26
22
  case RawEncoding::COMMA:
27
- sprintf(buffer, index != this->offset ? ",%d" : "%d", b);
28
- output << buffer;
23
+ output_str += str_sprintf(index != this->offset ? ",%d" : "%d", b);
29
24
  break;
30
25
  case RawEncoding::ANSI:
31
26
  if (b < 0x20)
@@ -33,25 +28,24 @@ void ModbusTextSensor::parse_and_publish(const std::vector<uint8_t> &data) {
33
28
  // FALLTHROUGH
34
29
  // Anything else no encoding
35
30
  default:
36
- output << (char) b;
31
+ output_str += (char) b;
37
32
  break;
38
33
  }
39
34
  items_left--;
40
35
  index++;
41
36
  }
42
37
 
43
- auto result = output.str();
44
38
  // Is there a lambda registered
45
39
  // call it with the pre converted value and the raw data array
46
40
  if (this->transform_func_.has_value()) {
47
41
  // the lambda can parse the response itself
48
- auto val = (*this->transform_func_)(this, result, data);
42
+ auto val = (*this->transform_func_)(this, output_str, data);
49
43
  if (val.has_value()) {
50
44
  ESP_LOGV(TAG, "Value overwritten by lambda");
51
- result = val.value();
45
+ output_str = val.value();
52
46
  }
53
47
  }
54
- this->publish_state(result);
48
+ this->publish_state(output_str);
55
49
  }
56
50
 
57
51
  } // namespace modbus_controller
@@ -117,6 +117,8 @@ class MPR121GPIOPin : public GPIOPin {
117
117
  void set_inverted(bool inverted) { this->inverted_ = inverted; }
118
118
  void set_flags(gpio::Flags flags) { this->flags_ = flags; }
119
119
 
120
+ gpio::Flags get_flags() const override { return this->flags_; }
121
+
120
122
  protected:
121
123
  MPR121Component *parent_;
122
124
  uint8_t pin_;
@@ -373,7 +373,7 @@ async def to_code(config):
373
373
  )
374
374
  )
375
375
 
376
- cg.add(var.set_topic_prefix(config[CONF_TOPIC_PREFIX]))
376
+ cg.add(var.set_topic_prefix(config[CONF_TOPIC_PREFIX], CORE.name))
377
377
 
378
378
  if config[CONF_USE_ABBREVIATIONS]:
379
379
  cg.add_define("USE_MQTT_ABBREVIATIONS")
@@ -606,7 +606,13 @@ void MQTTClientComponent::set_log_level(int level) { this->log_level_ = level; }
606
606
  void MQTTClientComponent::set_keep_alive(uint16_t keep_alive_s) { this->mqtt_backend_.set_keep_alive(keep_alive_s); }
607
607
  void MQTTClientComponent::set_log_message_template(MQTTMessage &&message) { this->log_message_ = std::move(message); }
608
608
  const MQTTDiscoveryInfo &MQTTClientComponent::get_discovery_info() const { return this->discovery_info_; }
609
- void MQTTClientComponent::set_topic_prefix(const std::string &topic_prefix) { this->topic_prefix_ = topic_prefix; }
609
+ void MQTTClientComponent::set_topic_prefix(const std::string &topic_prefix, const std::string &check_topic_prefix) {
610
+ if (App.is_name_add_mac_suffix_enabled() && (topic_prefix == check_topic_prefix)) {
611
+ this->topic_prefix_ = str_sanitize(App.get_name());
612
+ } else {
613
+ this->topic_prefix_ = topic_prefix;
614
+ }
615
+ }
610
616
  const std::string &MQTTClientComponent::get_topic_prefix() const { return this->topic_prefix_; }
611
617
  void MQTTClientComponent::set_publish_nan_as_none(bool publish_nan_as_none) {
612
618
  this->publish_nan_as_none_ = publish_nan_as_none;
@@ -165,7 +165,7 @@ class MQTTClientComponent : public Component {
165
165
  *
166
166
  * @param topic_prefix The topic prefix. The last "/" is appended automatically.
167
167
  */
168
- void set_topic_prefix(const std::string &topic_prefix);
168
+ void set_topic_prefix(const std::string &topic_prefix, const std::string &check_topic_prefix);
169
169
  /// Get the topic prefix of this device, using default if necessary
170
170
  const std::string &get_topic_prefix() const;
171
171
 
@@ -72,9 +72,9 @@ void MQTTClimateComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryCo
72
72
  // max_temp
73
73
  root[MQTT_MAX_TEMP] = traits.get_visual_max_temperature();
74
74
  // target_temp_step
75
- root[MQTT_TARGET_TEMPERATURE_STEP] = traits.get_visual_target_temperature_step();
75
+ root[MQTT_TARGET_TEMPERATURE_STEP] = roundf(traits.get_visual_target_temperature_step() * 10) * 0.1;
76
76
  // current_temp_step
77
- root[MQTT_CURRENT_TEMPERATURE_STEP] = traits.get_visual_current_temperature_step();
77
+ root[MQTT_CURRENT_TEMPERATURE_STEP] = roundf(traits.get_visual_current_temperature_step() * 10) * 0.1;
78
78
  // temperature units are always coerced to Celsius internally
79
79
  root[MQTT_TEMPERATURE_UNIT] = "C";
80
80
 
@@ -49,6 +49,7 @@ struct IPAddress {
49
49
  }
50
50
  IPAddress(const std::string &in_address) { inet_aton(in_address.c_str(), &ip_addr_); }
51
51
  IPAddress(const ip_addr_t *other_ip) { ip_addr_ = *other_ip; }
52
+ std::string str() const { return str_lower_case(inet_ntoa(ip_addr_)); }
52
53
  #else
53
54
  IPAddress() { ip_addr_set_zero(&ip_addr_); }
54
55
  IPAddress(uint8_t first, uint8_t second, uint8_t third, uint8_t fourth) {
@@ -119,6 +120,7 @@ struct IPAddress {
119
120
  bool is_set() { return !ip_addr_isany(&ip_addr_); } // NOLINT(readability-simplify-boolean-expr)
120
121
  bool is_ip4() { return IP_IS_V4(&ip_addr_); }
121
122
  bool is_ip6() { return IP_IS_V6(&ip_addr_); }
123
+ bool is_multicast() { return ip_addr_ismulticast(&ip_addr_); }
122
124
  std::string str() const { return str_lower_case(ipaddr_ntoa(&ip_addr_)); }
123
125
  bool operator==(const IPAddress &other) const { return ip_addr_cmp(&ip_addr_, &other.ip_addr_); }
124
126
  bool operator!=(const IPAddress &other) const { return !ip_addr_cmp(&ip_addr_, &other.ip_addr_); }
@@ -49,6 +49,23 @@ class TouchTrigger : public Trigger<uint8_t, uint8_t, bool> {
49
49
  }
50
50
  };
51
51
 
52
+ template<typename... Ts> class NextionSetBrightnessAction : public Action<Ts...> {
53
+ public:
54
+ explicit NextionSetBrightnessAction(Nextion *component) : component_(component) {}
55
+
56
+ TEMPLATABLE_VALUE(float, brightness)
57
+
58
+ void play(Ts... x) override {
59
+ this->component_->set_brightness(this->brightness_.value(x...));
60
+ this->component_->set_backlight_brightness(this->brightness_.value(x...));
61
+ }
62
+
63
+ void set_brightness(std::function<void(Ts..., float)> brightness) { this->brightness_ = brightness; }
64
+
65
+ protected:
66
+ Nextion *component_;
67
+ };
68
+
52
69
  template<typename... Ts> class NextionPublishFloatAction : public Action<Ts...> {
53
70
  public:
54
71
  explicit NextionPublishFloatAction(NextionComponent *component) : component_(component) {}
@@ -1,30 +1,30 @@
1
+ from esphome import automation
1
2
  import esphome.codegen as cg
3
+ from esphome.components import display, esp32, uart
2
4
  import esphome.config_validation as cv
3
- from esphome import automation
4
- from esphome.components import display, uart
5
- from esphome.components import esp32
6
5
  from esphome.const import (
6
+ CONF_BRIGHTNESS,
7
7
  CONF_ID,
8
8
  CONF_LAMBDA,
9
- CONF_BRIGHTNESS,
10
- CONF_TRIGGER_ID,
11
9
  CONF_ON_TOUCH,
10
+ CONF_TRIGGER_ID,
12
11
  )
13
12
  from esphome.core import CORE
13
+
14
14
  from . import Nextion, nextion_ns, nextion_ref
15
15
  from .base_component import (
16
+ CONF_AUTO_WAKE_ON_TOUCH,
17
+ CONF_EXIT_REPARSE_ON_START,
16
18
  CONF_ON_BUFFER_OVERFLOW,
19
+ CONF_ON_PAGE,
20
+ CONF_ON_SETUP,
17
21
  CONF_ON_SLEEP,
18
22
  CONF_ON_WAKE,
19
- CONF_ON_SETUP,
20
- CONF_ON_PAGE,
23
+ CONF_SKIP_CONNECTION_HANDSHAKE,
24
+ CONF_START_UP_PAGE,
21
25
  CONF_TFT_URL,
22
26
  CONF_TOUCH_SLEEP_TIMEOUT,
23
27
  CONF_WAKE_UP_PAGE,
24
- CONF_START_UP_PAGE,
25
- CONF_AUTO_WAKE_ON_TOUCH,
26
- CONF_EXIT_REPARSE_ON_START,
27
- CONF_SKIP_CONNECTION_HANDSHAKE,
28
28
  )
29
29
 
30
30
  CODEOWNERS = ["@senexcrenshaw", "@edwardtfn"]
@@ -32,6 +32,9 @@ CODEOWNERS = ["@senexcrenshaw", "@edwardtfn"]
32
32
  DEPENDENCIES = ["uart"]
33
33
  AUTO_LOAD = ["binary_sensor", "switch", "sensor", "text_sensor"]
34
34
 
35
+ NextionSetBrightnessAction = nextion_ns.class_(
36
+ "NextionSetBrightnessAction", automation.Action
37
+ )
35
38
  SetupTrigger = nextion_ns.class_("SetupTrigger", automation.Trigger.template())
36
39
  SleepTrigger = nextion_ns.class_("SleepTrigger", automation.Trigger.template())
37
40
  WakeTrigger = nextion_ns.class_("WakeTrigger", automation.Trigger.template())
@@ -46,7 +49,7 @@ CONFIG_SCHEMA = (
46
49
  {
47
50
  cv.GenerateID(): cv.declare_id(Nextion),
48
51
  cv.Optional(CONF_TFT_URL): cv.url,
49
- cv.Optional(CONF_BRIGHTNESS, default=1.0): cv.percentage,
52
+ cv.Optional(CONF_BRIGHTNESS): cv.percentage,
50
53
  cv.Optional(CONF_ON_SETUP): automation.validate_automation(
51
54
  {
52
55
  cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(SetupTrigger),
@@ -92,12 +95,34 @@ CONFIG_SCHEMA = (
92
95
  )
93
96
 
94
97
 
98
+ @automation.register_action(
99
+ "display.nextion.set_brightness",
100
+ NextionSetBrightnessAction,
101
+ cv.maybe_simple_value(
102
+ {
103
+ cv.GenerateID(): cv.use_id(Nextion),
104
+ cv.Required(CONF_BRIGHTNESS): cv.templatable(cv.percentage),
105
+ },
106
+ key=CONF_BRIGHTNESS,
107
+ ),
108
+ )
109
+ async def nextion_set_brightness_to_code(config, action_id, template_arg, args):
110
+ paren = await cg.get_variable(config[CONF_ID])
111
+ var = cg.new_Pvariable(action_id, template_arg, paren)
112
+
113
+ template_ = await cg.templatable(config[CONF_BRIGHTNESS], args, float)
114
+ cg.add(var.set_brightness(template_))
115
+
116
+ return var
117
+
118
+
95
119
  async def to_code(config):
96
120
  var = cg.new_Pvariable(config[CONF_ID])
97
121
  await uart.register_uart_device(var, config)
98
122
 
99
123
  if CONF_BRIGHTNESS in config:
100
124
  cg.add(var.set_brightness(config[CONF_BRIGHTNESS]))
125
+
101
126
  if CONF_LAMBDA in config:
102
127
  lambda_ = await cg.process_lambda(
103
128
  config[CONF_LAMBDA], [(nextion_ref, "it")], return_type=cg.void
@@ -119,17 +144,17 @@ async def to_code(config):
119
144
  cg.add_library("ESP8266HTTPClient", None)
120
145
 
121
146
  if CONF_TOUCH_SLEEP_TIMEOUT in config:
122
- cg.add(var.set_touch_sleep_timeout_internal(config[CONF_TOUCH_SLEEP_TIMEOUT]))
147
+ cg.add(var.set_touch_sleep_timeout(config[CONF_TOUCH_SLEEP_TIMEOUT]))
123
148
 
124
149
  if CONF_WAKE_UP_PAGE in config:
125
- cg.add(var.set_wake_up_page_internal(config[CONF_WAKE_UP_PAGE]))
150
+ cg.add(var.set_wake_up_page(config[CONF_WAKE_UP_PAGE]))
126
151
 
127
152
  if CONF_START_UP_PAGE in config:
128
- cg.add(var.set_start_up_page_internal(config[CONF_START_UP_PAGE]))
153
+ cg.add(var.set_start_up_page(config[CONF_START_UP_PAGE]))
129
154
 
130
- cg.add(var.set_auto_wake_on_touch_internal(config[CONF_AUTO_WAKE_ON_TOUCH]))
155
+ cg.add(var.set_auto_wake_on_touch(config[CONF_AUTO_WAKE_ON_TOUCH]))
131
156
 
132
- cg.add(var.set_exit_reparse_on_start_internal(config[CONF_EXIT_REPARSE_ON_START]))
157
+ cg.add(var.set_exit_reparse_on_start(config[CONF_EXIT_REPARSE_ON_START]))
133
158
 
134
159
  cg.add(var.set_skip_connection_handshake(config[CONF_SKIP_CONNECTION_HANDSHAKE]))
135
160
 
@@ -40,7 +40,7 @@ bool Nextion::send_command_(const std::string &command) {
40
40
  }
41
41
 
42
42
  bool Nextion::check_connect_() {
43
- if (this->get_is_connected_())
43
+ if (this->is_connected_)
44
44
  return true;
45
45
 
46
46
  // Check if the handshake should be skipped for the Nextion connection
@@ -273,21 +273,15 @@ void Nextion::loop() {
273
273
  this->sent_setup_commands_ = true;
274
274
  this->send_command_("bkcmd=3"); // Always, returns 0x00 to 0x23 result of serial command.
275
275
 
276
- this->set_backlight_brightness(this->brightness_);
276
+ if (this->brightness_.has_value()) {
277
+ this->set_backlight_brightness(this->brightness_.value());
278
+ }
277
279
 
278
280
  // Check if a startup page has been set and send the command
279
281
  if (this->start_up_page_ != -1) {
280
282
  this->goto_page(this->start_up_page_);
281
283
  }
282
284
 
283
- // This could probably be removed from the loop area, as those are redundant.
284
- this->set_auto_wake_on_touch(this->auto_wake_on_touch_);
285
- this->set_exit_reparse_on_start(this->exit_reparse_on_start_);
286
-
287
- if (this->touch_sleep_timeout_ != 0) {
288
- this->set_touch_sleep_timeout(this->touch_sleep_timeout_);
289
- }
290
-
291
285
  if (this->wake_up_page_ != -1) {
292
286
  this->set_wake_up_page(this->wake_up_page_);
293
287
  }