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.
- esphome/__main__.py +15 -81
- esphome/automation.py +1 -1
- esphome/codegen.py +53 -53
- esphome/components/ade7953/sensor.py +1 -1
- esphome/components/ade7953_spi/ade7953_spi.cpp +1 -1
- esphome/components/airthings_wave_plus/airthings_wave_plus.cpp +5 -2
- esphome/components/airthings_wave_plus/airthings_wave_plus.h +2 -0
- esphome/components/airthings_wave_plus/sensor.py +12 -0
- esphome/components/alarm_control_panel/__init__.py +75 -66
- esphome/components/apds9306/__init__.py +4 -0
- esphome/components/apds9306/apds9306.cpp +151 -0
- esphome/components/apds9306/apds9306.h +66 -0
- esphome/components/apds9306/sensor.py +95 -0
- esphome/components/api/__init__.py +80 -52
- esphome/components/api/api_connection.cpp +14 -1
- esphome/components/api/api_pb2.cpp +33 -4
- esphome/components/api/api_pb2.h +8 -1
- esphome/components/api/api_server.cpp +10 -0
- esphome/components/api/api_server.h +3 -0
- esphome/components/atm90e32/__init__.py +7 -0
- esphome/components/atm90e32/atm90e32.cpp +68 -16
- esphome/components/atm90e32/atm90e32.h +20 -7
- esphome/components/atm90e32/atm90e32_reg.h +2 -0
- esphome/components/atm90e32/button/__init__.py +43 -0
- esphome/components/atm90e32/button/atm90e32_button.cpp +20 -0
- esphome/components/atm90e32/button/atm90e32_button.h +27 -0
- esphome/components/atm90e32/sensor.py +15 -11
- esphome/components/bedjet/bedjet_codec.h +1 -1
- esphome/components/binary/light/binary_light_output.h +3 -2
- esphome/components/binary_sensor/__init__.py +5 -5
- esphome/components/ble_client/__init__.py +3 -3
- esphome/components/ble_client/output/__init__.py +1 -1
- esphome/components/ble_client/sensor/__init__.py +4 -3
- esphome/components/ble_client/switch/__init__.py +2 -1
- esphome/components/ble_client/text_sensor/__init__.py +4 -3
- esphome/components/ble_presence/binary_sensor.py +3 -3
- esphome/components/ble_rssi/sensor.py +2 -2
- esphome/components/ble_scanner/text_sensor.py +1 -1
- esphome/components/bluetooth_proxy/__init__.py +3 -3
- esphome/components/bme68x_bsec2/__init__.py +196 -0
- esphome/components/bme68x_bsec2/bme68x_bsec2.cpp +523 -0
- esphome/components/bme68x_bsec2/bme68x_bsec2.h +163 -0
- esphome/components/bme68x_bsec2/sensor.py +130 -0
- esphome/components/bme68x_bsec2/text_sensor.py +33 -0
- esphome/components/bme68x_bsec2_i2c/__init__.py +28 -0
- esphome/components/bme68x_bsec2_i2c/bme68x_bsec2_i2c.cpp +53 -0
- esphome/components/bme68x_bsec2_i2c/bme68x_bsec2_i2c.h +28 -0
- esphome/components/bmp3xx/sensor.py +1 -1
- esphome/components/button/__init__.py +4 -4
- esphome/components/climate/__init__.py +5 -5
- esphome/components/climate/climate.h +1 -1
- esphome/components/cover/__init__.py +8 -8
- esphome/components/cst226/touchscreen/cst226_touchscreen.cpp +11 -7
- esphome/components/cst226/touchscreen/cst226_touchscreen.h +1 -1
- esphome/components/datetime/__init__.py +11 -13
- esphome/components/demo/demo_sensor.h +3 -2
- esphome/components/display/display.cpp +31 -0
- esphome/components/display/display.h +3 -0
- esphome/components/display_menu_base/__init__.py +14 -13
- esphome/components/ens160/sensor.py +1 -1
- esphome/components/esp32/__init__.py +22 -10
- esphome/components/esp32/boards.py +1 -1
- esphome/components/esp32/gpio.py +12 -13
- esphome/components/esp32/gpio_esp32.py +1 -2
- esphome/components/esp32/gpio_esp32_c2.py +1 -2
- esphome/components/esp32/gpio_esp32_c3.py +1 -5
- esphome/components/esp32/gpio_esp32_c6.py +1 -2
- esphome/components/esp32/gpio_esp32_h2.py +1 -2
- esphome/components/esp32/gpio_esp32_s2.py +1 -2
- esphome/components/esp32/gpio_esp32_s3.py +1 -6
- esphome/components/esp32_ble/__init__.py +20 -3
- esphome/components/esp32_ble/ble.cpp +9 -1
- esphome/components/esp32_ble/ble.h +9 -0
- esphome/components/esp32_ble/ble_advertising.cpp +42 -9
- esphome/components/esp32_ble/ble_advertising.h +21 -1
- esphome/components/esp32_ble_beacon/__init__.py +17 -7
- esphome/components/esp32_ble_beacon/esp32_ble_beacon.cpp +45 -113
- esphome/components/esp32_ble_beacon/esp32_ble_beacon.h +17 -19
- esphome/components/esp32_ble_client/__init__.py +0 -1
- esphome/components/esp32_ble_server/__init__.py +2 -3
- esphome/components/esp32_ble_tracker/__init__.py +2 -2
- esphome/components/esp32_improv/__init__.py +2 -4
- esphome/components/ethernet/__init__.py +17 -17
- esphome/components/ethernet_info/text_sensor.py +2 -2
- esphome/components/event/__init__.py +5 -5
- esphome/components/fan/__init__.py +14 -14
- esphome/components/fan/fan.cpp +2 -2
- esphome/components/fingerprint_grow/fingerprint_grow.cpp +1 -1
- esphome/components/fingerprint_grow/fingerprint_grow.h +1 -1
- esphome/components/graphical_display_menu/__init__.py +11 -8
- esphome/components/haier/haier_base.h +2 -2
- esphome/components/homeassistant/__init__.py +8 -1
- esphome/components/homeassistant/number/__init__.py +33 -0
- esphome/components/homeassistant/number/homeassistant_number.cpp +100 -0
- esphome/components/homeassistant/number/homeassistant_number.h +31 -0
- esphome/components/homeassistant/switch/__init__.py +30 -0
- esphome/components/homeassistant/switch/homeassistant_switch.cpp +59 -0
- esphome/components/homeassistant/switch/homeassistant_switch.h +22 -0
- esphome/components/host/__init__.py +3 -7
- esphome/components/http_request/__init__.py +12 -1
- esphome/components/http_request/http_request_arduino.cpp +2 -2
- esphome/components/http_request/http_request_idf.cpp +11 -2
- esphome/components/http_request/http_request_idf.h +10 -0
- esphome/components/http_request/ota/ota_http_request.cpp +1 -1
- esphome/components/http_request/update/http_request_update.cpp +2 -2
- esphome/components/http_request/update/http_request_update.h +2 -1
- esphome/components/hx711/hx711.cpp +10 -1
- esphome/components/hydreon_rgxx/hydreon_rgxx.cpp +1 -1
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +11 -2
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +2 -0
- esphome/components/ili9xxx/ili9xxx_defines.h +3 -1
- esphome/components/ili9xxx/ili9xxx_display.cpp +9 -22
- esphome/components/ili9xxx/ili9xxx_display.h +5 -7
- esphome/components/ili9xxx/ili9xxx_init.h +4 -4
- esphome/components/improv_base/__init__.py +2 -3
- esphome/components/improv_serial/__init__.py +4 -10
- esphome/components/improv_serial/improv_serial_component.cpp +4 -0
- esphome/components/jsn_sr04t/jsn_sr04t.cpp +18 -1
- esphome/components/jsn_sr04t/jsn_sr04t.h +7 -1
- esphome/components/jsn_sr04t/sensor.py +13 -0
- esphome/components/kalman_combinator/sensor.py +1 -1
- esphome/components/light/__init__.py +16 -15
- esphome/components/light/addressable_light_effect.h +12 -8
- esphome/components/light/automation.h +16 -1
- esphome/components/light/automation.py +21 -0
- esphome/components/light/base_light_effects.h +5 -5
- esphome/components/light/esp_color_correction.h +8 -8
- esphome/components/light/types.py +7 -0
- esphome/components/lock/__init__.py +3 -3
- esphome/components/logger/__init__.py +15 -18
- esphome/components/lvgl/__init__.py +346 -0
- esphome/components/lvgl/automation.py +226 -0
- esphome/components/lvgl/binary_sensor/__init__.py +43 -0
- esphome/components/lvgl/defines.py +508 -0
- esphome/components/lvgl/encoders.py +77 -0
- esphome/components/lvgl/font.cpp +76 -0
- esphome/components/lvgl/helpers.py +49 -0
- esphome/components/lvgl/light/__init__.py +32 -0
- esphome/components/lvgl/light/lvgl_light.h +48 -0
- esphome/components/lvgl/lv_validation.py +303 -0
- esphome/components/lvgl/lvcode.py +349 -0
- esphome/components/lvgl/lvgl_esphome.cpp +407 -0
- esphome/components/lvgl/lvgl_esphome.h +274 -0
- esphome/components/lvgl/lvgl_hal.h +21 -0
- esphome/components/lvgl/number/__init__.py +66 -0
- esphome/components/lvgl/number/lvgl_number.h +34 -0
- esphome/components/lvgl/schemas.py +436 -0
- esphome/components/lvgl/select/__init__.py +55 -0
- esphome/components/lvgl/select/lvgl_select.h +62 -0
- esphome/components/lvgl/sensor/__init__.py +47 -0
- esphome/components/lvgl/styles.py +58 -0
- esphome/components/lvgl/switch/__init__.py +56 -0
- esphome/components/lvgl/switch/lvgl_switch.h +34 -0
- esphome/components/lvgl/text/__init__.py +50 -0
- esphome/components/lvgl/text/lvgl_text.h +34 -0
- esphome/components/lvgl/text_sensor/__init__.py +42 -0
- esphome/components/lvgl/touchscreens.py +45 -0
- esphome/components/lvgl/trigger.py +74 -0
- esphome/components/lvgl/types.py +191 -0
- esphome/components/lvgl/widgets/__init__.py +419 -0
- esphome/components/lvgl/widgets/animimg.py +117 -0
- esphome/components/lvgl/widgets/arc.py +78 -0
- esphome/components/lvgl/widgets/button.py +20 -0
- esphome/components/lvgl/widgets/buttonmatrix.py +275 -0
- esphome/components/lvgl/widgets/checkbox.py +27 -0
- esphome/components/lvgl/widgets/dropdown.py +76 -0
- esphome/components/lvgl/widgets/img.py +85 -0
- esphome/components/lvgl/widgets/keyboard.py +49 -0
- esphome/components/lvgl/widgets/label.py +42 -0
- esphome/components/lvgl/widgets/led.py +29 -0
- esphome/components/lvgl/widgets/line.py +50 -0
- esphome/components/lvgl/widgets/lv_bar.py +55 -0
- esphome/components/lvgl/widgets/meter.py +302 -0
- esphome/components/lvgl/widgets/msgbox.py +134 -0
- esphome/components/lvgl/widgets/obj.py +28 -0
- esphome/components/lvgl/widgets/page.py +113 -0
- esphome/components/lvgl/widgets/roller.py +77 -0
- esphome/components/lvgl/widgets/slider.py +63 -0
- esphome/components/lvgl/widgets/spinbox.py +178 -0
- esphome/components/lvgl/widgets/spinner.py +43 -0
- esphome/components/lvgl/widgets/switch.py +20 -0
- esphome/components/lvgl/widgets/tabview.py +114 -0
- esphome/components/lvgl/widgets/textarea.py +66 -0
- esphome/components/lvgl/widgets/tileview.py +128 -0
- esphome/components/m5stack_8angle/__init__.py +33 -0
- esphome/components/m5stack_8angle/binary_sensor/__init__.py +30 -0
- esphome/components/m5stack_8angle/binary_sensor/m5stack_8angle_binary_sensor.cpp +17 -0
- esphome/components/m5stack_8angle/binary_sensor/m5stack_8angle_binary_sensor.h +19 -0
- esphome/components/m5stack_8angle/light/__init__.py +31 -0
- esphome/components/m5stack_8angle/light/m5stack_8angle_light.cpp +45 -0
- esphome/components/m5stack_8angle/light/m5stack_8angle_light.h +37 -0
- esphome/components/m5stack_8angle/m5stack_8angle.cpp +74 -0
- esphome/components/m5stack_8angle/m5stack_8angle.h +34 -0
- esphome/components/m5stack_8angle/sensor/__init__.py +66 -0
- esphome/components/m5stack_8angle/sensor/m5stack_8angle_sensor.cpp +24 -0
- esphome/components/m5stack_8angle/sensor/m5stack_8angle_sensor.h +27 -0
- esphome/components/matrix_keypad/matrix_keypad.cpp +2 -0
- esphome/components/max31856/sensor.py +5 -5
- esphome/components/media_player/__init__.py +3 -5
- esphome/components/media_player/automation.h +31 -27
- esphome/components/micro_wake_word/__init__.py +20 -25
- esphome/components/micro_wake_word/streaming_model.cpp +6 -4
- esphome/components/microphone/microphone.h +4 -1
- esphome/components/mitsubishi/mitsubishi.cpp +7 -1
- esphome/components/modbus_controller/__init__.py +26 -2
- esphome/components/modbus_controller/automation.h +19 -0
- esphome/components/modbus_controller/const.py +1 -0
- esphome/components/modbus_controller/modbus_controller.cpp +8 -0
- esphome/components/modbus_controller/modbus_controller.h +3 -0
- esphome/components/mqtt/__init__.py +20 -9
- esphome/components/mqtt/mqtt_alarm_control_panel.cpp +128 -0
- esphome/components/mqtt/mqtt_alarm_control_panel.h +39 -0
- esphome/components/mqtt/mqtt_backend.h +3 -1
- esphome/components/mqtt/mqtt_backend_esp32.cpp +4 -1
- esphome/components/mqtt/mqtt_backend_esp32.h +3 -1
- esphome/components/mqtt/mqtt_backend_esp8266.h +3 -1
- esphome/components/mqtt/mqtt_backend_libretiny.h +3 -1
- esphome/components/mqtt/mqtt_client.cpp +16 -3
- esphome/components/mqtt/mqtt_client.h +5 -1
- esphome/components/mqtt/mqtt_component.cpp +32 -4
- esphome/components/mqtt/mqtt_const.h +2 -0
- esphome/components/network/__init__.py +15 -12
- esphome/components/network/ip_address.h +3 -0
- esphome/components/network/util.cpp +2 -1
- esphome/components/network/util.h +3 -1
- esphome/components/nextion/base_component.py +5 -8
- esphome/components/number/__init__.py +7 -8
- esphome/components/online_image/__init__.py +167 -0
- esphome/components/online_image/image_decoder.cpp +44 -0
- esphome/components/online_image/image_decoder.h +112 -0
- esphome/components/online_image/online_image.cpp +283 -0
- esphome/components/online_image/online_image.h +195 -0
- esphome/components/online_image/png_image.cpp +68 -0
- esphome/components/online_image/png_image.h +33 -0
- esphome/components/ota/__init__.py +8 -4
- esphome/components/pid/pid_climate.h +2 -0
- esphome/components/pmwcs3/pmwcs3.cpp +31 -30
- esphome/components/remote_base/pronto_protocol.cpp +0 -3
- esphome/components/remote_transmitter/remote_transmitter.h +1 -1
- esphome/components/rgbct/rgbct_light_output.h +3 -2
- esphome/components/rgbw/rgbw_light_output.h +3 -2
- esphome/components/rgbww/rgbww_light_output.h +3 -2
- esphome/components/rp2040_pio_led_strip/led_strip.cpp +31 -5
- esphome/components/rp2040_pio_led_strip/led_strip.h +5 -0
- esphome/components/rtttl/rtttl.cpp +108 -21
- esphome/components/rtttl/rtttl.h +15 -6
- esphome/components/select/__init__.py +7 -7
- esphome/components/sensor/__init__.py +29 -10
- esphome/components/sensor/filter.cpp +8 -0
- esphome/components/sensor/filter.h +9 -0
- esphome/components/sml/sml_parser.cpp +48 -22
- esphome/components/socket/socket.cpp +11 -14
- esphome/components/speaker/__init__.py +14 -5
- esphome/components/speaker/automation.h +10 -0
- esphome/components/speaker/speaker.h +9 -0
- esphome/components/spi/spi.cpp +0 -6
- esphome/components/spi/spi.h +2 -19
- esphome/components/spi_led_strip/spi_led_strip.h +5 -4
- esphome/components/sprinkler/sprinkler.cpp +2 -2
- esphome/components/sprinkler/sprinkler.h +1 -1
- esphome/components/switch/__init__.py +3 -3
- esphome/components/text/__init__.py +5 -5
- esphome/components/text_sensor/__init__.py +7 -7
- esphome/components/time/__init__.py +8 -8
- esphome/components/touchscreen/binary_sensor/__init__.py +24 -10
- esphome/components/touchscreen/binary_sensor/touchscreen_binary_sensor.cpp +3 -2
- esphome/components/touchscreen/binary_sensor/touchscreen_binary_sensor.h +4 -2
- esphome/components/uart/uart_component_host.cpp +6 -2
- esphome/components/update/__init__.py +33 -15
- esphome/components/update/automation.h +23 -0
- esphome/components/update/update_entity.h +3 -1
- esphome/components/valve/__init__.py +3 -3
- esphome/components/voice_assistant/__init__.py +7 -8
- esphome/components/wake_on_lan/wake_on_lan.cpp +2 -0
- esphome/components/wake_on_lan/wake_on_lan.h +3 -1
- esphome/components/watchdog/__init__.py +1 -0
- esphome/components/{http_request → watchdog}/watchdog.cpp +0 -2
- esphome/components/{http_request → watchdog}/watchdog.h +0 -2
- esphome/components/waveshare_epaper/waveshare_epaper.cpp +5 -5
- esphome/components/web_server/server_index_v3.h +3615 -3603
- esphome/components/web_server/web_server.cpp +0 -209
- esphome/components/web_server/web_server.h +1 -1
- esphome/components/web_server/web_server_v1.cpp +217 -0
- esphome/components/web_server_base/web_server_base.h +1 -0
- esphome/components/wifi/__init__.py +15 -14
- esphome/components/wifi/wifi_component.cpp +2 -0
- esphome/components/wifi/wifi_component.h +7 -1
- esphome/components/wifi/wifi_component_esp32_arduino.cpp +5 -2
- esphome/components/wifi/wifi_component_esp8266.cpp +2 -0
- esphome/components/wifi/wifi_component_esp_idf.cpp +43 -7
- esphome/components/wifi/wifi_component_libretiny.cpp +2 -0
- esphome/components/wifi/wifi_component_pico_w.cpp +2 -0
- esphome/components/wifi/wpa2_eap.py +6 -7
- esphome/components/wifi_info/text_sensor.py +3 -3
- esphome/components/wifi_info/wifi_info_text_sensor.cpp +2 -0
- esphome/components/wifi_info/wifi_info_text_sensor.h +2 -0
- esphome/components/wifi_signal/sensor.py +1 -1
- esphome/components/wifi_signal/wifi_signal_sensor.cpp +2 -0
- esphome/components/wifi_signal/wifi_signal_sensor.h +2 -1
- esphome/components/xiaomi_ble/xiaomi_ble.cpp +20 -3
- esphome/components/xiaomi_ble/xiaomi_ble.h +1 -0
- esphome/components/xiaomi_lywsd02mmc/__init__.py +0 -0
- esphome/components/xiaomi_lywsd02mmc/sensor.py +77 -0
- esphome/components/xiaomi_lywsd02mmc/xiaomi_lywsd02mmc.cpp +73 -0
- esphome/components/xiaomi_lywsd02mmc/xiaomi_lywsd02mmc.h +37 -0
- esphome/config.py +17 -19
- esphome/config_validation.py +55 -23
- esphome/const.py +25 -9
- esphome/core/__init__.py +17 -14
- esphome/core/application.h +42 -21
- esphome/core/automation.h +5 -3
- esphome/core/base_automation.h +3 -2
- esphome/core/bytebuffer.cpp +134 -0
- esphome/core/bytebuffer.h +96 -0
- esphome/core/color.h +24 -16
- esphome/core/config.py +3 -3
- esphome/core/defines.h +14 -1
- esphome/core/entity_base.h +2 -2
- esphome/core/entity_helpers.py +1 -2
- esphome/core/gpio.h +0 -18
- esphome/core/helpers.h +1 -1
- esphome/core/optional.h +15 -16
- esphome/coroutine.py +1 -1
- esphome/cpp_generator.py +1 -1
- esphome/cpp_helpers.py +3 -5
- esphome/dashboard/core.py +3 -3
- esphome/dashboard/dashboard.py +3 -3
- esphome/dashboard/entries.py +1 -1
- esphome/dashboard/util/file.py +1 -1
- esphome/dashboard/web_server.py +3 -3
- esphome/external_files.py +5 -3
- esphome/final_validate.py +2 -2
- esphome/git.py +4 -4
- esphome/helpers.py +5 -5
- esphome/loader.py +15 -10
- esphome/mqtt.py +4 -8
- esphome/pins.py +6 -6
- esphome/platformio_api.py +5 -5
- esphome/storage_json.py +2 -1
- esphome/types.py +1 -1
- esphome/util.py +2 -3
- esphome/voluptuous_schema.py +1 -0
- esphome/vscode.py +5 -4
- esphome/wizard.py +1 -1
- esphome/writer.py +7 -7
- esphome/yaml_util.py +3 -3
- esphome/zeroconf.py +1 -1
- {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/METADATA +3 -3
- {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/RECORD +353 -247
- {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/LICENSE +0 -0
- {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/WHEEL +0 -0
- {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/entry_points.txt +0 -0
- {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
import esphome.codegen as cg
|
2
|
+
from esphome.components import light
|
3
|
+
from esphome.components.light import LightOutput
|
4
|
+
import esphome.config_validation as cv
|
5
|
+
from esphome.const import CONF_GAMMA_CORRECT, CONF_LED, CONF_OUTPUT_ID
|
6
|
+
|
7
|
+
from ..defines import CONF_LVGL_ID
|
8
|
+
from ..lvcode import LvContext
|
9
|
+
from ..schemas import LVGL_SCHEMA
|
10
|
+
from ..types import LvType, lvgl_ns
|
11
|
+
from ..widgets import get_widgets
|
12
|
+
|
13
|
+
lv_led_t = LvType("lv_led_t")
|
14
|
+
LVLight = lvgl_ns.class_("LVLight", LightOutput)
|
15
|
+
CONFIG_SCHEMA = light.RGB_LIGHT_SCHEMA.extend(
|
16
|
+
{
|
17
|
+
cv.Optional(CONF_GAMMA_CORRECT, default=0.0): cv.positive_float,
|
18
|
+
cv.Required(CONF_LED): cv.use_id(lv_led_t),
|
19
|
+
cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(LVLight),
|
20
|
+
}
|
21
|
+
).extend(LVGL_SCHEMA)
|
22
|
+
|
23
|
+
|
24
|
+
async def to_code(config):
|
25
|
+
var = cg.new_Pvariable(config[CONF_OUTPUT_ID])
|
26
|
+
await light.register_light(var, config)
|
27
|
+
|
28
|
+
paren = await cg.get_variable(config[CONF_LVGL_ID])
|
29
|
+
widget = await get_widgets(config, CONF_LED)
|
30
|
+
widget = widget[0]
|
31
|
+
async with LvContext(paren) as ctx:
|
32
|
+
ctx.add(var.set_obj(widget.obj))
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "esphome/core/component.h"
|
4
|
+
#include "esphome/components/light/light_output.h"
|
5
|
+
#include "../lvgl_esphome.h"
|
6
|
+
|
7
|
+
namespace esphome {
|
8
|
+
namespace lvgl {
|
9
|
+
|
10
|
+
class LVLight : public light::LightOutput {
|
11
|
+
public:
|
12
|
+
light::LightTraits get_traits() override {
|
13
|
+
auto traits = light::LightTraits();
|
14
|
+
traits.set_supported_color_modes({light::ColorMode::RGB});
|
15
|
+
return traits;
|
16
|
+
}
|
17
|
+
void write_state(light::LightState *state) override {
|
18
|
+
float red, green, blue;
|
19
|
+
state->current_values_as_rgb(&red, &green, &blue, false);
|
20
|
+
auto color = lv_color_make(red * 255, green * 255, blue * 255);
|
21
|
+
if (this->obj_ != nullptr) {
|
22
|
+
this->set_value_(color);
|
23
|
+
} else {
|
24
|
+
this->initial_value_ = color;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
void set_obj(lv_obj_t *obj) {
|
29
|
+
this->obj_ = obj;
|
30
|
+
if (this->initial_value_) {
|
31
|
+
lv_led_set_color(obj, this->initial_value_.value());
|
32
|
+
lv_led_on(obj);
|
33
|
+
this->initial_value_.reset();
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
protected:
|
38
|
+
void set_value_(lv_color_t value) {
|
39
|
+
lv_led_set_color(this->obj_, value);
|
40
|
+
lv_led_on(this->obj_);
|
41
|
+
lv_event_send(this->obj_, lv_api_event, nullptr);
|
42
|
+
}
|
43
|
+
lv_obj_t *obj_{};
|
44
|
+
optional<lv_color_t> initial_value_{};
|
45
|
+
};
|
46
|
+
|
47
|
+
} // namespace lvgl
|
48
|
+
} // namespace esphome
|
@@ -0,0 +1,303 @@
|
|
1
|
+
from typing import Union
|
2
|
+
|
3
|
+
import esphome.codegen as cg
|
4
|
+
from esphome.components.color import ColorStruct
|
5
|
+
from esphome.components.font import Font
|
6
|
+
from esphome.components.image import Image_
|
7
|
+
import esphome.config_validation as cv
|
8
|
+
from esphome.const import CONF_ARGS, CONF_COLOR, CONF_FORMAT, CONF_TIME, CONF_VALUE
|
9
|
+
from esphome.core import HexInt, Lambda
|
10
|
+
from esphome.cpp_generator import MockObj
|
11
|
+
from esphome.cpp_types import ESPTime, uint32
|
12
|
+
from esphome.helpers import cpp_string_escape
|
13
|
+
from esphome.schema_extractors import SCHEMA_EXTRACT, schema_extractor
|
14
|
+
|
15
|
+
from . import types as ty
|
16
|
+
from .defines import (
|
17
|
+
CONF_END_VALUE,
|
18
|
+
CONF_START_VALUE,
|
19
|
+
CONF_TIME_FORMAT,
|
20
|
+
LV_FONTS,
|
21
|
+
LValidator,
|
22
|
+
LvConstant,
|
23
|
+
call_lambda,
|
24
|
+
literal,
|
25
|
+
)
|
26
|
+
from .helpers import (
|
27
|
+
esphome_fonts_used,
|
28
|
+
lv_fonts_used,
|
29
|
+
lvgl_components_required,
|
30
|
+
requires_component,
|
31
|
+
)
|
32
|
+
from .lvcode import lv_expr
|
33
|
+
from .types import lv_font_t, lv_img_t
|
34
|
+
|
35
|
+
opacity_consts = LvConstant("LV_OPA_", "TRANSP", "COVER")
|
36
|
+
|
37
|
+
|
38
|
+
@schema_extractor("one_of")
|
39
|
+
def opacity_validator(value):
|
40
|
+
if value == SCHEMA_EXTRACT:
|
41
|
+
return opacity_consts.choices
|
42
|
+
value = cv.Any(cv.percentage, opacity_consts.one_of)(value)
|
43
|
+
if isinstance(value, float):
|
44
|
+
return int(value * 255)
|
45
|
+
return value
|
46
|
+
|
47
|
+
|
48
|
+
opacity = LValidator(opacity_validator, uint32, retmapper=literal)
|
49
|
+
|
50
|
+
|
51
|
+
@schema_extractor("one_of")
|
52
|
+
def color(value):
|
53
|
+
if value == SCHEMA_EXTRACT:
|
54
|
+
return ["hex color value", "color ID"]
|
55
|
+
if isinstance(value, int):
|
56
|
+
return value
|
57
|
+
return cv.use_id(ColorStruct)(value)
|
58
|
+
|
59
|
+
|
60
|
+
def color_retmapper(value):
|
61
|
+
if isinstance(value, cv.Lambda):
|
62
|
+
return cv.returning_lambda(value)
|
63
|
+
if isinstance(value, int):
|
64
|
+
hexval = HexInt(value)
|
65
|
+
return lv_expr.color_hex(hexval)
|
66
|
+
# Must be an id
|
67
|
+
lvgl_components_required.add(CONF_COLOR)
|
68
|
+
return lv_expr.color_from(MockObj(value))
|
69
|
+
|
70
|
+
|
71
|
+
def option_string(value):
|
72
|
+
value = cv.string(value).strip()
|
73
|
+
if value.find("\n") != -1:
|
74
|
+
raise cv.Invalid("Options strings must not contain newlines")
|
75
|
+
return value
|
76
|
+
|
77
|
+
|
78
|
+
lv_color = LValidator(color, ty.lv_color_t, retmapper=color_retmapper)
|
79
|
+
|
80
|
+
|
81
|
+
def pixels_or_percent_validator(value):
|
82
|
+
"""A length in one axis - either a number (pixels) or a percentage"""
|
83
|
+
if value == SCHEMA_EXTRACT:
|
84
|
+
return ["pixels", "..%"]
|
85
|
+
if isinstance(value, int):
|
86
|
+
return cv.int_(value)
|
87
|
+
# Will throw an exception if not a percentage.
|
88
|
+
return f"lv_pct({int(cv.percentage(value) * 100)})"
|
89
|
+
|
90
|
+
|
91
|
+
pixels_or_percent = LValidator(pixels_or_percent_validator, uint32, retmapper=literal)
|
92
|
+
|
93
|
+
|
94
|
+
def zoom(value):
|
95
|
+
value = cv.float_range(0.1, 10.0)(value)
|
96
|
+
return int(value * 256)
|
97
|
+
|
98
|
+
|
99
|
+
def angle(value):
|
100
|
+
"""
|
101
|
+
Validation for an angle in degrees, converted to an integer representing 0.1deg units
|
102
|
+
:param value: The input in the range 0..360
|
103
|
+
:return: An angle in 1/10 degree units.
|
104
|
+
"""
|
105
|
+
return int(cv.float_range(0.0, 360.0)(cv.angle(value)) * 10)
|
106
|
+
|
107
|
+
|
108
|
+
@schema_extractor("one_of")
|
109
|
+
def size_validator(value):
|
110
|
+
"""A size in one axis - one of "size_content", a number (pixels) or a percentage"""
|
111
|
+
if value == SCHEMA_EXTRACT:
|
112
|
+
return ["SIZE_CONTENT", "number of pixels", "percentage"]
|
113
|
+
if isinstance(value, str) and value.lower().endswith("px"):
|
114
|
+
value = cv.int_(value[:-2])
|
115
|
+
if isinstance(value, str) and not value.endswith("%"):
|
116
|
+
if value.upper() == "SIZE_CONTENT":
|
117
|
+
return "LV_SIZE_CONTENT"
|
118
|
+
raise cv.Invalid("must be 'size_content', a percentage or an integer (pixels)")
|
119
|
+
if isinstance(value, int):
|
120
|
+
return cv.int_(value)
|
121
|
+
# Will throw an exception if not a percentage.
|
122
|
+
return f"lv_pct({int(cv.percentage(value) * 100)})"
|
123
|
+
|
124
|
+
|
125
|
+
size = LValidator(size_validator, uint32, retmapper=literal)
|
126
|
+
|
127
|
+
|
128
|
+
def pixels_validator(value):
|
129
|
+
if isinstance(value, str) and value.lower().endswith("px"):
|
130
|
+
return cv.int_(value[:-2])
|
131
|
+
return cv.int_(value)
|
132
|
+
|
133
|
+
|
134
|
+
pixels = LValidator(pixels_validator, uint32, retmapper=literal)
|
135
|
+
|
136
|
+
radius_consts = LvConstant("LV_RADIUS_", "CIRCLE")
|
137
|
+
|
138
|
+
|
139
|
+
@schema_extractor("one_of")
|
140
|
+
def radius_validator(value):
|
141
|
+
if value == SCHEMA_EXTRACT:
|
142
|
+
return radius_consts.choices
|
143
|
+
value = cv.Any(size, cv.percentage, radius_consts.one_of)(value)
|
144
|
+
if isinstance(value, float):
|
145
|
+
return int(value * 255)
|
146
|
+
return value
|
147
|
+
|
148
|
+
|
149
|
+
radius = LValidator(radius_validator, uint32, retmapper=literal)
|
150
|
+
|
151
|
+
|
152
|
+
def id_name(value):
|
153
|
+
if value == SCHEMA_EXTRACT:
|
154
|
+
return "id"
|
155
|
+
return cv.validate_id_name(value)
|
156
|
+
|
157
|
+
|
158
|
+
def stop_value(value):
|
159
|
+
return cv.int_range(0, 255)(value)
|
160
|
+
|
161
|
+
|
162
|
+
lv_images_used = set()
|
163
|
+
|
164
|
+
|
165
|
+
def image_validator(value):
|
166
|
+
value = requires_component("image")(value)
|
167
|
+
value = cv.use_id(Image_)(value)
|
168
|
+
lv_images_used.add(value)
|
169
|
+
return value
|
170
|
+
|
171
|
+
|
172
|
+
lv_image = LValidator(
|
173
|
+
image_validator,
|
174
|
+
lv_img_t,
|
175
|
+
retmapper=lambda x: lv_expr.img_from(MockObj(x)),
|
176
|
+
requires="image",
|
177
|
+
)
|
178
|
+
lv_bool = LValidator(cv.boolean, cg.bool_, retmapper=literal)
|
179
|
+
|
180
|
+
|
181
|
+
def lv_pct(value: Union[int, float]):
|
182
|
+
if isinstance(value, float):
|
183
|
+
value = int(value * 100)
|
184
|
+
return literal(f"lv_pct({value})")
|
185
|
+
|
186
|
+
|
187
|
+
def lvms_validator_(value):
|
188
|
+
if value == "never":
|
189
|
+
value = "2147483647ms"
|
190
|
+
return cv.positive_time_period_milliseconds(value)
|
191
|
+
|
192
|
+
|
193
|
+
lv_milliseconds = LValidator(
|
194
|
+
lvms_validator_, cg.int32, retmapper=lambda x: x.total_milliseconds
|
195
|
+
)
|
196
|
+
|
197
|
+
|
198
|
+
class TextValidator(LValidator):
|
199
|
+
def __init__(self):
|
200
|
+
super().__init__(cv.string, cg.std_string, lambda s: cg.safe_exp(f"{s}"))
|
201
|
+
|
202
|
+
def __call__(self, value):
|
203
|
+
if isinstance(value, dict) and CONF_FORMAT in value:
|
204
|
+
return value
|
205
|
+
return super().__call__(value)
|
206
|
+
|
207
|
+
async def process(self, value, args=()):
|
208
|
+
if isinstance(value, dict):
|
209
|
+
if format_str := value.get(CONF_FORMAT):
|
210
|
+
args = [str(x) for x in value[CONF_ARGS]]
|
211
|
+
arg_expr = cg.RawExpression(",".join(args))
|
212
|
+
format_str = cpp_string_escape(format_str)
|
213
|
+
return literal(f"str_sprintf({format_str}, {arg_expr}).c_str()")
|
214
|
+
if time_format := value.get(CONF_TIME_FORMAT):
|
215
|
+
source = value[CONF_TIME]
|
216
|
+
if isinstance(source, Lambda):
|
217
|
+
time_format = cpp_string_escape(time_format)
|
218
|
+
return cg.RawExpression(
|
219
|
+
call_lambda(
|
220
|
+
await cg.process_lambda(source, args, return_type=ESPTime)
|
221
|
+
)
|
222
|
+
+ f".strftime({time_format}).c_str()"
|
223
|
+
)
|
224
|
+
# must be an ID
|
225
|
+
source = await cg.get_variable(source)
|
226
|
+
return source.now().strftime(time_format).c_str()
|
227
|
+
if isinstance(value, Lambda):
|
228
|
+
value = call_lambda(
|
229
|
+
await cg.process_lambda(value, args, return_type=self.rtype)
|
230
|
+
)
|
231
|
+
|
232
|
+
# Was the lambda call reduced to a string?
|
233
|
+
if value.endswith("c_str()") or (
|
234
|
+
value.endswith('"') and value.startswith('"')
|
235
|
+
):
|
236
|
+
pass
|
237
|
+
else:
|
238
|
+
# Either a std::string or a lambda call returning that. We need const char*
|
239
|
+
value = f"({value}).c_str()"
|
240
|
+
return cg.RawExpression(value)
|
241
|
+
return await super().process(value, args)
|
242
|
+
|
243
|
+
|
244
|
+
lv_text = TextValidator()
|
245
|
+
lv_float = LValidator(cv.float_, cg.float_)
|
246
|
+
lv_int = LValidator(cv.int_, cg.int_)
|
247
|
+
lv_brightness = LValidator(cv.percentage, cg.float_, retmapper=lambda x: int(x * 255))
|
248
|
+
|
249
|
+
|
250
|
+
def is_lv_font(font):
|
251
|
+
return isinstance(font, str) and font.lower() in LV_FONTS
|
252
|
+
|
253
|
+
|
254
|
+
class LvFont(LValidator):
|
255
|
+
def __init__(self):
|
256
|
+
def lv_builtin_font(value):
|
257
|
+
fontval = cv.one_of(*LV_FONTS, lower=True)(value)
|
258
|
+
lv_fonts_used.add(fontval)
|
259
|
+
return fontval
|
260
|
+
|
261
|
+
def validator(value):
|
262
|
+
if value == SCHEMA_EXTRACT:
|
263
|
+
return LV_FONTS
|
264
|
+
if is_lv_font(value):
|
265
|
+
return lv_builtin_font(value)
|
266
|
+
fontval = cv.use_id(Font)(value)
|
267
|
+
esphome_fonts_used.add(fontval)
|
268
|
+
return requires_component("font")(fontval)
|
269
|
+
|
270
|
+
super().__init__(validator, lv_font_t)
|
271
|
+
|
272
|
+
async def process(self, value, args=()):
|
273
|
+
if is_lv_font(value):
|
274
|
+
return literal(f"&lv_font_{value}")
|
275
|
+
return literal(f"{value}_engine->get_lv_font()")
|
276
|
+
|
277
|
+
|
278
|
+
lv_font = LvFont()
|
279
|
+
|
280
|
+
|
281
|
+
def animated(value):
|
282
|
+
if isinstance(value, bool):
|
283
|
+
value = "ON" if value else "OFF"
|
284
|
+
return LvConstant("LV_ANIM_", "OFF", "ON").one_of(value)
|
285
|
+
|
286
|
+
|
287
|
+
def key_code(value):
|
288
|
+
value = cv.Any(cv.All(cv.string_strict, cv.Length(min=1, max=1)), cv.uint8_t)(value)
|
289
|
+
if isinstance(value, str):
|
290
|
+
return ord(value[0])
|
291
|
+
return value
|
292
|
+
|
293
|
+
|
294
|
+
async def get_end_value(config):
|
295
|
+
return await lv_int.process(config.get(CONF_END_VALUE))
|
296
|
+
|
297
|
+
|
298
|
+
async def get_start_value(config):
|
299
|
+
if CONF_START_VALUE in config:
|
300
|
+
value = config[CONF_START_VALUE]
|
301
|
+
else:
|
302
|
+
value = config.get(CONF_VALUE)
|
303
|
+
return await lv_int.process(value)
|