esphome 2024.7.2__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 (353) 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/micro_wake_word/streaming_model.cpp +6 -4
  203. esphome/components/microphone/microphone.h +4 -1
  204. esphome/components/mitsubishi/mitsubishi.cpp +7 -1
  205. esphome/components/modbus_controller/__init__.py +26 -2
  206. esphome/components/modbus_controller/automation.h +19 -0
  207. esphome/components/modbus_controller/const.py +1 -0
  208. esphome/components/modbus_controller/modbus_controller.cpp +8 -0
  209. esphome/components/modbus_controller/modbus_controller.h +3 -0
  210. esphome/components/mqtt/__init__.py +20 -9
  211. esphome/components/mqtt/mqtt_alarm_control_panel.cpp +128 -0
  212. esphome/components/mqtt/mqtt_alarm_control_panel.h +39 -0
  213. esphome/components/mqtt/mqtt_backend.h +3 -1
  214. esphome/components/mqtt/mqtt_backend_esp32.cpp +4 -1
  215. esphome/components/mqtt/mqtt_backend_esp32.h +3 -1
  216. esphome/components/mqtt/mqtt_backend_esp8266.h +3 -1
  217. esphome/components/mqtt/mqtt_backend_libretiny.h +3 -1
  218. esphome/components/mqtt/mqtt_client.cpp +16 -3
  219. esphome/components/mqtt/mqtt_client.h +5 -1
  220. esphome/components/mqtt/mqtt_component.cpp +32 -4
  221. esphome/components/mqtt/mqtt_const.h +2 -0
  222. esphome/components/network/__init__.py +15 -12
  223. esphome/components/network/ip_address.h +3 -0
  224. esphome/components/network/util.cpp +2 -1
  225. esphome/components/network/util.h +3 -1
  226. esphome/components/nextion/base_component.py +5 -8
  227. esphome/components/number/__init__.py +7 -8
  228. esphome/components/online_image/__init__.py +167 -0
  229. esphome/components/online_image/image_decoder.cpp +44 -0
  230. esphome/components/online_image/image_decoder.h +112 -0
  231. esphome/components/online_image/online_image.cpp +283 -0
  232. esphome/components/online_image/online_image.h +195 -0
  233. esphome/components/online_image/png_image.cpp +68 -0
  234. esphome/components/online_image/png_image.h +33 -0
  235. esphome/components/ota/__init__.py +8 -4
  236. esphome/components/pid/pid_climate.h +2 -0
  237. esphome/components/pmwcs3/pmwcs3.cpp +31 -30
  238. esphome/components/remote_base/pronto_protocol.cpp +0 -3
  239. esphome/components/remote_transmitter/remote_transmitter.h +1 -1
  240. esphome/components/rgbct/rgbct_light_output.h +3 -2
  241. esphome/components/rgbw/rgbw_light_output.h +3 -2
  242. esphome/components/rgbww/rgbww_light_output.h +3 -2
  243. esphome/components/rp2040_pio_led_strip/led_strip.cpp +31 -5
  244. esphome/components/rp2040_pio_led_strip/led_strip.h +5 -0
  245. esphome/components/rtttl/rtttl.cpp +108 -21
  246. esphome/components/rtttl/rtttl.h +15 -6
  247. esphome/components/select/__init__.py +7 -7
  248. esphome/components/sensor/__init__.py +29 -10
  249. esphome/components/sensor/filter.cpp +8 -0
  250. esphome/components/sensor/filter.h +9 -0
  251. esphome/components/sml/sml_parser.cpp +48 -22
  252. esphome/components/socket/socket.cpp +11 -14
  253. esphome/components/speaker/__init__.py +14 -5
  254. esphome/components/speaker/automation.h +10 -0
  255. esphome/components/speaker/speaker.h +9 -0
  256. esphome/components/spi/spi.cpp +0 -6
  257. esphome/components/spi/spi.h +2 -19
  258. esphome/components/spi_led_strip/spi_led_strip.h +5 -4
  259. esphome/components/sprinkler/sprinkler.cpp +2 -2
  260. esphome/components/sprinkler/sprinkler.h +1 -1
  261. esphome/components/switch/__init__.py +3 -3
  262. esphome/components/text/__init__.py +5 -5
  263. esphome/components/text_sensor/__init__.py +7 -7
  264. esphome/components/time/__init__.py +8 -8
  265. esphome/components/touchscreen/binary_sensor/__init__.py +24 -10
  266. esphome/components/touchscreen/binary_sensor/touchscreen_binary_sensor.cpp +3 -2
  267. esphome/components/touchscreen/binary_sensor/touchscreen_binary_sensor.h +4 -2
  268. esphome/components/uart/uart_component_host.cpp +6 -2
  269. esphome/components/update/__init__.py +33 -15
  270. esphome/components/update/automation.h +23 -0
  271. esphome/components/update/update_entity.h +3 -1
  272. esphome/components/valve/__init__.py +3 -3
  273. esphome/components/voice_assistant/__init__.py +7 -8
  274. esphome/components/wake_on_lan/wake_on_lan.cpp +2 -0
  275. esphome/components/wake_on_lan/wake_on_lan.h +3 -1
  276. esphome/components/watchdog/__init__.py +1 -0
  277. esphome/components/{http_request → watchdog}/watchdog.cpp +0 -2
  278. esphome/components/{http_request → watchdog}/watchdog.h +0 -2
  279. esphome/components/waveshare_epaper/waveshare_epaper.cpp +5 -5
  280. esphome/components/web_server/server_index_v3.h +3615 -3603
  281. esphome/components/web_server/web_server.cpp +0 -209
  282. esphome/components/web_server/web_server.h +1 -1
  283. esphome/components/web_server/web_server_v1.cpp +217 -0
  284. esphome/components/web_server_base/web_server_base.h +1 -0
  285. esphome/components/wifi/__init__.py +15 -14
  286. esphome/components/wifi/wifi_component.cpp +2 -0
  287. esphome/components/wifi/wifi_component.h +7 -1
  288. esphome/components/wifi/wifi_component_esp32_arduino.cpp +5 -2
  289. esphome/components/wifi/wifi_component_esp8266.cpp +2 -0
  290. esphome/components/wifi/wifi_component_esp_idf.cpp +43 -7
  291. esphome/components/wifi/wifi_component_libretiny.cpp +2 -0
  292. esphome/components/wifi/wifi_component_pico_w.cpp +2 -0
  293. esphome/components/wifi/wpa2_eap.py +6 -7
  294. esphome/components/wifi_info/text_sensor.py +3 -3
  295. esphome/components/wifi_info/wifi_info_text_sensor.cpp +2 -0
  296. esphome/components/wifi_info/wifi_info_text_sensor.h +2 -0
  297. esphome/components/wifi_signal/sensor.py +1 -1
  298. esphome/components/wifi_signal/wifi_signal_sensor.cpp +2 -0
  299. esphome/components/wifi_signal/wifi_signal_sensor.h +2 -1
  300. esphome/components/xiaomi_ble/xiaomi_ble.cpp +20 -3
  301. esphome/components/xiaomi_ble/xiaomi_ble.h +1 -0
  302. esphome/components/xiaomi_lywsd02mmc/__init__.py +0 -0
  303. esphome/components/xiaomi_lywsd02mmc/sensor.py +77 -0
  304. esphome/components/xiaomi_lywsd02mmc/xiaomi_lywsd02mmc.cpp +73 -0
  305. esphome/components/xiaomi_lywsd02mmc/xiaomi_lywsd02mmc.h +37 -0
  306. esphome/config.py +17 -19
  307. esphome/config_validation.py +55 -23
  308. esphome/const.py +25 -9
  309. esphome/core/__init__.py +17 -14
  310. esphome/core/application.h +42 -21
  311. esphome/core/automation.h +5 -3
  312. esphome/core/base_automation.h +3 -2
  313. esphome/core/bytebuffer.cpp +134 -0
  314. esphome/core/bytebuffer.h +96 -0
  315. esphome/core/color.h +24 -16
  316. esphome/core/config.py +3 -3
  317. esphome/core/defines.h +14 -1
  318. esphome/core/entity_base.h +2 -2
  319. esphome/core/entity_helpers.py +1 -2
  320. esphome/core/gpio.h +0 -18
  321. esphome/core/helpers.h +1 -1
  322. esphome/core/optional.h +15 -16
  323. esphome/coroutine.py +1 -1
  324. esphome/cpp_generator.py +1 -1
  325. esphome/cpp_helpers.py +3 -5
  326. esphome/dashboard/core.py +3 -3
  327. esphome/dashboard/dashboard.py +3 -3
  328. esphome/dashboard/entries.py +1 -1
  329. esphome/dashboard/util/file.py +1 -1
  330. esphome/dashboard/web_server.py +3 -3
  331. esphome/external_files.py +5 -3
  332. esphome/final_validate.py +2 -2
  333. esphome/git.py +4 -4
  334. esphome/helpers.py +5 -5
  335. esphome/loader.py +15 -10
  336. esphome/mqtt.py +4 -8
  337. esphome/pins.py +6 -6
  338. esphome/platformio_api.py +5 -5
  339. esphome/storage_json.py +2 -1
  340. esphome/types.py +1 -1
  341. esphome/util.py +2 -3
  342. esphome/voluptuous_schema.py +1 -0
  343. esphome/vscode.py +5 -4
  344. esphome/wizard.py +1 -1
  345. esphome/writer.py +7 -7
  346. esphome/yaml_util.py +3 -3
  347. esphome/zeroconf.py +1 -1
  348. {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/METADATA +3 -3
  349. {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/RECORD +353 -247
  350. {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/LICENSE +0 -0
  351. {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/WHEEL +0 -0
  352. {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/entry_points.txt +0 -0
  353. {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,63 @@
1
+ import esphome.config_validation as cv
2
+ from esphome.const import CONF_MAX_VALUE, CONF_MIN_VALUE, CONF_MODE, CONF_VALUE
3
+
4
+ from ..defines import (
5
+ BAR_MODES,
6
+ CONF_ANIMATED,
7
+ CONF_INDICATOR,
8
+ CONF_KNOB,
9
+ CONF_MAIN,
10
+ literal,
11
+ )
12
+ from ..helpers import add_lv_use
13
+ from ..lv_validation import animated, get_start_value, lv_float
14
+ from ..lvcode import lv
15
+ from ..types import LvNumber, NumberType
16
+ from . import Widget
17
+ from .lv_bar import CONF_BAR
18
+
19
+ CONF_SLIDER = "slider"
20
+ SLIDER_MODIFY_SCHEMA = cv.Schema(
21
+ {
22
+ cv.Optional(CONF_VALUE): lv_float,
23
+ cv.Optional(CONF_ANIMATED, default=True): animated,
24
+ }
25
+ )
26
+
27
+ SLIDER_SCHEMA = cv.Schema(
28
+ {
29
+ cv.Optional(CONF_VALUE): lv_float,
30
+ cv.Optional(CONF_MIN_VALUE, default=0): cv.int_,
31
+ cv.Optional(CONF_MAX_VALUE, default=100): cv.int_,
32
+ cv.Optional(CONF_MODE, default="NORMAL"): BAR_MODES.one_of,
33
+ cv.Optional(CONF_ANIMATED, default=True): animated,
34
+ }
35
+ )
36
+
37
+
38
+ class SliderType(NumberType):
39
+ def __init__(self):
40
+ super().__init__(
41
+ CONF_SLIDER,
42
+ LvNumber("lv_slider_t"),
43
+ parts=(CONF_MAIN, CONF_INDICATOR, CONF_KNOB),
44
+ schema=SLIDER_SCHEMA,
45
+ modify_schema=SLIDER_MODIFY_SCHEMA,
46
+ )
47
+
48
+ @property
49
+ def animated(self):
50
+ return True
51
+
52
+ async def to_code(self, w: Widget, config):
53
+ add_lv_use(CONF_BAR)
54
+ if CONF_MIN_VALUE in config:
55
+ # not modify case
56
+ lv.slider_set_range(w.obj, config[CONF_MIN_VALUE], config[CONF_MAX_VALUE])
57
+ lv.slider_set_mode(w.obj, literal(config[CONF_MODE]))
58
+ value = await get_start_value(config)
59
+ if value is not None:
60
+ lv.slider_set_value(w.obj, value, literal(config[CONF_ANIMATED]))
61
+
62
+
63
+ slider_spec = SliderType()
@@ -0,0 +1,178 @@
1
+ from esphome import automation
2
+ import esphome.config_validation as cv
3
+ from esphome.const import CONF_ID, CONF_RANGE_FROM, CONF_RANGE_TO, CONF_STEP, CONF_VALUE
4
+
5
+ from ..automation import action_to_code, update_to_code
6
+ from ..defines import (
7
+ CONF_CURSOR,
8
+ CONF_DECIMAL_PLACES,
9
+ CONF_DIGITS,
10
+ CONF_MAIN,
11
+ CONF_ROLLOVER,
12
+ CONF_SCROLLBAR,
13
+ CONF_SELECTED,
14
+ CONF_TEXTAREA_PLACEHOLDER,
15
+ )
16
+ from ..lv_validation import lv_bool, lv_float
17
+ from ..lvcode import lv
18
+ from ..types import LvNumber, ObjUpdateAction
19
+ from . import Widget, WidgetType, get_widgets
20
+ from .label import CONF_LABEL
21
+ from .textarea import CONF_TEXTAREA
22
+
23
+ CONF_SPINBOX = "spinbox"
24
+
25
+ lv_spinbox_t = LvNumber("lv_spinbox_t")
26
+
27
+ SPIN_ACTIONS = (
28
+ "INCREMENT",
29
+ "DECREMENT",
30
+ "STEP_NEXT",
31
+ "STEP_PREV",
32
+ "CLEAR",
33
+ )
34
+
35
+
36
+ def validate_spinbox(config):
37
+ max_val = 2**31 - 1
38
+ min_val = -1 - max_val
39
+ range_from = int(config[CONF_RANGE_FROM])
40
+ range_to = int(config[CONF_RANGE_TO])
41
+ step = int(config[CONF_STEP])
42
+ if (
43
+ range_from > max_val
44
+ or range_from < min_val
45
+ or range_to > max_val
46
+ or range_to < min_val
47
+ ):
48
+ raise cv.Invalid("Range outside allowed limits")
49
+ if step <= 0 or step >= (range_to - range_from) / 2:
50
+ raise cv.Invalid("Invalid step value")
51
+ if config[CONF_DIGITS] <= config[CONF_DECIMAL_PLACES]:
52
+ raise cv.Invalid("Number of digits must exceed number of decimal places")
53
+ return config
54
+
55
+
56
+ SPINBOX_SCHEMA = cv.Schema(
57
+ {
58
+ cv.Optional(CONF_VALUE): lv_float,
59
+ cv.Optional(CONF_RANGE_FROM, default=0): cv.float_,
60
+ cv.Optional(CONF_RANGE_TO, default=100): cv.float_,
61
+ cv.Optional(CONF_DIGITS, default=4): cv.int_range(1, 10),
62
+ cv.Optional(CONF_STEP, default=1.0): cv.positive_float,
63
+ cv.Optional(CONF_DECIMAL_PLACES, default=0): cv.int_range(0, 6),
64
+ cv.Optional(CONF_ROLLOVER, default=False): lv_bool,
65
+ }
66
+ ).add_extra(validate_spinbox)
67
+
68
+
69
+ SPINBOX_MODIFY_SCHEMA = {
70
+ cv.Required(CONF_VALUE): lv_float,
71
+ }
72
+
73
+
74
+ class SpinboxType(WidgetType):
75
+ def __init__(self):
76
+ super().__init__(
77
+ CONF_SPINBOX,
78
+ lv_spinbox_t,
79
+ (
80
+ CONF_MAIN,
81
+ CONF_SCROLLBAR,
82
+ CONF_SELECTED,
83
+ CONF_CURSOR,
84
+ CONF_TEXTAREA_PLACEHOLDER,
85
+ ),
86
+ SPINBOX_SCHEMA,
87
+ SPINBOX_MODIFY_SCHEMA,
88
+ )
89
+
90
+ async def to_code(self, w: Widget, config):
91
+ if CONF_DIGITS in config:
92
+ digits = config[CONF_DIGITS]
93
+ scale = 10 ** config[CONF_DECIMAL_PLACES]
94
+ range_from = int(config[CONF_RANGE_FROM]) * scale
95
+ range_to = int(config[CONF_RANGE_TO]) * scale
96
+ step = int(config[CONF_STEP]) * scale
97
+ w.scale = scale
98
+ w.step = step
99
+ w.range_to = range_to
100
+ w.range_from = range_from
101
+ lv.spinbox_set_range(w.obj, range_from, range_to)
102
+ await w.set_property(CONF_STEP, step)
103
+ await w.set_property(CONF_ROLLOVER, config)
104
+ lv.spinbox_set_digit_format(
105
+ w.obj, digits, digits - config[CONF_DECIMAL_PLACES]
106
+ )
107
+ if (value := config.get(CONF_VALUE)) is not None:
108
+ lv.spinbox_set_value(w.obj, await lv_float.process(value))
109
+
110
+ def get_scale(self, config):
111
+ return 10 ** config[CONF_DECIMAL_PLACES]
112
+
113
+ def get_uses(self):
114
+ return CONF_TEXTAREA, CONF_LABEL
115
+
116
+ def get_max(self, config: dict):
117
+ return config[CONF_RANGE_TO]
118
+
119
+ def get_min(self, config: dict):
120
+ return config[CONF_RANGE_FROM]
121
+
122
+ def get_step(self, config: dict):
123
+ return config[CONF_STEP]
124
+
125
+
126
+ spinbox_spec = SpinboxType()
127
+
128
+
129
+ @automation.register_action(
130
+ "lvgl.spinbox.increment",
131
+ ObjUpdateAction,
132
+ cv.maybe_simple_value(
133
+ {
134
+ cv.Required(CONF_ID): cv.use_id(lv_spinbox_t),
135
+ },
136
+ key=CONF_ID,
137
+ ),
138
+ )
139
+ async def spinbox_increment(config, action_id, template_arg, args):
140
+ widgets = await get_widgets(config)
141
+
142
+ async def do_increment(w: Widget):
143
+ lv.spinbox_increment(w.obj)
144
+
145
+ return await action_to_code(widgets, do_increment, action_id, template_arg, args)
146
+
147
+
148
+ @automation.register_action(
149
+ "lvgl.spinbox.decrement",
150
+ ObjUpdateAction,
151
+ cv.maybe_simple_value(
152
+ {
153
+ cv.Required(CONF_ID): cv.use_id(lv_spinbox_t),
154
+ },
155
+ key=CONF_ID,
156
+ ),
157
+ )
158
+ async def spinbox_decrement(config, action_id, template_arg, args):
159
+ widgets = await get_widgets(config)
160
+
161
+ async def do_increment(w: Widget):
162
+ lv.spinbox_decrement(w.obj)
163
+
164
+ return await action_to_code(widgets, do_increment, action_id, template_arg, args)
165
+
166
+
167
+ @automation.register_action(
168
+ "lvgl.spinbox.update",
169
+ ObjUpdateAction,
170
+ cv.Schema(
171
+ {
172
+ cv.Required(CONF_ID): cv.use_id(lv_spinbox_t),
173
+ cv.Required(CONF_VALUE): lv_float,
174
+ }
175
+ ),
176
+ )
177
+ async def spinbox_update_to_code(config, action_id, template_arg, args):
178
+ return await update_to_code(config, action_id, template_arg, args)
@@ -0,0 +1,43 @@
1
+ import esphome.config_validation as cv
2
+ from esphome.cpp_generator import MockObjClass
3
+
4
+ from ..defines import CONF_ARC_LENGTH, CONF_INDICATOR, CONF_MAIN, CONF_SPIN_TIME
5
+ from ..lv_validation import angle
6
+ from ..lvcode import lv_expr
7
+ from ..types import LvType
8
+ from . import Widget, WidgetType
9
+ from .arc import CONF_ARC
10
+
11
+ CONF_SPINNER = "spinner"
12
+
13
+ SPINNER_SCHEMA = cv.Schema(
14
+ {
15
+ cv.Required(CONF_ARC_LENGTH): angle,
16
+ cv.Required(CONF_SPIN_TIME): cv.positive_time_period_milliseconds,
17
+ }
18
+ )
19
+
20
+
21
+ class SpinnerType(WidgetType):
22
+ def __init__(self):
23
+ super().__init__(
24
+ CONF_SPINNER,
25
+ LvType("lv_spinner_t"),
26
+ (CONF_MAIN, CONF_INDICATOR),
27
+ SPINNER_SCHEMA,
28
+ {},
29
+ )
30
+
31
+ async def to_code(self, w: Widget, config):
32
+ return []
33
+
34
+ def get_uses(self):
35
+ return (CONF_ARC,)
36
+
37
+ def obj_creator(self, parent: MockObjClass, config: dict):
38
+ spin_time = config[CONF_SPIN_TIME].total_milliseconds
39
+ arc_length = config[CONF_ARC_LENGTH] // 10
40
+ return lv_expr.call("spinner_create", parent, spin_time, arc_length)
41
+
42
+
43
+ spinner_spec = SpinnerType()
@@ -0,0 +1,20 @@
1
+ from ..defines import CONF_INDICATOR, CONF_KNOB, CONF_MAIN
2
+ from ..types import LvBoolean
3
+ from . import WidgetType
4
+
5
+ CONF_SWITCH = "switch"
6
+
7
+
8
+ class SwitchType(WidgetType):
9
+ def __init__(self):
10
+ super().__init__(
11
+ CONF_SWITCH,
12
+ LvBoolean("lv_switch_t"),
13
+ (CONF_MAIN, CONF_INDICATOR, CONF_KNOB),
14
+ )
15
+
16
+ async def to_code(self, w, config):
17
+ return []
18
+
19
+
20
+ switch_spec = SwitchType()
@@ -0,0 +1,114 @@
1
+ from esphome import automation
2
+ import esphome.codegen as cg
3
+ import esphome.config_validation as cv
4
+ from esphome.const import CONF_ID, CONF_INDEX, CONF_NAME, CONF_POSITION, CONF_SIZE
5
+ from esphome.cpp_generator import MockObjClass
6
+
7
+ from ..automation import action_to_code
8
+ from ..defines import (
9
+ CONF_ANIMATED,
10
+ CONF_MAIN,
11
+ CONF_TAB_ID,
12
+ CONF_TABS,
13
+ DIRECTIONS,
14
+ TYPE_FLEX,
15
+ literal,
16
+ )
17
+ from ..lv_validation import animated, lv_int, size
18
+ from ..lvcode import LocalVariable, lv, lv_assign, lv_expr
19
+ from ..schemas import container_schema, part_schema
20
+ from ..types import LV_EVENT, LvType, ObjUpdateAction, lv_obj_t, lv_obj_t_ptr
21
+ from . import Widget, WidgetType, add_widgets, get_widgets, set_obj_properties
22
+ from .buttonmatrix import buttonmatrix_spec
23
+ from .obj import obj_spec
24
+
25
+ CONF_TABVIEW = "tabview"
26
+ CONF_TAB_STYLE = "tab_style"
27
+
28
+ lv_tab_t = LvType("lv_obj_t")
29
+
30
+ TABVIEW_SCHEMA = cv.Schema(
31
+ {
32
+ cv.Required(CONF_TABS): cv.ensure_list(
33
+ container_schema(
34
+ obj_spec,
35
+ {
36
+ cv.Required(CONF_NAME): cv.string,
37
+ cv.GenerateID(): cv.declare_id(lv_tab_t),
38
+ },
39
+ )
40
+ ),
41
+ cv.Optional(CONF_TAB_STYLE): part_schema(buttonmatrix_spec),
42
+ cv.Optional(CONF_POSITION, default="top"): DIRECTIONS.one_of,
43
+ cv.Optional(CONF_SIZE, default="10%"): size,
44
+ }
45
+ )
46
+
47
+
48
+ class TabviewType(WidgetType):
49
+ def __init__(self):
50
+ super().__init__(
51
+ CONF_TABVIEW,
52
+ LvType(
53
+ "lv_tabview_t",
54
+ largs=[(lv_obj_t_ptr, "tab")],
55
+ lvalue=lambda w: lv_expr.obj_get_child(
56
+ lv_expr.tabview_get_content(w.obj),
57
+ lv_expr.tabview_get_tab_act(w.obj),
58
+ ),
59
+ has_on_value=True,
60
+ ),
61
+ parts=(CONF_MAIN,),
62
+ schema=TABVIEW_SCHEMA,
63
+ modify_schema={},
64
+ )
65
+
66
+ def get_uses(self):
67
+ return "btnmatrix", TYPE_FLEX
68
+
69
+ async def to_code(self, w: Widget, config: dict):
70
+ for tab_conf in config[CONF_TABS]:
71
+ w_id = tab_conf[CONF_ID]
72
+ tab_obj = cg.Pvariable(w_id, cg.nullptr, type_=lv_tab_t)
73
+ tab_widget = Widget.create(w_id, tab_obj, obj_spec)
74
+ lv_assign(tab_obj, lv_expr.tabview_add_tab(w.obj, tab_conf[CONF_NAME]))
75
+ await set_obj_properties(tab_widget, tab_conf)
76
+ await add_widgets(tab_widget, tab_conf)
77
+ if button_style := config.get(CONF_TAB_STYLE):
78
+ with LocalVariable(
79
+ "tabview_btnmatrix", lv_obj_t, rhs=lv_expr.tabview_get_tab_btns(w.obj)
80
+ ) as btnmatrix_obj:
81
+ await set_obj_properties(Widget(btnmatrix_obj, obj_spec), button_style)
82
+
83
+ def obj_creator(self, parent: MockObjClass, config: dict):
84
+ return lv_expr.call(
85
+ "tabview_create",
86
+ parent,
87
+ literal(config[CONF_POSITION]),
88
+ literal(config[CONF_SIZE]),
89
+ )
90
+
91
+
92
+ tabview_spec = TabviewType()
93
+
94
+
95
+ @automation.register_action(
96
+ "lvgl.tabview.select",
97
+ ObjUpdateAction,
98
+ cv.Schema(
99
+ {
100
+ cv.Required(CONF_ID): cv.use_id(tabview_spec.w_type),
101
+ cv.Optional(CONF_ANIMATED, default=False): animated,
102
+ cv.Required(CONF_INDEX): lv_int,
103
+ },
104
+ ).add_extra(cv.has_at_least_one_key(CONF_INDEX, CONF_TAB_ID)),
105
+ )
106
+ async def tabview_select(config, action_id, template_arg, args):
107
+ widget = await get_widgets(config)
108
+ index = config[CONF_INDEX]
109
+
110
+ async def do_select(w: Widget):
111
+ lv.tabview_set_act(w.obj, index, literal(config[CONF_ANIMATED]))
112
+ lv.event_send(w.obj, LV_EVENT.VALUE_CHANGED, cg.nullptr)
113
+
114
+ return await action_to_code(widget, do_select, action_id, template_arg, args)
@@ -0,0 +1,66 @@
1
+ import esphome.config_validation as cv
2
+ from esphome.const import CONF_MAX_LENGTH, CONF_TEXT
3
+
4
+ from ..defines import (
5
+ CONF_ACCEPTED_CHARS,
6
+ CONF_CURSOR,
7
+ CONF_MAIN,
8
+ CONF_ONE_LINE,
9
+ CONF_PASSWORD_MODE,
10
+ CONF_PLACEHOLDER_TEXT,
11
+ CONF_SCROLLBAR,
12
+ CONF_SELECTED,
13
+ CONF_TEXTAREA_PLACEHOLDER,
14
+ )
15
+ from ..lv_validation import lv_bool, lv_int, lv_text
16
+ from ..schemas import TEXT_SCHEMA
17
+ from ..types import LvText
18
+ from . import Widget, WidgetType
19
+
20
+ CONF_TEXTAREA = "textarea"
21
+
22
+ lv_textarea_t = LvText("lv_textarea_t")
23
+
24
+ TEXTAREA_SCHEMA = TEXT_SCHEMA.extend(
25
+ {
26
+ cv.Optional(CONF_PLACEHOLDER_TEXT): lv_text,
27
+ cv.Optional(CONF_ACCEPTED_CHARS): lv_text,
28
+ cv.Optional(CONF_ONE_LINE): lv_bool,
29
+ cv.Optional(CONF_PASSWORD_MODE): lv_bool,
30
+ cv.Optional(CONF_MAX_LENGTH): lv_int,
31
+ }
32
+ )
33
+
34
+
35
+ class TextareaType(WidgetType):
36
+ def __init__(self):
37
+ super().__init__(
38
+ CONF_TEXTAREA,
39
+ lv_textarea_t,
40
+ (
41
+ CONF_MAIN,
42
+ CONF_SCROLLBAR,
43
+ CONF_SELECTED,
44
+ CONF_CURSOR,
45
+ CONF_TEXTAREA_PLACEHOLDER,
46
+ ),
47
+ TEXTAREA_SCHEMA,
48
+ )
49
+
50
+ async def to_code(self, w: Widget, config: dict):
51
+ for prop in (CONF_TEXT, CONF_PLACEHOLDER_TEXT, CONF_ACCEPTED_CHARS):
52
+ if (value := config.get(prop)) is not None:
53
+ await w.set_property(prop, await lv_text.process(value))
54
+ await w.set_property(
55
+ CONF_MAX_LENGTH, await lv_int.process(config.get(CONF_MAX_LENGTH))
56
+ )
57
+ await w.set_property(
58
+ CONF_PASSWORD_MODE,
59
+ await lv_bool.process(config.get(CONF_PASSWORD_MODE)),
60
+ )
61
+ await w.set_property(
62
+ CONF_ONE_LINE, await lv_bool.process(config.get(CONF_ONE_LINE))
63
+ )
64
+
65
+
66
+ textarea_spec = TextareaType()
@@ -0,0 +1,128 @@
1
+ from esphome import automation
2
+ import esphome.codegen as cg
3
+ import esphome.config_validation as cv
4
+ from esphome.const import CONF_ID, CONF_ON_VALUE, CONF_ROW, CONF_TRIGGER_ID
5
+
6
+ from ..automation import action_to_code
7
+ from ..defines import (
8
+ CONF_ANIMATED,
9
+ CONF_COLUMN,
10
+ CONF_DIR,
11
+ CONF_MAIN,
12
+ CONF_TILE_ID,
13
+ CONF_TILES,
14
+ TILE_DIRECTIONS,
15
+ literal,
16
+ )
17
+ from ..lv_validation import animated, lv_int
18
+ from ..lvcode import lv, lv_assign, lv_expr, lv_obj, lv_Pvariable
19
+ from ..schemas import container_schema
20
+ from ..types import LV_EVENT, LvType, ObjUpdateAction, lv_obj_t, lv_obj_t_ptr
21
+ from . import Widget, WidgetType, add_widgets, get_widgets, set_obj_properties
22
+ from .obj import obj_spec
23
+
24
+ CONF_TILEVIEW = "tileview"
25
+
26
+ lv_tile_t = LvType("lv_tileview_tile_t")
27
+
28
+ lv_tileview_t = LvType(
29
+ "lv_tileview_t",
30
+ largs=[(lv_obj_t_ptr, "tile")],
31
+ lvalue=lambda w: w.get_property("tile_act"),
32
+ )
33
+
34
+ tile_spec = WidgetType("lv_tileview_tile_t", lv_tile_t, (CONF_MAIN,), {})
35
+
36
+ TILEVIEW_SCHEMA = cv.Schema(
37
+ {
38
+ cv.Required(CONF_TILES): cv.ensure_list(
39
+ container_schema(
40
+ obj_spec,
41
+ {
42
+ cv.Required(CONF_ROW): lv_int,
43
+ cv.Required(CONF_COLUMN): lv_int,
44
+ cv.GenerateID(): cv.declare_id(lv_tile_t),
45
+ cv.Optional(CONF_DIR, default="ALL"): TILE_DIRECTIONS.several_of,
46
+ },
47
+ )
48
+ ),
49
+ cv.Optional(CONF_ON_VALUE): automation.validate_automation(
50
+ {
51
+ cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(
52
+ automation.Trigger.template(lv_obj_t_ptr)
53
+ )
54
+ }
55
+ ),
56
+ }
57
+ )
58
+
59
+
60
+ class TileviewType(WidgetType):
61
+ def __init__(self):
62
+ super().__init__(
63
+ CONF_TILEVIEW,
64
+ lv_tileview_t,
65
+ (CONF_MAIN,),
66
+ schema=TILEVIEW_SCHEMA,
67
+ modify_schema={},
68
+ )
69
+
70
+ async def to_code(self, w: Widget, config: dict):
71
+ for tile_conf in config.get(CONF_TILES, ()):
72
+ w_id = tile_conf[CONF_ID]
73
+ tile_obj = lv_Pvariable(lv_obj_t, w_id)
74
+ tile = Widget.create(w_id, tile_obj, tile_spec, tile_conf)
75
+ dirs = tile_conf[CONF_DIR]
76
+ if isinstance(dirs, list):
77
+ dirs = "|".join(dirs)
78
+ lv_assign(
79
+ tile_obj,
80
+ lv_expr.tileview_add_tile(
81
+ w.obj, tile_conf[CONF_COLUMN], tile_conf[CONF_ROW], literal(dirs)
82
+ ),
83
+ )
84
+ await set_obj_properties(tile, tile_conf)
85
+ await add_widgets(tile, tile_conf)
86
+
87
+
88
+ tileview_spec = TileviewType()
89
+
90
+
91
+ def tile_select_validate(config):
92
+ row = CONF_ROW in config
93
+ column = CONF_COLUMN in config
94
+ tile = CONF_TILE_ID in config
95
+ if tile and (row or column) or not tile and not (row and column):
96
+ raise cv.Invalid("Specify either a tile id, or both a row and a column")
97
+ return config
98
+
99
+
100
+ @automation.register_action(
101
+ "lvgl.tileview.select",
102
+ ObjUpdateAction,
103
+ cv.Schema(
104
+ {
105
+ cv.Required(CONF_ID): cv.use_id(lv_tileview_t),
106
+ cv.Optional(CONF_ANIMATED, default=False): animated,
107
+ cv.Optional(CONF_ROW): lv_int,
108
+ cv.Optional(CONF_COLUMN): lv_int,
109
+ cv.Optional(CONF_TILE_ID): cv.use_id(lv_tile_t),
110
+ },
111
+ ).add_extra(tile_select_validate),
112
+ )
113
+ async def tileview_select(config, action_id, template_arg, args):
114
+ widgets = await get_widgets(config)
115
+
116
+ async def do_select(w: Widget):
117
+ if tile := config.get(CONF_TILE_ID):
118
+ tile = await cg.get_variable(tile)
119
+ lv_obj.set_tile(w.obj, tile, literal(config[CONF_ANIMATED]))
120
+ else:
121
+ row = await lv_int.process(config[CONF_ROW])
122
+ column = await lv_int.process(config[CONF_COLUMN])
123
+ lv_obj.set_tile_id(
124
+ widgets[0].obj, column, row, literal(config[CONF_ANIMATED])
125
+ )
126
+ lv.event_send(w.obj, LV_EVENT.VALUE_CHANGED, cg.nullptr)
127
+
128
+ return await action_to_code(widgets, do_select, action_id, template_arg, args)
@@ -0,0 +1,33 @@
1
+ import esphome.codegen as cg
2
+ import esphome.config_validation as cv
3
+ from esphome.components import i2c
4
+ from esphome.const import CONF_ID
5
+
6
+
7
+ DEPENDENCIES = ["i2c"]
8
+ CODEOWNERS = ["@rnauber"]
9
+ MULTI_CONF = True
10
+
11
+ CONF_M5STACK_8ANGLE_ID = "m5stack_8angle_id"
12
+
13
+ m5stack_8angle_ns = cg.esphome_ns.namespace("m5stack_8angle")
14
+ M5Stack8AngleComponent = m5stack_8angle_ns.class_(
15
+ "M5Stack8AngleComponent",
16
+ i2c.I2CDevice,
17
+ cg.Component,
18
+ )
19
+
20
+ AnalogBits = m5stack_8angle_ns.enum("AnalogBits")
21
+
22
+
23
+ CONFIG_SCHEMA = cv.Schema(
24
+ {
25
+ cv.GenerateID(): cv.declare_id(M5Stack8AngleComponent),
26
+ }
27
+ ).extend(i2c.i2c_device_schema(0x43))
28
+
29
+
30
+ async def to_code(config):
31
+ var = cg.new_Pvariable(config[CONF_ID])
32
+ await cg.register_component(var, config)
33
+ await i2c.register_i2c_device(var, config)
@@ -0,0 +1,30 @@
1
+ import esphome.codegen as cg
2
+ import esphome.config_validation as cv
3
+ from esphome.components import binary_sensor
4
+
5
+ from .. import M5Stack8AngleComponent, m5stack_8angle_ns, CONF_M5STACK_8ANGLE_ID
6
+
7
+
8
+ M5Stack8AngleSwitchBinarySensor = m5stack_8angle_ns.class_(
9
+ "M5Stack8AngleSwitchBinarySensor",
10
+ binary_sensor.BinarySensor,
11
+ cg.PollingComponent,
12
+ )
13
+
14
+
15
+ CONFIG_SCHEMA = cv.All(
16
+ cv.Schema(
17
+ {
18
+ cv.GenerateID(CONF_M5STACK_8ANGLE_ID): cv.use_id(M5Stack8AngleComponent),
19
+ }
20
+ )
21
+ .extend(binary_sensor.binary_sensor_schema(M5Stack8AngleSwitchBinarySensor))
22
+ .extend(cv.polling_component_schema("10s"))
23
+ )
24
+
25
+
26
+ async def to_code(config):
27
+ hub = await cg.get_variable(config[CONF_M5STACK_8ANGLE_ID])
28
+ sens = await binary_sensor.new_binary_sensor(config)
29
+ cg.add(sens.set_parent(hub))
30
+ await cg.register_component(sens, config)
@@ -0,0 +1,17 @@
1
+ #include "m5stack_8angle_binary_sensor.h"
2
+
3
+ namespace esphome {
4
+ namespace m5stack_8angle {
5
+
6
+ void M5Stack8AngleSwitchBinarySensor::update() {
7
+ int8_t out = this->parent_->read_switch();
8
+ if (out == -1) {
9
+ this->status_set_warning("Could not read binary sensor state from M5Stack 8Angle.");
10
+ return;
11
+ }
12
+ this->publish_state(out != 0);
13
+ this->status_clear_warning();
14
+ }
15
+
16
+ } // namespace m5stack_8angle
17
+ } // namespace esphome