esphome 2024.7.3__py3-none-any.whl → 2024.8.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 (350) hide show
  1. esphome/__main__.py +15 -81
  2. esphome/automation.py +1 -1
  3. esphome/codegen.py +53 -53
  4. esphome/components/ade7953/sensor.py +1 -1
  5. esphome/components/ade7953_spi/ade7953_spi.cpp +1 -1
  6. esphome/components/airthings_wave_plus/airthings_wave_plus.cpp +5 -2
  7. esphome/components/airthings_wave_plus/airthings_wave_plus.h +2 -0
  8. esphome/components/airthings_wave_plus/sensor.py +12 -0
  9. esphome/components/alarm_control_panel/__init__.py +75 -66
  10. esphome/components/apds9306/__init__.py +4 -0
  11. esphome/components/apds9306/apds9306.cpp +151 -0
  12. esphome/components/apds9306/apds9306.h +66 -0
  13. esphome/components/apds9306/sensor.py +95 -0
  14. esphome/components/api/__init__.py +80 -52
  15. esphome/components/api/api_connection.cpp +14 -1
  16. esphome/components/api/api_pb2.cpp +33 -4
  17. esphome/components/api/api_pb2.h +8 -1
  18. esphome/components/api/api_server.cpp +10 -0
  19. esphome/components/api/api_server.h +3 -0
  20. esphome/components/atm90e32/__init__.py +7 -0
  21. esphome/components/atm90e32/atm90e32.cpp +68 -16
  22. esphome/components/atm90e32/atm90e32.h +20 -7
  23. esphome/components/atm90e32/atm90e32_reg.h +2 -0
  24. esphome/components/atm90e32/button/__init__.py +43 -0
  25. esphome/components/atm90e32/button/atm90e32_button.cpp +20 -0
  26. esphome/components/atm90e32/button/atm90e32_button.h +27 -0
  27. esphome/components/atm90e32/sensor.py +15 -11
  28. esphome/components/bedjet/bedjet_codec.h +1 -1
  29. esphome/components/binary/light/binary_light_output.h +3 -2
  30. esphome/components/binary_sensor/__init__.py +5 -5
  31. esphome/components/ble_client/__init__.py +3 -3
  32. esphome/components/ble_client/output/__init__.py +1 -1
  33. esphome/components/ble_client/sensor/__init__.py +4 -3
  34. esphome/components/ble_client/switch/__init__.py +2 -1
  35. esphome/components/ble_client/text_sensor/__init__.py +4 -3
  36. esphome/components/ble_presence/binary_sensor.py +3 -3
  37. esphome/components/ble_rssi/sensor.py +2 -2
  38. esphome/components/ble_scanner/text_sensor.py +1 -1
  39. esphome/components/bluetooth_proxy/__init__.py +3 -3
  40. esphome/components/bme68x_bsec2/__init__.py +196 -0
  41. esphome/components/bme68x_bsec2/bme68x_bsec2.cpp +523 -0
  42. esphome/components/bme68x_bsec2/bme68x_bsec2.h +163 -0
  43. esphome/components/bme68x_bsec2/sensor.py +130 -0
  44. esphome/components/bme68x_bsec2/text_sensor.py +33 -0
  45. esphome/components/bme68x_bsec2_i2c/__init__.py +28 -0
  46. esphome/components/bme68x_bsec2_i2c/bme68x_bsec2_i2c.cpp +53 -0
  47. esphome/components/bme68x_bsec2_i2c/bme68x_bsec2_i2c.h +28 -0
  48. esphome/components/bmp3xx/sensor.py +1 -1
  49. esphome/components/button/__init__.py +4 -4
  50. esphome/components/climate/__init__.py +5 -5
  51. esphome/components/climate/climate.h +1 -1
  52. esphome/components/cover/__init__.py +8 -8
  53. esphome/components/cst226/touchscreen/cst226_touchscreen.cpp +11 -7
  54. esphome/components/cst226/touchscreen/cst226_touchscreen.h +1 -1
  55. esphome/components/datetime/__init__.py +11 -13
  56. esphome/components/demo/demo_sensor.h +3 -2
  57. esphome/components/display/display.cpp +31 -0
  58. esphome/components/display/display.h +3 -0
  59. esphome/components/display_menu_base/__init__.py +14 -13
  60. esphome/components/ens160/sensor.py +1 -1
  61. esphome/components/esp32/__init__.py +22 -10
  62. esphome/components/esp32/boards.py +1 -1
  63. esphome/components/esp32/gpio.py +12 -13
  64. esphome/components/esp32/gpio_esp32.py +1 -2
  65. esphome/components/esp32/gpio_esp32_c2.py +1 -2
  66. esphome/components/esp32/gpio_esp32_c3.py +1 -5
  67. esphome/components/esp32/gpio_esp32_c6.py +1 -2
  68. esphome/components/esp32/gpio_esp32_h2.py +1 -2
  69. esphome/components/esp32/gpio_esp32_s2.py +1 -2
  70. esphome/components/esp32/gpio_esp32_s3.py +1 -6
  71. esphome/components/esp32_ble/__init__.py +20 -3
  72. esphome/components/esp32_ble/ble.cpp +9 -1
  73. esphome/components/esp32_ble/ble.h +9 -0
  74. esphome/components/esp32_ble/ble_advertising.cpp +42 -9
  75. esphome/components/esp32_ble/ble_advertising.h +21 -1
  76. esphome/components/esp32_ble_beacon/__init__.py +17 -7
  77. esphome/components/esp32_ble_beacon/esp32_ble_beacon.cpp +45 -113
  78. esphome/components/esp32_ble_beacon/esp32_ble_beacon.h +17 -19
  79. esphome/components/esp32_ble_client/__init__.py +0 -1
  80. esphome/components/esp32_ble_server/__init__.py +2 -3
  81. esphome/components/esp32_ble_tracker/__init__.py +2 -2
  82. esphome/components/esp32_improv/__init__.py +2 -4
  83. esphome/components/ethernet/__init__.py +17 -17
  84. esphome/components/ethernet_info/text_sensor.py +2 -2
  85. esphome/components/event/__init__.py +5 -5
  86. esphome/components/fan/__init__.py +14 -14
  87. esphome/components/fan/fan.cpp +2 -2
  88. esphome/components/fingerprint_grow/fingerprint_grow.cpp +1 -1
  89. esphome/components/fingerprint_grow/fingerprint_grow.h +1 -1
  90. esphome/components/graphical_display_menu/__init__.py +11 -8
  91. esphome/components/haier/haier_base.h +2 -2
  92. esphome/components/homeassistant/__init__.py +8 -1
  93. esphome/components/homeassistant/number/__init__.py +33 -0
  94. esphome/components/homeassistant/number/homeassistant_number.cpp +100 -0
  95. esphome/components/homeassistant/number/homeassistant_number.h +31 -0
  96. esphome/components/homeassistant/switch/__init__.py +30 -0
  97. esphome/components/homeassistant/switch/homeassistant_switch.cpp +59 -0
  98. esphome/components/homeassistant/switch/homeassistant_switch.h +22 -0
  99. esphome/components/host/__init__.py +3 -7
  100. esphome/components/http_request/__init__.py +12 -1
  101. esphome/components/http_request/http_request_arduino.cpp +2 -2
  102. esphome/components/http_request/http_request_idf.cpp +11 -2
  103. esphome/components/http_request/http_request_idf.h +10 -0
  104. esphome/components/http_request/ota/ota_http_request.cpp +1 -1
  105. esphome/components/http_request/update/http_request_update.cpp +2 -2
  106. esphome/components/http_request/update/http_request_update.h +2 -1
  107. esphome/components/hx711/hx711.cpp +10 -1
  108. esphome/components/hydreon_rgxx/hydreon_rgxx.cpp +1 -1
  109. esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +11 -2
  110. esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +2 -0
  111. esphome/components/ili9xxx/ili9xxx_defines.h +3 -1
  112. esphome/components/ili9xxx/ili9xxx_display.cpp +9 -22
  113. esphome/components/ili9xxx/ili9xxx_display.h +5 -7
  114. esphome/components/ili9xxx/ili9xxx_init.h +4 -4
  115. esphome/components/improv_base/__init__.py +2 -3
  116. esphome/components/improv_serial/__init__.py +4 -10
  117. esphome/components/improv_serial/improv_serial_component.cpp +4 -0
  118. esphome/components/jsn_sr04t/jsn_sr04t.cpp +18 -1
  119. esphome/components/jsn_sr04t/jsn_sr04t.h +7 -1
  120. esphome/components/jsn_sr04t/sensor.py +13 -0
  121. esphome/components/kalman_combinator/sensor.py +1 -1
  122. esphome/components/light/__init__.py +16 -15
  123. esphome/components/light/addressable_light_effect.h +12 -8
  124. esphome/components/light/automation.h +16 -1
  125. esphome/components/light/automation.py +21 -0
  126. esphome/components/light/base_light_effects.h +5 -5
  127. esphome/components/light/esp_color_correction.h +8 -8
  128. esphome/components/light/types.py +7 -0
  129. esphome/components/lock/__init__.py +3 -3
  130. esphome/components/logger/__init__.py +15 -18
  131. esphome/components/lvgl/__init__.py +346 -0
  132. esphome/components/lvgl/automation.py +226 -0
  133. esphome/components/lvgl/binary_sensor/__init__.py +43 -0
  134. esphome/components/lvgl/defines.py +508 -0
  135. esphome/components/lvgl/encoders.py +77 -0
  136. esphome/components/lvgl/font.cpp +76 -0
  137. esphome/components/lvgl/helpers.py +49 -0
  138. esphome/components/lvgl/light/__init__.py +32 -0
  139. esphome/components/lvgl/light/lvgl_light.h +48 -0
  140. esphome/components/lvgl/lv_validation.py +303 -0
  141. esphome/components/lvgl/lvcode.py +349 -0
  142. esphome/components/lvgl/lvgl_esphome.cpp +407 -0
  143. esphome/components/lvgl/lvgl_esphome.h +274 -0
  144. esphome/components/lvgl/lvgl_hal.h +21 -0
  145. esphome/components/lvgl/number/__init__.py +66 -0
  146. esphome/components/lvgl/number/lvgl_number.h +34 -0
  147. esphome/components/lvgl/schemas.py +436 -0
  148. esphome/components/lvgl/select/__init__.py +55 -0
  149. esphome/components/lvgl/select/lvgl_select.h +62 -0
  150. esphome/components/lvgl/sensor/__init__.py +47 -0
  151. esphome/components/lvgl/styles.py +58 -0
  152. esphome/components/lvgl/switch/__init__.py +56 -0
  153. esphome/components/lvgl/switch/lvgl_switch.h +34 -0
  154. esphome/components/lvgl/text/__init__.py +50 -0
  155. esphome/components/lvgl/text/lvgl_text.h +34 -0
  156. esphome/components/lvgl/text_sensor/__init__.py +42 -0
  157. esphome/components/lvgl/touchscreens.py +45 -0
  158. esphome/components/lvgl/trigger.py +74 -0
  159. esphome/components/lvgl/types.py +191 -0
  160. esphome/components/lvgl/widgets/__init__.py +419 -0
  161. esphome/components/lvgl/widgets/animimg.py +117 -0
  162. esphome/components/lvgl/widgets/arc.py +78 -0
  163. esphome/components/lvgl/widgets/button.py +20 -0
  164. esphome/components/lvgl/widgets/buttonmatrix.py +275 -0
  165. esphome/components/lvgl/widgets/checkbox.py +27 -0
  166. esphome/components/lvgl/widgets/dropdown.py +76 -0
  167. esphome/components/lvgl/widgets/img.py +85 -0
  168. esphome/components/lvgl/widgets/keyboard.py +49 -0
  169. esphome/components/lvgl/widgets/label.py +42 -0
  170. esphome/components/lvgl/widgets/led.py +29 -0
  171. esphome/components/lvgl/widgets/line.py +50 -0
  172. esphome/components/lvgl/widgets/lv_bar.py +55 -0
  173. esphome/components/lvgl/widgets/meter.py +302 -0
  174. esphome/components/lvgl/widgets/msgbox.py +134 -0
  175. esphome/components/lvgl/widgets/obj.py +28 -0
  176. esphome/components/lvgl/widgets/page.py +113 -0
  177. esphome/components/lvgl/widgets/roller.py +77 -0
  178. esphome/components/lvgl/widgets/slider.py +63 -0
  179. esphome/components/lvgl/widgets/spinbox.py +178 -0
  180. esphome/components/lvgl/widgets/spinner.py +43 -0
  181. esphome/components/lvgl/widgets/switch.py +20 -0
  182. esphome/components/lvgl/widgets/tabview.py +114 -0
  183. esphome/components/lvgl/widgets/textarea.py +66 -0
  184. esphome/components/lvgl/widgets/tileview.py +128 -0
  185. esphome/components/m5stack_8angle/__init__.py +33 -0
  186. esphome/components/m5stack_8angle/binary_sensor/__init__.py +30 -0
  187. esphome/components/m5stack_8angle/binary_sensor/m5stack_8angle_binary_sensor.cpp +17 -0
  188. esphome/components/m5stack_8angle/binary_sensor/m5stack_8angle_binary_sensor.h +19 -0
  189. esphome/components/m5stack_8angle/light/__init__.py +31 -0
  190. esphome/components/m5stack_8angle/light/m5stack_8angle_light.cpp +45 -0
  191. esphome/components/m5stack_8angle/light/m5stack_8angle_light.h +37 -0
  192. esphome/components/m5stack_8angle/m5stack_8angle.cpp +74 -0
  193. esphome/components/m5stack_8angle/m5stack_8angle.h +34 -0
  194. esphome/components/m5stack_8angle/sensor/__init__.py +66 -0
  195. esphome/components/m5stack_8angle/sensor/m5stack_8angle_sensor.cpp +24 -0
  196. esphome/components/m5stack_8angle/sensor/m5stack_8angle_sensor.h +27 -0
  197. esphome/components/matrix_keypad/matrix_keypad.cpp +2 -0
  198. esphome/components/max31856/sensor.py +5 -5
  199. esphome/components/media_player/__init__.py +3 -5
  200. esphome/components/media_player/automation.h +31 -27
  201. esphome/components/micro_wake_word/__init__.py +20 -25
  202. esphome/components/microphone/microphone.h +4 -1
  203. esphome/components/modbus_controller/__init__.py +26 -2
  204. esphome/components/modbus_controller/automation.h +19 -0
  205. esphome/components/modbus_controller/const.py +1 -0
  206. esphome/components/modbus_controller/modbus_controller.cpp +8 -0
  207. esphome/components/modbus_controller/modbus_controller.h +3 -0
  208. esphome/components/mqtt/__init__.py +20 -9
  209. esphome/components/mqtt/mqtt_alarm_control_panel.cpp +128 -0
  210. esphome/components/mqtt/mqtt_alarm_control_panel.h +39 -0
  211. esphome/components/mqtt/mqtt_backend.h +3 -1
  212. esphome/components/mqtt/mqtt_backend_esp32.cpp +4 -1
  213. esphome/components/mqtt/mqtt_backend_esp32.h +3 -1
  214. esphome/components/mqtt/mqtt_backend_esp8266.h +3 -1
  215. esphome/components/mqtt/mqtt_backend_libretiny.h +3 -1
  216. esphome/components/mqtt/mqtt_client.cpp +16 -3
  217. esphome/components/mqtt/mqtt_client.h +5 -1
  218. esphome/components/mqtt/mqtt_component.cpp +32 -4
  219. esphome/components/mqtt/mqtt_const.h +2 -0
  220. esphome/components/network/__init__.py +15 -12
  221. esphome/components/network/ip_address.h +3 -0
  222. esphome/components/network/util.cpp +2 -1
  223. esphome/components/network/util.h +3 -1
  224. esphome/components/nextion/base_component.py +5 -8
  225. esphome/components/number/__init__.py +7 -8
  226. esphome/components/online_image/__init__.py +167 -0
  227. esphome/components/online_image/image_decoder.cpp +44 -0
  228. esphome/components/online_image/image_decoder.h +112 -0
  229. esphome/components/online_image/online_image.cpp +283 -0
  230. esphome/components/online_image/online_image.h +195 -0
  231. esphome/components/online_image/png_image.cpp +68 -0
  232. esphome/components/online_image/png_image.h +33 -0
  233. esphome/components/ota/__init__.py +8 -4
  234. esphome/components/pid/pid_climate.h +2 -0
  235. esphome/components/remote_base/pronto_protocol.cpp +0 -3
  236. esphome/components/remote_transmitter/remote_transmitter.h +1 -1
  237. esphome/components/rgbct/rgbct_light_output.h +3 -2
  238. esphome/components/rgbw/rgbw_light_output.h +3 -2
  239. esphome/components/rgbww/rgbww_light_output.h +3 -2
  240. esphome/components/rp2040_pio_led_strip/led_strip.cpp +31 -5
  241. esphome/components/rp2040_pio_led_strip/led_strip.h +5 -0
  242. esphome/components/rtttl/rtttl.cpp +108 -21
  243. esphome/components/rtttl/rtttl.h +15 -6
  244. esphome/components/select/__init__.py +7 -7
  245. esphome/components/sensor/__init__.py +29 -10
  246. esphome/components/sensor/filter.cpp +8 -0
  247. esphome/components/sensor/filter.h +9 -0
  248. esphome/components/sml/sml_parser.cpp +48 -22
  249. esphome/components/socket/socket.cpp +11 -14
  250. esphome/components/speaker/__init__.py +14 -5
  251. esphome/components/speaker/automation.h +10 -0
  252. esphome/components/speaker/speaker.h +9 -0
  253. esphome/components/spi/spi.cpp +0 -6
  254. esphome/components/spi/spi.h +2 -19
  255. esphome/components/spi_led_strip/spi_led_strip.h +5 -4
  256. esphome/components/sprinkler/sprinkler.cpp +2 -2
  257. esphome/components/sprinkler/sprinkler.h +1 -1
  258. esphome/components/switch/__init__.py +3 -3
  259. esphome/components/text/__init__.py +5 -5
  260. esphome/components/text_sensor/__init__.py +7 -7
  261. esphome/components/time/__init__.py +8 -8
  262. esphome/components/touchscreen/binary_sensor/__init__.py +24 -10
  263. esphome/components/touchscreen/binary_sensor/touchscreen_binary_sensor.cpp +3 -2
  264. esphome/components/touchscreen/binary_sensor/touchscreen_binary_sensor.h +4 -2
  265. esphome/components/uart/uart_component_host.cpp +6 -2
  266. esphome/components/update/__init__.py +33 -15
  267. esphome/components/update/automation.h +23 -0
  268. esphome/components/update/update_entity.h +3 -1
  269. esphome/components/valve/__init__.py +3 -3
  270. esphome/components/voice_assistant/__init__.py +7 -8
  271. esphome/components/wake_on_lan/wake_on_lan.cpp +2 -0
  272. esphome/components/wake_on_lan/wake_on_lan.h +3 -1
  273. esphome/components/watchdog/__init__.py +1 -0
  274. esphome/components/{http_request → watchdog}/watchdog.cpp +0 -2
  275. esphome/components/{http_request → watchdog}/watchdog.h +0 -2
  276. esphome/components/waveshare_epaper/waveshare_epaper.cpp +5 -5
  277. esphome/components/web_server/server_index_v3.h +3615 -3603
  278. esphome/components/web_server/web_server.cpp +0 -209
  279. esphome/components/web_server/web_server.h +1 -1
  280. esphome/components/web_server/web_server_v1.cpp +217 -0
  281. esphome/components/web_server_base/web_server_base.h +1 -0
  282. esphome/components/wifi/__init__.py +15 -14
  283. esphome/components/wifi/wifi_component.cpp +2 -0
  284. esphome/components/wifi/wifi_component.h +7 -1
  285. esphome/components/wifi/wifi_component_esp32_arduino.cpp +5 -2
  286. esphome/components/wifi/wifi_component_esp8266.cpp +2 -0
  287. esphome/components/wifi/wifi_component_esp_idf.cpp +43 -7
  288. esphome/components/wifi/wifi_component_libretiny.cpp +2 -0
  289. esphome/components/wifi/wifi_component_pico_w.cpp +2 -0
  290. esphome/components/wifi/wpa2_eap.py +6 -7
  291. esphome/components/wifi_info/text_sensor.py +3 -3
  292. esphome/components/wifi_info/wifi_info_text_sensor.cpp +2 -0
  293. esphome/components/wifi_info/wifi_info_text_sensor.h +2 -0
  294. esphome/components/wifi_signal/sensor.py +1 -1
  295. esphome/components/wifi_signal/wifi_signal_sensor.cpp +2 -0
  296. esphome/components/wifi_signal/wifi_signal_sensor.h +2 -1
  297. esphome/components/xiaomi_ble/xiaomi_ble.cpp +20 -3
  298. esphome/components/xiaomi_ble/xiaomi_ble.h +1 -0
  299. esphome/components/xiaomi_lywsd02mmc/__init__.py +0 -0
  300. esphome/components/xiaomi_lywsd02mmc/sensor.py +77 -0
  301. esphome/components/xiaomi_lywsd02mmc/xiaomi_lywsd02mmc.cpp +73 -0
  302. esphome/components/xiaomi_lywsd02mmc/xiaomi_lywsd02mmc.h +37 -0
  303. esphome/config.py +17 -19
  304. esphome/config_validation.py +55 -23
  305. esphome/const.py +25 -9
  306. esphome/core/__init__.py +17 -14
  307. esphome/core/application.h +42 -21
  308. esphome/core/automation.h +5 -3
  309. esphome/core/base_automation.h +3 -2
  310. esphome/core/bytebuffer.cpp +134 -0
  311. esphome/core/bytebuffer.h +96 -0
  312. esphome/core/color.h +24 -16
  313. esphome/core/config.py +3 -3
  314. esphome/core/defines.h +14 -1
  315. esphome/core/entity_base.h +2 -2
  316. esphome/core/entity_helpers.py +1 -2
  317. esphome/core/gpio.h +0 -18
  318. esphome/core/helpers.h +1 -1
  319. esphome/core/optional.h +15 -16
  320. esphome/coroutine.py +1 -1
  321. esphome/cpp_generator.py +1 -1
  322. esphome/cpp_helpers.py +3 -5
  323. esphome/dashboard/core.py +3 -3
  324. esphome/dashboard/dashboard.py +3 -3
  325. esphome/dashboard/entries.py +1 -1
  326. esphome/dashboard/util/file.py +1 -1
  327. esphome/dashboard/web_server.py +3 -3
  328. esphome/external_files.py +5 -3
  329. esphome/final_validate.py +2 -2
  330. esphome/git.py +4 -4
  331. esphome/helpers.py +5 -5
  332. esphome/loader.py +15 -10
  333. esphome/mqtt.py +4 -8
  334. esphome/pins.py +6 -6
  335. esphome/platformio_api.py +5 -5
  336. esphome/storage_json.py +2 -1
  337. esphome/types.py +1 -1
  338. esphome/util.py +2 -3
  339. esphome/voluptuous_schema.py +1 -0
  340. esphome/vscode.py +5 -4
  341. esphome/wizard.py +1 -1
  342. esphome/writer.py +7 -7
  343. esphome/yaml_util.py +3 -3
  344. esphome/zeroconf.py +1 -1
  345. {esphome-2024.7.3.dist-info → esphome-2024.8.0.dist-info}/METADATA +3 -3
  346. {esphome-2024.7.3.dist-info → esphome-2024.8.0.dist-info}/RECORD +350 -244
  347. {esphome-2024.7.3.dist-info → esphome-2024.8.0.dist-info}/LICENSE +0 -0
  348. {esphome-2024.7.3.dist-info → esphome-2024.8.0.dist-info}/WHEEL +0 -0
  349. {esphome-2024.7.3.dist-info → esphome-2024.8.0.dist-info}/entry_points.txt +0 -0
  350. {esphome-2024.7.3.dist-info → esphome-2024.8.0.dist-info}/top_level.txt +0 -0
@@ -1,12 +1,10 @@
1
+ import esphome.codegen as cg
1
2
  from esphome.components import improv_base
2
3
  from esphome.components.esp32 import get_esp32_variant
3
- from esphome.components.esp32.const import (
4
- VARIANT_ESP32S3,
5
- )
4
+ from esphome.components.esp32.const import VARIANT_ESP32S3
6
5
  from esphome.components.logger import USB_CDC
7
- from esphome.const import CONF_BAUD_RATE, CONF_HARDWARE_UART, CONF_ID, CONF_LOGGER
8
- import esphome.codegen as cg
9
6
  import esphome.config_validation as cv
7
+ from esphome.const import CONF_BAUD_RATE, CONF_HARDWARE_UART, CONF_ID, CONF_LOGGER
10
8
  from esphome.core import CORE
11
9
  import esphome.final_validate as fv
12
10
 
@@ -19,11 +17,7 @@ improv_serial_ns = cg.esphome_ns.namespace("improv_serial")
19
17
  ImprovSerialComponent = improv_serial_ns.class_("ImprovSerialComponent", cg.Component)
20
18
 
21
19
  CONFIG_SCHEMA = (
22
- cv.Schema(
23
- {
24
- cv.GenerateID(): cv.declare_id(ImprovSerialComponent),
25
- }
26
- )
20
+ cv.Schema({cv.GenerateID(): cv.declare_id(ImprovSerialComponent)})
27
21
  .extend(improv_base.IMPROV_SCHEMA)
28
22
  .extend(cv.COMPONENT_SCHEMA)
29
23
  )
@@ -170,7 +170,11 @@ std::vector<uint8_t> ImprovSerialComponent::build_rpc_settings_response_(improv:
170
170
  }
171
171
 
172
172
  std::vector<uint8_t> ImprovSerialComponent::build_version_info_() {
173
+ #ifdef ESPHOME_PROJECT_NAME
174
+ std::vector<std::string> infos = {ESPHOME_PROJECT_NAME, ESPHOME_PROJECT_VERSION, ESPHOME_VARIANT, App.get_name()};
175
+ #else
173
176
  std::vector<std::string> infos = {"ESPHome", ESPHOME_VERSION, ESPHOME_VARIANT, App.get_name()};
177
+ #endif
174
178
  std::vector<uint8_t> data = improv::build_rpc_response(improv::GET_DEVICE_INFO, infos, false);
175
179
  return data;
176
180
  };
@@ -31,7 +31,16 @@ void Jsnsr04tComponent::loop() {
31
31
  }
32
32
 
33
33
  void Jsnsr04tComponent::check_buffer_() {
34
- uint8_t checksum = this->buffer_[0] + this->buffer_[1] + this->buffer_[2];
34
+ uint8_t checksum = 0;
35
+ switch (this->model_) {
36
+ case JSN_SR04T:
37
+ checksum = this->buffer_[0] + this->buffer_[1] + this->buffer_[2];
38
+ break;
39
+ case AJ_SR04M:
40
+ checksum = this->buffer_[1] + this->buffer_[2];
41
+ break;
42
+ }
43
+
35
44
  if (this->buffer_[3] == checksum) {
36
45
  uint16_t distance = encode_uint16(this->buffer_[1], this->buffer_[2]);
37
46
  if (distance > 250) {
@@ -49,6 +58,14 @@ void Jsnsr04tComponent::check_buffer_() {
49
58
 
50
59
  void Jsnsr04tComponent::dump_config() {
51
60
  LOG_SENSOR("", "JST_SR04T Sensor", this);
61
+ switch (this->model_) {
62
+ case JSN_SR04T:
63
+ ESP_LOGCONFIG(TAG, " sensor model: jsn_sr04t");
64
+ break;
65
+ case AJ_SR04M:
66
+ ESP_LOGCONFIG(TAG, " sensor model: aj_sr04m");
67
+ break;
68
+ }
52
69
  LOG_UPDATE_INTERVAL(this);
53
70
  }
54
71
 
@@ -9,9 +9,14 @@
9
9
  namespace esphome {
10
10
  namespace jsn_sr04t {
11
11
 
12
+ enum Model {
13
+ JSN_SR04T,
14
+ AJ_SR04M,
15
+ };
16
+
12
17
  class Jsnsr04tComponent : public sensor::Sensor, public PollingComponent, public uart::UARTDevice {
13
18
  public:
14
- // Nothing really public.
19
+ void set_model(Model model) { this->model_ = model; }
15
20
 
16
21
  // ========== INTERNAL METHODS ==========
17
22
  void update() override;
@@ -20,6 +25,7 @@ class Jsnsr04tComponent : public sensor::Sensor, public PollingComponent, public
20
25
 
21
26
  protected:
22
27
  void check_buffer_();
28
+ Model model_;
23
29
 
24
30
  std::vector<uint8_t> buffer_;
25
31
  };
@@ -5,6 +5,7 @@ from esphome.const import (
5
5
  STATE_CLASS_MEASUREMENT,
6
6
  UNIT_METER,
7
7
  ICON_ARROW_EXPAND_VERTICAL,
8
+ CONF_MODEL,
8
9
  )
9
10
 
10
11
  CODEOWNERS = ["@Mafus1"]
@@ -14,6 +15,11 @@ jsn_sr04t_ns = cg.esphome_ns.namespace("jsn_sr04t")
14
15
  Jsnsr04tComponent = jsn_sr04t_ns.class_(
15
16
  "Jsnsr04tComponent", sensor.Sensor, cg.PollingComponent, uart.UARTDevice
16
17
  )
18
+ Model = jsn_sr04t_ns.enum("Model")
19
+ MODEL = {
20
+ "jsn_sr04t": Model.JSN_SR04T,
21
+ "aj_sr04m": Model.AJ_SR04M,
22
+ }
17
23
 
18
24
  CONFIG_SCHEMA = (
19
25
  sensor.sensor_schema(
@@ -25,6 +31,11 @@ CONFIG_SCHEMA = (
25
31
  )
26
32
  .extend(cv.polling_component_schema("60s"))
27
33
  .extend(uart.UART_DEVICE_SCHEMA)
34
+ .extend(
35
+ {
36
+ cv.Optional(CONF_MODEL, default="jsn_sr04t"): cv.enum(MODEL, upper=False),
37
+ }
38
+ )
28
39
  )
29
40
 
30
41
  FINAL_VALIDATE_SCHEMA = uart.final_validate_device_schema(
@@ -42,3 +53,5 @@ async def to_code(config):
42
53
  var = await sensor.new_sensor(config)
43
54
  await cg.register_component(var, config)
44
55
  await uart.register_uart_device(var, config)
56
+
57
+ cg.add(var.set_model(config[CONF_MODEL]))
@@ -1,6 +1,6 @@
1
1
  import esphome.config_validation as cv
2
2
 
3
- CONFIG_SCHEMA = CONFIG_SCHEMA = cv.invalid(
3
+ CONFIG_SCHEMA = cv.invalid(
4
4
  "The kalman_combinator sensor has moved.\nPlease use the combination platform instead with type: kalman.\n"
5
5
  "See https://esphome.io/components/sensor/combination.html"
6
6
  )
@@ -1,8 +1,9 @@
1
- import esphome.codegen as cg
2
- import esphome.config_validation as cv
3
1
  import esphome.automation as auto
2
+ import esphome.codegen as cg
4
3
  from esphome.components import mqtt, power_supply, web_server
4
+ import esphome.config_validation as cv
5
5
  from esphome.const import (
6
+ CONF_COLD_WHITE_COLOR_TEMPERATURE,
6
7
  CONF_COLOR_CORRECT,
7
8
  CONF_DEFAULT_TRANSITION_LENGTH,
8
9
  CONF_EFFECTS,
@@ -10,36 +11,36 @@ from esphome.const import (
10
11
  CONF_GAMMA_CORRECT,
11
12
  CONF_ID,
12
13
  CONF_MQTT_ID,
13
- CONF_WEB_SERVER_ID,
14
- CONF_POWER_SUPPLY,
15
- CONF_RESTORE_MODE,
14
+ CONF_ON_STATE,
16
15
  CONF_ON_TURN_OFF,
17
16
  CONF_ON_TURN_ON,
18
- CONF_ON_STATE,
17
+ CONF_POWER_SUPPLY,
18
+ CONF_RESTORE_MODE,
19
19
  CONF_TRIGGER_ID,
20
- CONF_COLD_WHITE_COLOR_TEMPERATURE,
21
20
  CONF_WARM_WHITE_COLOR_TEMPERATURE,
21
+ CONF_WEB_SERVER_ID,
22
22
  )
23
23
  from esphome.core import coroutine_with_priority
24
24
  from esphome.cpp_helpers import setup_entity
25
+
25
26
  from .automation import light_control_to_code # noqa
26
27
  from .effects import (
27
- validate_effects,
28
+ ADDRESSABLE_EFFECTS,
28
29
  BINARY_EFFECTS,
30
+ EFFECTS_REGISTRY,
29
31
  MONOCHROMATIC_EFFECTS,
30
32
  RGB_EFFECTS,
31
- ADDRESSABLE_EFFECTS,
32
- EFFECTS_REGISTRY,
33
+ validate_effects,
33
34
  )
34
35
  from .types import ( # noqa
35
- LightState,
36
+ AddressableLight,
36
37
  AddressableLightState,
37
- light_ns,
38
38
  LightOutput,
39
- AddressableLight,
40
- LightTurnOnTrigger,
41
- LightTurnOffTrigger,
39
+ LightState,
42
40
  LightStateTrigger,
41
+ LightTurnOffTrigger,
42
+ LightTurnOnTrigger,
43
+ light_ns,
43
44
  )
44
45
 
45
46
  CODEOWNERS = ["@esphome/core"]
@@ -114,10 +114,11 @@ class AddressableColorWipeEffect : public AddressableLightEffect {
114
114
  if (now - this->last_add_ < this->add_led_interval_)
115
115
  return;
116
116
  this->last_add_ = now;
117
- if (this->reverse_)
117
+ if (this->reverse_) {
118
118
  it.shift_left(1);
119
- else
119
+ } else {
120
120
  it.shift_right(1);
121
+ }
121
122
  const AddressableColorWipeEffectColor &color = this->colors_[this->at_color_];
122
123
  Color esp_color = Color(color.r, color.g, color.b, color.w);
123
124
  if (color.gradient) {
@@ -127,10 +128,11 @@ class AddressableColorWipeEffect : public AddressableLightEffect {
127
128
  uint8_t gradient = 255 * ((float) this->leds_added_ / color.num_leds);
128
129
  esp_color = esp_color.gradient(next_esp_color, gradient);
129
130
  }
130
- if (this->reverse_)
131
+ if (this->reverse_) {
131
132
  it[-1] = esp_color;
132
- else
133
+ } else {
133
134
  it[0] = esp_color;
135
+ }
134
136
  if (++this->leds_added_ >= color.num_leds) {
135
137
  this->leds_added_ = 0;
136
138
  this->at_color_ = (this->at_color_ + 1) % this->colors_.size();
@@ -207,10 +209,11 @@ class AddressableTwinkleEffect : public AddressableLightEffect {
207
209
  const uint8_t sine = half_sin8(view.get_effect_data());
208
210
  view = current_color * sine;
209
211
  const uint8_t new_pos = view.get_effect_data() + pos_add;
210
- if (new_pos < view.get_effect_data())
212
+ if (new_pos < view.get_effect_data()) {
211
213
  view.set_effect_data(0);
212
- else
214
+ } else {
213
215
  view.set_effect_data(new_pos);
216
+ }
214
217
  } else {
215
218
  view = Color::BLACK;
216
219
  }
@@ -254,10 +257,11 @@ class AddressableRandomTwinkleEffect : public AddressableLightEffect {
254
257
  view = Color(((color >> 2) & 1) * sine, ((color >> 1) & 1) * sine, ((color >> 0) & 1) * sine);
255
258
  }
256
259
  const uint8_t new_x = x + pos_add;
257
- if (new_x > 0b11111)
260
+ if (new_x > 0b11111) {
258
261
  view.set_effect_data(0);
259
- else
262
+ } else {
260
263
  view.set_effect_data((new_x << 3) | color);
264
+ }
261
265
  } else {
262
266
  view = Color(0, 0, 0, 0);
263
267
  }
@@ -7,6 +7,8 @@
7
7
  namespace esphome {
8
8
  namespace light {
9
9
 
10
+ enum class LimitMode { CLAMP, DO_NOTHING };
11
+
10
12
  template<typename... Ts> class ToggleAction : public Action<Ts...> {
11
13
  public:
12
14
  explicit ToggleAction(LightState *state) : state_(state) {}
@@ -77,7 +79,10 @@ template<typename... Ts> class DimRelativeAction : public Action<Ts...> {
77
79
  float rel = this->relative_brightness_.value(x...);
78
80
  float cur;
79
81
  this->parent_->remote_values.as_brightness(&cur);
80
- float new_brightness = clamp(cur + rel, 0.0f, 1.0f);
82
+ if ((limit_mode_ == LimitMode::DO_NOTHING) && ((cur < min_brightness_) || (cur > max_brightness_))) {
83
+ return;
84
+ }
85
+ float new_brightness = clamp(cur + rel, min_brightness_, max_brightness_);
81
86
  call.set_state(new_brightness != 0.0f);
82
87
  call.set_brightness(new_brightness);
83
88
 
@@ -85,8 +90,18 @@ template<typename... Ts> class DimRelativeAction : public Action<Ts...> {
85
90
  call.perform();
86
91
  }
87
92
 
93
+ void set_min_max_brightness(float min, float max) {
94
+ this->min_brightness_ = min;
95
+ this->max_brightness_ = max;
96
+ }
97
+
98
+ void set_limit_mode(LimitMode limit_mode) { this->limit_mode_ = limit_mode; }
99
+
88
100
  protected:
89
101
  LightState *parent_;
102
+ float min_brightness_{0.0};
103
+ float max_brightness_{1.0};
104
+ LimitMode limit_mode_{LimitMode::CLAMP};
90
105
  };
91
106
 
92
107
  template<typename... Ts> class LightIsOnCondition : public Condition<Ts...> {
@@ -19,10 +19,15 @@ from esphome.const import (
19
19
  CONF_WARM_WHITE,
20
20
  CONF_RANGE_FROM,
21
21
  CONF_RANGE_TO,
22
+ CONF_BRIGHTNESS_LIMITS,
23
+ CONF_LIMIT_MODE,
24
+ CONF_MIN_BRIGHTNESS,
25
+ CONF_MAX_BRIGHTNESS,
22
26
  )
23
27
  from .types import (
24
28
  ColorMode,
25
29
  COLOR_MODES,
30
+ LIMIT_MODES,
26
31
  DimRelativeAction,
27
32
  ToggleAction,
28
33
  LightState,
@@ -167,6 +172,15 @@ LIGHT_DIM_RELATIVE_ACTION_SCHEMA = cv.Schema(
167
172
  cv.Optional(CONF_TRANSITION_LENGTH): cv.templatable(
168
173
  cv.positive_time_period_milliseconds
169
174
  ),
175
+ cv.Optional(CONF_BRIGHTNESS_LIMITS): cv.Schema(
176
+ {
177
+ cv.Optional(CONF_MIN_BRIGHTNESS, default="0%"): cv.percentage,
178
+ cv.Optional(CONF_MAX_BRIGHTNESS, default="100%"): cv.percentage,
179
+ cv.Optional(CONF_LIMIT_MODE, default="CLAMP"): cv.enum(
180
+ LIMIT_MODES, upper=True, space="_"
181
+ ),
182
+ }
183
+ ),
170
184
  }
171
185
  )
172
186
 
@@ -182,6 +196,13 @@ async def light_dim_relative_to_code(config, action_id, template_arg, args):
182
196
  if CONF_TRANSITION_LENGTH in config:
183
197
  templ = await cg.templatable(config[CONF_TRANSITION_LENGTH], args, cg.uint32)
184
198
  cg.add(var.set_transition_length(templ))
199
+ if conf := config.get(CONF_BRIGHTNESS_LIMITS):
200
+ cg.add(
201
+ var.set_min_max_brightness(
202
+ conf[CONF_MIN_BRIGHTNESS], conf[CONF_MAX_BRIGHTNESS]
203
+ )
204
+ )
205
+ cg.add(var.set_limit_mode(conf[CONF_LIMIT_MODE]))
185
206
  return var
186
207
 
187
208
 
@@ -25,7 +25,7 @@ class PulseLightEffect : public LightEffect {
25
25
  return;
26
26
  }
27
27
  auto call = this->state_->turn_on();
28
- float out = this->on_ ? this->max_brightness : this->min_brightness;
28
+ float out = this->on_ ? this->max_brightness_ : this->min_brightness_;
29
29
  call.set_brightness_if_supported(out);
30
30
  call.set_transition_length_if_supported(this->on_ ? this->transition_on_length_ : this->transition_off_length_);
31
31
  this->on_ = !this->on_;
@@ -43,8 +43,8 @@ class PulseLightEffect : public LightEffect {
43
43
  void set_update_interval(uint32_t update_interval) { this->update_interval_ = update_interval; }
44
44
 
45
45
  void set_min_max_brightness(float min, float max) {
46
- this->min_brightness = min;
47
- this->max_brightness = max;
46
+ this->min_brightness_ = min;
47
+ this->max_brightness_ = max;
48
48
  }
49
49
 
50
50
  protected:
@@ -53,8 +53,8 @@ class PulseLightEffect : public LightEffect {
53
53
  uint32_t transition_on_length_{};
54
54
  uint32_t transition_off_length_{};
55
55
  uint32_t update_interval_{};
56
- float min_brightness{0.0};
57
- float max_brightness{1.0};
56
+ float min_brightness_{0.0};
57
+ float max_brightness_{1.0};
58
58
  };
59
59
 
60
60
  /// Random effect. Sets random colors every 10 seconds and slowly transitions between them.
@@ -41,29 +41,29 @@ class ESPColorCorrection {
41
41
  if (this->max_brightness_.red == 0 || this->local_brightness_ == 0)
42
42
  return 0;
43
43
  uint16_t uncorrected = this->gamma_reverse_table_[red] * 255UL;
44
- uint8_t res = ((uncorrected / this->max_brightness_.red) * 255UL) / this->local_brightness_;
45
- return res;
44
+ uint16_t res = ((uncorrected / this->max_brightness_.red) * 255UL) / this->local_brightness_;
45
+ return (uint8_t) std::min(res, uint16_t(255));
46
46
  }
47
47
  inline uint8_t color_uncorrect_green(uint8_t green) const ESPHOME_ALWAYS_INLINE {
48
48
  if (this->max_brightness_.green == 0 || this->local_brightness_ == 0)
49
49
  return 0;
50
50
  uint16_t uncorrected = this->gamma_reverse_table_[green] * 255UL;
51
- uint8_t res = ((uncorrected / this->max_brightness_.green) * 255UL) / this->local_brightness_;
52
- return res;
51
+ uint16_t res = ((uncorrected / this->max_brightness_.green) * 255UL) / this->local_brightness_;
52
+ return (uint8_t) std::min(res, uint16_t(255));
53
53
  }
54
54
  inline uint8_t color_uncorrect_blue(uint8_t blue) const ESPHOME_ALWAYS_INLINE {
55
55
  if (this->max_brightness_.blue == 0 || this->local_brightness_ == 0)
56
56
  return 0;
57
57
  uint16_t uncorrected = this->gamma_reverse_table_[blue] * 255UL;
58
- uint8_t res = ((uncorrected / this->max_brightness_.blue) * 255UL) / this->local_brightness_;
59
- return res;
58
+ uint16_t res = ((uncorrected / this->max_brightness_.blue) * 255UL) / this->local_brightness_;
59
+ return (uint8_t) std::min(res, uint16_t(255));
60
60
  }
61
61
  inline uint8_t color_uncorrect_white(uint8_t white) const ESPHOME_ALWAYS_INLINE {
62
62
  if (this->max_brightness_.white == 0 || this->local_brightness_ == 0)
63
63
  return 0;
64
64
  uint16_t uncorrected = this->gamma_reverse_table_[white] * 255UL;
65
- uint8_t res = ((uncorrected / this->max_brightness_.white) * 255UL) / this->local_brightness_;
66
- return res;
65
+ uint16_t res = ((uncorrected / this->max_brightness_.white) * 255UL) / this->local_brightness_;
66
+ return (uint8_t) std::min(res, uint16_t(255));
67
67
  }
68
68
 
69
69
  protected:
@@ -26,6 +26,13 @@ COLOR_MODES = {
26
26
  "RGB_COLD_WARM_WHITE": ColorMode.RGB_COLD_WARM_WHITE,
27
27
  }
28
28
 
29
+ # Limit modes
30
+ LimitMode = light_ns.enum("LimitMode", is_class=True)
31
+ LIMIT_MODES = {
32
+ "CLAMP": LimitMode.CLAMP,
33
+ "DO_NOTHING": LimitMode.DO_NOTHING,
34
+ }
35
+
29
36
  # Actions
30
37
  ToggleAction = light_ns.class_("ToggleAction", automation.Action)
31
38
  LightControlAction = light_ns.class_("LightControlAction", automation.Action)
@@ -1,14 +1,14 @@
1
- import esphome.codegen as cg
2
- import esphome.config_validation as cv
3
1
  from esphome import automation
4
2
  from esphome.automation import Condition, maybe_simple_id
3
+ import esphome.codegen as cg
5
4
  from esphome.components import mqtt, web_server
5
+ import esphome.config_validation as cv
6
6
  from esphome.const import (
7
7
  CONF_ID,
8
+ CONF_MQTT_ID,
8
9
  CONF_ON_LOCK,
9
10
  CONF_ON_UNLOCK,
10
11
  CONF_TRIGGER_ID,
11
- CONF_MQTT_ID,
12
12
  CONF_WEB_SERVER_ID,
13
13
  )
14
14
  from esphome.core import CORE, coroutine_with_priority
@@ -1,9 +1,21 @@
1
1
  import re
2
2
 
3
- import esphome.codegen as cg
4
- import esphome.config_validation as cv
5
3
  from esphome import automation
6
4
  from esphome.automation import LambdaAction
5
+ import esphome.codegen as cg
6
+ from esphome.components.esp32 import add_idf_sdkconfig_option, get_esp32_variant
7
+ from esphome.components.esp32.const import (
8
+ VARIANT_ESP32,
9
+ VARIANT_ESP32C2,
10
+ VARIANT_ESP32C3,
11
+ VARIANT_ESP32C6,
12
+ VARIANT_ESP32H2,
13
+ VARIANT_ESP32S2,
14
+ VARIANT_ESP32S3,
15
+ )
16
+ from esphome.components.libretiny import get_libretiny_component, get_libretiny_family
17
+ from esphome.components.libretiny.const import COMPONENT_BK72XX, COMPONENT_RTL87XX
18
+ import esphome.config_validation as cv
7
19
  from esphome.const import (
8
20
  CONF_ARGS,
9
21
  CONF_BAUD_RATE,
@@ -18,27 +30,12 @@ from esphome.const import (
18
30
  CONF_TRIGGER_ID,
19
31
  CONF_TX_BUFFER_SIZE,
20
32
  PLATFORM_BK72XX,
21
- PLATFORM_RTL87XX,
22
33
  PLATFORM_ESP32,
23
34
  PLATFORM_ESP8266,
24
35
  PLATFORM_RP2040,
36
+ PLATFORM_RTL87XX,
25
37
  )
26
38
  from esphome.core import CORE, EsphomeError, Lambda, coroutine_with_priority
27
- from esphome.components.esp32 import add_idf_sdkconfig_option, get_esp32_variant
28
- from esphome.components.esp32.const import (
29
- VARIANT_ESP32,
30
- VARIANT_ESP32S2,
31
- VARIANT_ESP32C3,
32
- VARIANT_ESP32S3,
33
- VARIANT_ESP32C2,
34
- VARIANT_ESP32C6,
35
- VARIANT_ESP32H2,
36
- )
37
- from esphome.components.libretiny import get_libretiny_component, get_libretiny_family
38
- from esphome.components.libretiny.const import (
39
- COMPONENT_BK72XX,
40
- COMPONENT_RTL87XX,
41
- )
42
39
 
43
40
  CODEOWNERS = ["@esphome/core"]
44
41
  logger_ns = cg.esphome_ns.namespace("logger")