esphome 2025.8.4__py3-none-any.whl → 2025.9.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 +177 -105
- esphome/components/absolute_humidity/absolute_humidity.cpp +3 -5
- esphome/components/adc/__init__.py +1 -26
- esphome/components/adc/adc_sensor_esp32.cpp +29 -6
- esphome/components/adc/sensor.py +20 -0
- esphome/components/ade7880/ade7880.cpp +1 -1
- esphome/components/ags10/ags10.cpp +3 -18
- esphome/components/ags10/ags10.h +2 -12
- esphome/components/aht10/aht10.cpp +3 -3
- esphome/components/airthings_ble/__init__.py +2 -2
- esphome/components/alarm_control_panel/__init__.py +2 -2
- esphome/components/am2315c/am2315c.cpp +1 -17
- esphome/components/am2315c/am2315c.h +2 -3
- esphome/components/api/__init__.py +2 -2
- esphome/components/api/api_connection.cpp +38 -34
- esphome/components/api/api_connection.h +20 -40
- esphome/components/api/api_frame_helper.cpp +25 -25
- esphome/components/api/api_frame_helper.h +3 -3
- esphome/components/api/api_frame_helper_noise.cpp +75 -40
- esphome/components/api/api_frame_helper_noise.h +3 -7
- esphome/components/api/api_frame_helper_plaintext.cpp +17 -4
- esphome/components/api/api_frame_helper_plaintext.h +1 -4
- esphome/components/api/api_pb2.cpp +12 -2
- esphome/components/api/api_pb2.h +144 -143
- esphome/components/api/api_pb2_dump.cpp +6 -1
- esphome/components/api/api_pb2_service.cpp +0 -14
- esphome/components/api/api_pb2_service.h +1 -3
- esphome/components/api/client.py +5 -3
- esphome/components/api/proto.cpp +33 -37
- esphome/components/async_tcp/__init__.py +2 -2
- esphome/components/atm90e26/sensor.py +2 -0
- esphome/components/atm90e32/sensor.py +4 -2
- esphome/components/audio_adc/__init__.py +2 -2
- esphome/components/audio_dac/__init__.py +2 -2
- esphome/components/axs15231/touchscreen/axs15231_touchscreen.cpp +1 -1
- esphome/components/bedjet/bedjet_hub.cpp +1 -1
- esphome/components/binary_sensor/__init__.py +2 -2
- esphome/components/binary_sensor/binary_sensor.cpp +13 -0
- esphome/components/binary_sensor/binary_sensor.h +4 -7
- esphome/components/bl0940/__init__.py +6 -1
- esphome/components/bl0940/bl0940.cpp +178 -41
- esphome/components/bl0940/bl0940.h +121 -76
- esphome/components/bl0940/button/__init__.py +27 -0
- esphome/components/bl0940/button/calibration_reset_button.cpp +20 -0
- esphome/components/bl0940/button/calibration_reset_button.h +19 -0
- esphome/components/bl0940/number/__init__.py +94 -0
- esphome/components/bl0940/number/calibration_number.cpp +29 -0
- esphome/components/bl0940/number/calibration_number.h +26 -0
- esphome/components/bl0940/sensor.py +151 -2
- esphome/components/bl0942/bl0942.cpp +1 -1
- esphome/components/ble_client/output/__init__.py +4 -4
- esphome/components/bluetooth_proxy/__init__.py +1 -1
- esphome/components/bluetooth_proxy/bluetooth_connection.h +1 -1
- esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +15 -7
- esphome/components/bluetooth_proxy/bluetooth_proxy.h +6 -3
- esphome/components/button/__init__.py +2 -2
- esphome/components/button/button.cpp +13 -0
- esphome/components/button/button.h +4 -7
- esphome/components/camera/buffer.h +18 -0
- esphome/components/camera/buffer_impl.cpp +20 -0
- esphome/components/camera/buffer_impl.h +26 -0
- esphome/components/camera/camera.h +43 -0
- esphome/components/camera/encoder.h +69 -0
- esphome/components/camera_encoder/__init__.py +62 -0
- esphome/components/camera_encoder/encoder_buffer_impl.cpp +23 -0
- esphome/components/camera_encoder/encoder_buffer_impl.h +25 -0
- esphome/components/camera_encoder/esp32_camera_jpeg_encoder.cpp +82 -0
- esphome/components/camera_encoder/esp32_camera_jpeg_encoder.h +39 -0
- esphome/components/captive_portal/__init__.py +2 -2
- esphome/components/captive_portal/captive_index.h +77 -97
- esphome/components/captive_portal/captive_portal.cpp +35 -12
- esphome/components/captive_portal/captive_portal.h +3 -3
- esphome/components/ccs811/ccs811.cpp +3 -3
- esphome/components/climate/__init__.py +2 -2
- esphome/components/climate/climate.cpp +1 -1
- esphome/components/cover/__init__.py +5 -5
- esphome/components/cover/cover.cpp +1 -1
- esphome/components/cover/cover.h +2 -2
- esphome/components/dallas_temp/dallas_temp.cpp +2 -2
- esphome/components/datetime/__init__.py +2 -2
- esphome/components/datetime/date_entity.h +2 -2
- esphome/components/datetime/datetime_entity.h +2 -2
- esphome/components/datetime/time_entity.h +2 -2
- esphome/components/debug/debug_esp32.cpp +1 -1
- esphome/components/display/__init__.py +4 -4
- esphome/components/duty_time/duty_time_sensor.cpp +1 -1
- esphome/components/esp32/__init__.py +0 -5
- esphome/components/esp32/gpio.cpp +27 -23
- esphome/components/esp32/gpio.h +26 -11
- esphome/components/esp32/preferences.cpp +8 -4
- esphome/components/esp32_ble/__init__.py +7 -2
- esphome/components/esp32_ble/ble_uuid.cpp +30 -9
- esphome/components/esp32_ble_beacon/esp32_ble_beacon.cpp +4 -3
- esphome/components/esp32_ble_client/ble_client_base.cpp +7 -3
- esphome/components/esp32_ble_client/ble_client_base.h +8 -5
- esphome/components/esp32_ble_tracker/__init__.py +2 -2
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +11 -47
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +2 -14
- esphome/components/esp8266/__init__.py +2 -2
- esphome/components/esp8266/core.cpp +2 -2
- esphome/components/esp8266/gpio.py +4 -4
- esphome/components/esp8266/preferences.cpp +30 -28
- esphome/components/esphome/ota/__init__.py +2 -2
- esphome/components/esphome/ota/ota_esphome.cpp +21 -19
- esphome/components/esphome/ota/ota_esphome.h +6 -5
- esphome/components/ethernet/__init__.py +18 -2
- esphome/components/ethernet/ethernet_component.cpp +53 -3
- esphome/components/ethernet/ethernet_component.h +4 -0
- esphome/components/event/__init__.py +2 -2
- esphome/components/event/event.h +4 -4
- esphome/components/factory_reset/button/factory_reset_button.cpp +18 -1
- esphome/components/factory_reset/button/factory_reset_button.h +6 -1
- esphome/components/factory_reset/switch/factory_reset_switch.cpp +18 -1
- esphome/components/factory_reset/switch/factory_reset_switch.h +5 -1
- esphome/components/fan/__init__.py +2 -2
- esphome/components/fan/fan.cpp +2 -1
- esphome/components/gdk101/gdk101.cpp +4 -4
- esphome/components/globals/__init__.py +2 -2
- esphome/components/gpio/binary_sensor/gpio_binary_sensor.cpp +19 -18
- esphome/components/gpio_expander/cached_gpio.h +36 -16
- esphome/components/grove_gas_mc_v2/grove_gas_mc_v2.cpp +5 -5
- esphome/components/gt911/touchscreen/gt911_touchscreen.cpp +1 -1
- esphome/components/haier/haier_base.cpp +1 -1
- esphome/components/haier/hon_climate.cpp +1 -1
- esphome/components/hlw8012/hlw8012.cpp +5 -5
- esphome/components/honeywellabp2_i2c/honeywellabp2.cpp +4 -4
- esphome/components/host/preferences.h +3 -2
- esphome/components/hte501/hte501.cpp +3 -21
- esphome/components/hte501/hte501.h +2 -3
- esphome/components/http_request/ota/__init__.py +2 -2
- esphome/components/i2c/__init__.py +2 -2
- esphome/components/i2c/i2c.cpp +13 -9
- esphome/components/i2c/i2c_bus.h +36 -6
- esphome/components/i2s_audio/__init__.py +8 -2
- esphome/components/i2s_audio/media_player/__init__.py +1 -1
- esphome/components/i2s_audio/microphone/__init__.py +1 -1
- esphome/components/i2s_audio/speaker/__init__.py +1 -1
- esphome/components/ina2xx_base/__init__.py +4 -2
- esphome/components/inkplate/__init__.py +1 -0
- esphome/components/inkplate/const.py +105 -0
- esphome/components/inkplate/display.py +238 -0
- esphome/components/{inkplate6 → inkplate}/inkplate.cpp +156 -74
- esphome/components/{inkplate6 → inkplate}/inkplate.h +28 -68
- esphome/components/inkplate6/__init__.py +0 -1
- esphome/components/inkplate6/display.py +2 -211
- esphome/components/integration/integration_sensor.cpp +1 -1
- esphome/components/json/__init__.py +2 -2
- esphome/components/lc709203f/lc709203f.cpp +4 -17
- esphome/components/lc709203f/lc709203f.h +2 -3
- esphome/components/ld2420/text_sensor/{text_sensor.cpp → ld2420_text_sensor.cpp} +1 -1
- esphome/components/ld2450/ld2450.cpp +1 -1
- esphome/components/libretiny/preferences.cpp +13 -5
- esphome/components/light/__init__.py +2 -2
- esphome/components/light/addressable_light_effect.h +7 -0
- esphome/components/light/base_light_effects.h +8 -0
- esphome/components/light/light_call.cpp +22 -20
- esphome/components/light/light_effect.cpp +36 -0
- esphome/components/light/light_effect.h +14 -0
- esphome/components/light/light_json_schema.cpp +9 -1
- esphome/components/light/light_state.cpp +2 -2
- esphome/components/light/light_state.h +38 -0
- esphome/components/lock/__init__.py +2 -2
- esphome/components/lock/lock.h +2 -2
- esphome/components/logger/__init__.py +2 -2
- esphome/components/logger/logger.cpp +25 -4
- esphome/components/logger/logger.h +1 -1
- esphome/components/logger/logger_esp32.cpp +16 -8
- esphome/components/logger/logger_esp8266.cpp +11 -3
- esphome/components/logger/logger_libretiny.cpp +13 -3
- esphome/components/logger/logger_rp2040.cpp +14 -3
- esphome/components/logger/logger_zephyr.cpp +15 -4
- esphome/components/lvgl/defines.py +1 -0
- esphome/components/lvgl/hello_world.py +96 -33
- esphome/components/lvgl/number/lvgl_number.h +1 -1
- esphome/components/lvgl/select/lvgl_select.h +1 -1
- esphome/components/lvgl/widgets/__init__.py +0 -1
- esphome/components/lvgl/widgets/spinbox.py +20 -11
- esphome/components/m5stack_8angle/binary_sensor/m5stack_8angle_binary_sensor.cpp +1 -1
- esphome/components/m5stack_8angle/sensor/m5stack_8angle_sensor.cpp +1 -1
- esphome/components/mapping/__init__.py +13 -5
- esphome/components/mapping/mapping.h +69 -0
- esphome/components/max17043/max17043.cpp +2 -2
- esphome/components/mcp23016/__init__.py +1 -0
- esphome/components/mcp23016/mcp23016.cpp +20 -5
- esphome/components/mcp23016/mcp23016.h +10 -4
- esphome/components/mcp23x08_base/mcp23x08_base.cpp +1 -1
- esphome/components/mcp23x17_base/mcp23x17_base.cpp +2 -2
- esphome/components/md5/md5.cpp +3 -2
- esphome/components/mdns/__init__.py +2 -2
- esphome/components/mdns/mdns_component.cpp +145 -54
- esphome/components/media_player/__init__.py +2 -2
- esphome/components/micro_wake_word/__init__.py +2 -2
- esphome/components/microphone/__init__.py +2 -2
- esphome/components/mipi/__init__.py +77 -33
- esphome/components/mipi_rgb/__init__.py +2 -0
- esphome/components/mipi_rgb/display.py +321 -0
- esphome/components/mipi_rgb/mipi_rgb.cpp +388 -0
- esphome/components/mipi_rgb/mipi_rgb.h +127 -0
- esphome/components/mipi_rgb/models/guition.py +24 -0
- esphome/components/mipi_rgb/models/lilygo.py +228 -0
- esphome/components/mipi_rgb/models/rpi.py +9 -0
- esphome/components/mipi_rgb/models/st7701s.py +214 -0
- esphome/components/mipi_rgb/models/waveshare.py +64 -0
- esphome/components/mipi_spi/models/jc.py +229 -0
- esphome/components/mlx90614/mlx90614.cpp +1 -16
- esphome/components/mlx90614/mlx90614.h +0 -1
- esphome/components/mqtt/__init__.py +2 -2
- esphome/components/mqtt/mqtt_client.cpp +1 -1
- esphome/components/mqtt/mqtt_sensor.cpp +7 -2
- esphome/components/ms5611/ms5611.cpp +7 -6
- esphome/components/network/__init__.py +2 -2
- esphome/components/nextion/nextion_upload.cpp +4 -1
- esphome/components/nrf52/__init__.py +49 -6
- esphome/components/nrf52/const.py +1 -0
- esphome/components/nrf52/dfu.cpp +51 -0
- esphome/components/nrf52/dfu.h +24 -0
- esphome/components/ntc/ntc.cpp +1 -1
- esphome/components/number/__init__.py +2 -2
- esphome/components/number/automation.cpp +1 -1
- esphome/components/number/number.cpp +21 -0
- esphome/components/number/number.h +4 -13
- esphome/components/opentherm/hub.h +6 -6
- esphome/components/opentherm/number/{number.cpp → opentherm_number.cpp} +2 -2
- esphome/components/opentherm/output/{output.cpp → opentherm_output.cpp} +1 -1
- esphome/components/opentherm/switch/{switch.cpp → opentherm_switch.cpp} +1 -1
- esphome/components/openthread/openthread.cpp +41 -7
- esphome/components/openthread/openthread.h +11 -0
- esphome/components/ota/__init__.py +2 -2
- esphome/components/pca6416a/__init__.py +1 -0
- esphome/components/pca6416a/pca6416a.cpp +20 -5
- esphome/components/pca6416a/pca6416a.h +12 -5
- esphome/components/pca9554/__init__.py +2 -1
- esphome/components/pca9554/pca9554.cpp +12 -18
- esphome/components/pca9554/pca9554.h +10 -9
- esphome/components/pcf8574/__init__.py +1 -0
- esphome/components/pcf8574/pcf8574.cpp +14 -5
- esphome/components/pcf8574/pcf8574.h +13 -6
- esphome/components/pi4ioe5v6408/pi4ioe5v6408.cpp +7 -7
- esphome/components/pipsolar/__init__.py +3 -3
- esphome/components/pipsolar/output/__init__.py +4 -4
- esphome/components/pulse_width/pulse_width.cpp +2 -2
- esphome/components/qmp6988/qmp6988.cpp +81 -126
- esphome/components/qmp6988/qmp6988.h +31 -37
- esphome/components/radon_eye_ble/__init__.py +2 -2
- esphome/components/remote_base/__init__.py +6 -8
- esphome/components/rotary_encoder/rotary_encoder.cpp +1 -1
- esphome/components/rp2040/__init__.py +2 -2
- esphome/components/runtime_stats/runtime_stats.cpp +10 -23
- esphome/components/runtime_stats/runtime_stats.h +4 -10
- esphome/components/safe_mode/__init__.py +2 -2
- esphome/components/safe_mode/safe_mode.cpp +33 -31
- esphome/components/script/script.cpp +6 -0
- esphome/components/script/script.h +19 -5
- esphome/components/sdm_meter/sensor.py +3 -1
- esphome/components/select/__init__.py +2 -2
- esphome/components/select/select.cpp +3 -3
- esphome/components/select/select.h +2 -2
- esphome/components/select/select_call.cpp +1 -1
- esphome/components/sen5x/sen5x.cpp +57 -55
- esphome/components/sen5x/sen5x.h +21 -15
- esphome/components/sen5x/sensor.py +67 -44
- esphome/components/sensirion_common/i2c_sensirion.cpp +18 -47
- esphome/components/sensirion_common/i2c_sensirion.h +39 -55
- esphome/components/sensor/__init__.py +2 -2
- esphome/components/sensor/automation.h +1 -1
- esphome/components/sensor/sensor.cpp +34 -6
- esphome/components/sensor/sensor.h +4 -21
- esphome/components/sgp30/sgp30.cpp +34 -35
- esphome/components/sgp30/sgp30.h +11 -10
- esphome/components/sgp4x/sgp4x.cpp +2 -2
- esphome/components/shelly_dimmer/light.py +7 -7
- esphome/components/sht4x/sht4x.cpp +1 -1
- esphome/components/sntp/sntp_component.cpp +36 -9
- esphome/components/sntp/sntp_component.h +7 -0
- esphome/components/sound_level/sound_level.cpp +1 -1
- esphome/components/speaker/__init__.py +2 -2
- esphome/components/speaker/media_player/__init__.py +2 -2
- esphome/components/speaker/media_player/speaker_media_player.cpp +1 -1
- esphome/components/spi/__init__.py +2 -2
- esphome/components/sprinkler/sprinkler.cpp +1 -1
- esphome/components/sps30/sps30.cpp +18 -23
- esphome/components/sps30/sps30.h +3 -3
- esphome/components/status_led/__init__.py +2 -2
- esphome/components/stepper/__init__.py +2 -2
- esphome/components/switch/__init__.py +2 -2
- esphome/components/switch/switch.cpp +5 -5
- esphome/components/sx1509/__init__.py +1 -1
- esphome/components/sx1509/sx1509.cpp +12 -7
- esphome/components/sx1509/sx1509.h +11 -4
- esphome/components/tca9555/tca9555.cpp +5 -5
- esphome/components/tee501/tee501.cpp +2 -21
- esphome/components/tee501/tee501.h +2 -4
- esphome/components/template/alarm_control_panel/template_alarm_control_panel.cpp +1 -1
- esphome/components/template/datetime/template_date.cpp +1 -1
- esphome/components/template/datetime/template_datetime.cpp +2 -2
- esphome/components/template/datetime/template_time.cpp +1 -1
- esphome/components/template/number/template_number.cpp +1 -1
- esphome/components/template/select/template_select.cpp +1 -1
- esphome/components/template/text/template_text.cpp +1 -1
- esphome/components/text/__init__.py +2 -2
- esphome/components/text/text.h +2 -2
- esphome/components/text_sensor/__init__.py +2 -2
- esphome/components/text_sensor/text_sensor.h +4 -4
- esphome/components/thermostat/climate.py +11 -7
- esphome/components/thermostat/thermostat_climate.cpp +237 -206
- esphome/components/thermostat/thermostat_climate.h +52 -41
- esphome/components/time/__init__.py +2 -2
- esphome/components/tmp1075/tmp1075.cpp +1 -1
- esphome/components/total_daily_energy/total_daily_energy.cpp +1 -1
- esphome/components/touchscreen/__init__.py +2 -2
- esphome/components/tuya/number/tuya_number.cpp +1 -1
- esphome/components/udp/udp_component.cpp +3 -3
- esphome/components/ufire_ec/ufire_ec.cpp +4 -4
- esphome/components/ufire_ise/ufire_ise.cpp +4 -4
- esphome/components/update/__init__.py +2 -2
- esphome/components/usb_uart/usb_uart.cpp +1 -1
- esphome/components/valve/__init__.py +5 -5
- esphome/components/valve/valve.cpp +1 -1
- esphome/components/valve/valve.h +2 -2
- esphome/components/wake_on_lan/wake_on_lan.cpp +2 -2
- esphome/components/waveshare_epaper/waveshare_213v3.cpp +1 -1
- esphome/components/web_server/__init__.py +2 -2
- esphome/components/web_server/ota/__init__.py +2 -2
- esphome/components/web_server/ota/ota_web_server.cpp +11 -0
- esphome/components/web_server/server_index_v2.h +149 -149
- esphome/components/web_server/web_server.cpp +58 -12
- esphome/components/web_server_base/__init__.py +2 -2
- esphome/components/wifi/__init__.py +5 -5
- esphome/components/wifi/wifi_component.cpp +4 -4
- esphome/components/wifi/wifi_component_esp_idf.cpp +2 -0
- esphome/components/wifi_info/wifi_info_text_sensor.h +3 -2
- esphome/config_validation.py +2 -2
- esphome/const.py +3 -1
- esphome/core/__init__.py +1 -0
- esphome/core/application.cpp +89 -51
- esphome/core/application.h +1 -0
- esphome/core/component.cpp +41 -19
- esphome/core/component.h +17 -13
- esphome/core/config.py +7 -7
- esphome/core/defines.h +5 -0
- esphome/core/entity_base.cpp +22 -8
- esphome/core/entity_base.h +43 -0
- esphome/core/helpers.cpp +34 -20
- esphome/core/helpers.h +33 -3
- esphome/core/ring_buffer.cpp +6 -2
- esphome/core/ring_buffer.h +2 -1
- esphome/core/scheduler.cpp +178 -97
- esphome/core/scheduler.h +67 -36
- esphome/core/time.cpp +6 -20
- esphome/coroutine.py +80 -3
- esphome/cpp_generator.py +13 -0
- esphome/cpp_helpers.py +2 -2
- esphome/dashboard/web_server.py +69 -15
- esphome/espota2.py +13 -6
- esphome/helpers.py +68 -83
- esphome/resolver.py +67 -0
- esphome/util.py +9 -6
- esphome/wizard.py +81 -34
- esphome/writer.py +13 -0
- {esphome-2025.8.4.dist-info → esphome-2025.9.0.dist-info}/METADATA +9 -9
- {esphome-2025.8.4.dist-info → esphome-2025.9.0.dist-info}/RECORD +369 -338
- /esphome/components/ld2420/text_sensor/{text_sensor.h → ld2420_text_sensor.h} +0 -0
- /esphome/components/opentherm/number/{number.h → opentherm_number.h} +0 -0
- /esphome/components/opentherm/output/{output.h → opentherm_output.h} +0 -0
- /esphome/components/opentherm/switch/{switch.h → opentherm_switch.h} +0 -0
- {esphome-2025.8.4.dist-info → esphome-2025.9.0.dist-info}/WHEEL +0 -0
- {esphome-2025.8.4.dist-info → esphome-2025.9.0.dist-info}/entry_points.txt +0 -0
- {esphome-2025.8.4.dist-info → esphome-2025.9.0.dist-info}/licenses/LICENSE +0 -0
- {esphome-2025.8.4.dist-info → esphome-2025.9.0.dist-info}/top_level.txt +0 -0
@@ -164,6 +164,44 @@ class LightState : public EntityBase, public Component {
|
|
164
164
|
/// Add effects for this light state.
|
165
165
|
void add_effects(const std::vector<LightEffect *> &effects);
|
166
166
|
|
167
|
+
/// Get the total number of effects available for this light.
|
168
|
+
size_t get_effect_count() const { return this->effects_.size(); }
|
169
|
+
|
170
|
+
/// Get the currently active effect index (0 = no effect, 1+ = effect index).
|
171
|
+
uint32_t get_current_effect_index() const { return this->active_effect_index_; }
|
172
|
+
|
173
|
+
/// Get effect index by name. Returns 0 if effect not found.
|
174
|
+
uint32_t get_effect_index(const std::string &effect_name) const {
|
175
|
+
if (strcasecmp(effect_name.c_str(), "none") == 0) {
|
176
|
+
return 0;
|
177
|
+
}
|
178
|
+
for (size_t i = 0; i < this->effects_.size(); i++) {
|
179
|
+
if (strcasecmp(effect_name.c_str(), this->effects_[i]->get_name().c_str()) == 0) {
|
180
|
+
return i + 1; // Effects are 1-indexed in active_effect_index_
|
181
|
+
}
|
182
|
+
}
|
183
|
+
return 0; // Effect not found
|
184
|
+
}
|
185
|
+
|
186
|
+
/// Get effect by index. Returns nullptr if index is invalid.
|
187
|
+
LightEffect *get_effect_by_index(uint32_t index) const {
|
188
|
+
if (index == 0 || index > this->effects_.size()) {
|
189
|
+
return nullptr;
|
190
|
+
}
|
191
|
+
return this->effects_[index - 1]; // Effects are 1-indexed in active_effect_index_
|
192
|
+
}
|
193
|
+
|
194
|
+
/// Get effect name by index. Returns "None" for index 0, empty string for invalid index.
|
195
|
+
std::string get_effect_name_by_index(uint32_t index) const {
|
196
|
+
if (index == 0) {
|
197
|
+
return "None";
|
198
|
+
}
|
199
|
+
if (index > this->effects_.size()) {
|
200
|
+
return ""; // Invalid index
|
201
|
+
}
|
202
|
+
return this->effects_[index - 1]->get_name();
|
203
|
+
}
|
204
|
+
|
167
205
|
/// The result of all the current_values_as_* methods have gamma correction applied.
|
168
206
|
void current_values_as_binary(bool *binary);
|
169
207
|
|
@@ -13,7 +13,7 @@ from esphome.const import (
|
|
13
13
|
CONF_TRIGGER_ID,
|
14
14
|
CONF_WEB_SERVER,
|
15
15
|
)
|
16
|
-
from esphome.core import CORE, coroutine_with_priority
|
16
|
+
from esphome.core import CORE, CoroPriority, coroutine_with_priority
|
17
17
|
from esphome.core.entity_helpers import entity_duplicate_validator, setup_entity
|
18
18
|
from esphome.cpp_generator import MockObjClass
|
19
19
|
|
@@ -155,6 +155,6 @@ async def lock_is_off_to_code(config, condition_id, template_arg, args):
|
|
155
155
|
return cg.new_Pvariable(condition_id, template_arg, paren, False)
|
156
156
|
|
157
157
|
|
158
|
-
@coroutine_with_priority(
|
158
|
+
@coroutine_with_priority(CoroPriority.CORE)
|
159
159
|
async def to_code(config):
|
160
160
|
cg.add_global(lock_ns.using)
|
esphome/components/lock/lock.h
CHANGED
@@ -15,8 +15,8 @@ class Lock;
|
|
15
15
|
#define LOG_LOCK(prefix, type, obj) \
|
16
16
|
if ((obj) != nullptr) { \
|
17
17
|
ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
|
18
|
-
if (!(obj)->
|
19
|
-
ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->
|
18
|
+
if (!(obj)->get_icon_ref().empty()) { \
|
19
|
+
ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon_ref().c_str()); \
|
20
20
|
} \
|
21
21
|
if ((obj)->traits.get_assumed_state()) { \
|
22
22
|
ESP_LOGCONFIG(TAG, "%s Assumed State: YES", prefix); \
|
@@ -51,7 +51,7 @@ from esphome.const import (
|
|
51
51
|
PLATFORM_RTL87XX,
|
52
52
|
PlatformFramework,
|
53
53
|
)
|
54
|
-
from esphome.core import CORE, Lambda, coroutine_with_priority
|
54
|
+
from esphome.core import CORE, CoroPriority, Lambda, coroutine_with_priority
|
55
55
|
|
56
56
|
CODEOWNERS = ["@esphome/core"]
|
57
57
|
logger_ns = cg.esphome_ns.namespace("logger")
|
@@ -275,7 +275,7 @@ CONFIG_SCHEMA = cv.All(
|
|
275
275
|
)
|
276
276
|
|
277
277
|
|
278
|
-
@coroutine_with_priority(
|
278
|
+
@coroutine_with_priority(CoroPriority.DIAGNOSTICS)
|
279
279
|
async def to_code(config):
|
280
280
|
baud_rate = config[CONF_BAUD_RATE]
|
281
281
|
level = config[CONF_LEVEL]
|
@@ -246,19 +246,40 @@ void Logger::add_on_log_callback(std::function<void(uint8_t, const char *, const
|
|
246
246
|
this->log_callback_.add(std::move(callback));
|
247
247
|
}
|
248
248
|
float Logger::get_setup_priority() const { return setup_priority::BUS + 500.0f; }
|
249
|
+
|
250
|
+
#ifdef USE_STORE_LOG_STR_IN_FLASH
|
251
|
+
// ESP8266: PSTR() cannot be used in array initializers, so we need to declare
|
252
|
+
// each string separately as a global constant first
|
253
|
+
static const char LOG_LEVEL_NONE[] PROGMEM = "NONE";
|
254
|
+
static const char LOG_LEVEL_ERROR[] PROGMEM = "ERROR";
|
255
|
+
static const char LOG_LEVEL_WARN[] PROGMEM = "WARN";
|
256
|
+
static const char LOG_LEVEL_INFO[] PROGMEM = "INFO";
|
257
|
+
static const char LOG_LEVEL_CONFIG[] PROGMEM = "CONFIG";
|
258
|
+
static const char LOG_LEVEL_DEBUG[] PROGMEM = "DEBUG";
|
259
|
+
static const char LOG_LEVEL_VERBOSE[] PROGMEM = "VERBOSE";
|
260
|
+
static const char LOG_LEVEL_VERY_VERBOSE[] PROGMEM = "VERY_VERBOSE";
|
261
|
+
|
262
|
+
static const LogString *const LOG_LEVELS[] = {
|
263
|
+
reinterpret_cast<const LogString *>(LOG_LEVEL_NONE), reinterpret_cast<const LogString *>(LOG_LEVEL_ERROR),
|
264
|
+
reinterpret_cast<const LogString *>(LOG_LEVEL_WARN), reinterpret_cast<const LogString *>(LOG_LEVEL_INFO),
|
265
|
+
reinterpret_cast<const LogString *>(LOG_LEVEL_CONFIG), reinterpret_cast<const LogString *>(LOG_LEVEL_DEBUG),
|
266
|
+
reinterpret_cast<const LogString *>(LOG_LEVEL_VERBOSE), reinterpret_cast<const LogString *>(LOG_LEVEL_VERY_VERBOSE),
|
267
|
+
};
|
268
|
+
#else
|
249
269
|
static const char *const LOG_LEVELS[] = {"NONE", "ERROR", "WARN", "INFO", "CONFIG", "DEBUG", "VERBOSE", "VERY_VERBOSE"};
|
270
|
+
#endif
|
250
271
|
|
251
272
|
void Logger::dump_config() {
|
252
273
|
ESP_LOGCONFIG(TAG,
|
253
274
|
"Logger:\n"
|
254
275
|
" Max Level: %s\n"
|
255
276
|
" Initial Level: %s",
|
256
|
-
LOG_LEVELS[ESPHOME_LOG_LEVEL], LOG_LEVELS[this->current_level_]);
|
277
|
+
LOG_STR_ARG(LOG_LEVELS[ESPHOME_LOG_LEVEL]), LOG_STR_ARG(LOG_LEVELS[this->current_level_]));
|
257
278
|
#ifndef USE_HOST
|
258
279
|
ESP_LOGCONFIG(TAG,
|
259
280
|
" Log Baud Rate: %" PRIu32 "\n"
|
260
281
|
" Hardware UART: %s",
|
261
|
-
this->baud_rate_, get_uart_selection_());
|
282
|
+
this->baud_rate_, LOG_STR_ARG(get_uart_selection_()));
|
262
283
|
#endif
|
263
284
|
#ifdef USE_ESPHOME_TASK_LOG_BUFFER
|
264
285
|
if (this->log_buffer_) {
|
@@ -267,14 +288,14 @@ void Logger::dump_config() {
|
|
267
288
|
#endif
|
268
289
|
|
269
290
|
for (auto &it : this->log_levels_) {
|
270
|
-
ESP_LOGCONFIG(TAG, " Level for '%s': %s", it.first.c_str(), LOG_LEVELS[it.second]);
|
291
|
+
ESP_LOGCONFIG(TAG, " Level for '%s': %s", it.first.c_str(), LOG_STR_ARG(LOG_LEVELS[it.second]));
|
271
292
|
}
|
272
293
|
}
|
273
294
|
|
274
295
|
void Logger::set_log_level(uint8_t level) {
|
275
296
|
if (level > ESPHOME_LOG_LEVEL) {
|
276
297
|
level = ESPHOME_LOG_LEVEL;
|
277
|
-
ESP_LOGW(TAG, "Cannot set log level higher than pre-compiled %s", LOG_LEVELS[ESPHOME_LOG_LEVEL]);
|
298
|
+
ESP_LOGW(TAG, "Cannot set log level higher than pre-compiled %s", LOG_STR_ARG(LOG_LEVELS[ESPHOME_LOG_LEVEL]));
|
278
299
|
}
|
279
300
|
this->current_level_ = level;
|
280
301
|
this->level_callback_.call(level);
|
@@ -190,20 +190,28 @@ void HOT Logger::write_msg_(const char *msg) {
|
|
190
190
|
void HOT Logger::write_msg_(const char *msg) { this->hw_serial_->println(msg); }
|
191
191
|
#endif
|
192
192
|
|
193
|
-
const
|
194
|
-
|
193
|
+
const LogString *Logger::get_uart_selection_() {
|
194
|
+
switch (this->uart_) {
|
195
|
+
case UART_SELECTION_UART0:
|
196
|
+
return LOG_STR("UART0");
|
197
|
+
case UART_SELECTION_UART1:
|
198
|
+
return LOG_STR("UART1");
|
195
199
|
#ifdef USE_ESP32_VARIANT_ESP32
|
196
|
-
|
200
|
+
case UART_SELECTION_UART2:
|
201
|
+
return LOG_STR("UART2");
|
197
202
|
#endif
|
198
203
|
#ifdef USE_LOGGER_USB_CDC
|
199
|
-
|
204
|
+
case UART_SELECTION_USB_CDC:
|
205
|
+
return LOG_STR("USB_CDC");
|
200
206
|
#endif
|
201
207
|
#ifdef USE_LOGGER_USB_SERIAL_JTAG
|
202
|
-
|
208
|
+
case UART_SELECTION_USB_SERIAL_JTAG:
|
209
|
+
return LOG_STR("USB_SERIAL_JTAG");
|
203
210
|
#endif
|
204
|
-
|
205
|
-
|
206
|
-
|
211
|
+
default:
|
212
|
+
return LOG_STR("UNKNOWN");
|
213
|
+
}
|
214
|
+
}
|
207
215
|
|
208
216
|
} // namespace esphome::logger
|
209
217
|
#endif
|
@@ -35,9 +35,17 @@ void Logger::pre_setup() {
|
|
35
35
|
|
36
36
|
void HOT Logger::write_msg_(const char *msg) { this->hw_serial_->println(msg); }
|
37
37
|
|
38
|
-
const
|
39
|
-
|
40
|
-
|
38
|
+
const LogString *Logger::get_uart_selection_() {
|
39
|
+
switch (this->uart_) {
|
40
|
+
case UART_SELECTION_UART0:
|
41
|
+
return LOG_STR("UART0");
|
42
|
+
case UART_SELECTION_UART1:
|
43
|
+
return LOG_STR("UART1");
|
44
|
+
case UART_SELECTION_UART0_SWAP:
|
45
|
+
default:
|
46
|
+
return LOG_STR("UART0_SWAP");
|
47
|
+
}
|
48
|
+
}
|
41
49
|
|
42
50
|
} // namespace esphome::logger
|
43
51
|
#endif
|
@@ -51,9 +51,19 @@ void Logger::pre_setup() {
|
|
51
51
|
|
52
52
|
void HOT Logger::write_msg_(const char *msg) { this->hw_serial_->println(msg); }
|
53
53
|
|
54
|
-
const
|
55
|
-
|
56
|
-
|
54
|
+
const LogString *Logger::get_uart_selection_() {
|
55
|
+
switch (this->uart_) {
|
56
|
+
case UART_SELECTION_DEFAULT:
|
57
|
+
return LOG_STR("DEFAULT");
|
58
|
+
case UART_SELECTION_UART0:
|
59
|
+
return LOG_STR("UART0");
|
60
|
+
case UART_SELECTION_UART1:
|
61
|
+
return LOG_STR("UART1");
|
62
|
+
case UART_SELECTION_UART2:
|
63
|
+
default:
|
64
|
+
return LOG_STR("UART2");
|
65
|
+
}
|
66
|
+
}
|
57
67
|
|
58
68
|
} // namespace esphome::logger
|
59
69
|
|
@@ -29,9 +29,20 @@ void Logger::pre_setup() {
|
|
29
29
|
|
30
30
|
void HOT Logger::write_msg_(const char *msg) { this->hw_serial_->println(msg); }
|
31
31
|
|
32
|
-
const
|
33
|
-
|
34
|
-
|
32
|
+
const LogString *Logger::get_uart_selection_() {
|
33
|
+
switch (this->uart_) {
|
34
|
+
case UART_SELECTION_UART0:
|
35
|
+
return LOG_STR("UART0");
|
36
|
+
case UART_SELECTION_UART1:
|
37
|
+
return LOG_STR("UART1");
|
38
|
+
#ifdef USE_LOGGER_USB_CDC
|
39
|
+
case UART_SELECTION_USB_CDC:
|
40
|
+
return LOG_STR("USB_CDC");
|
41
|
+
#endif
|
42
|
+
default:
|
43
|
+
return LOG_STR("UNKNOWN");
|
44
|
+
}
|
45
|
+
}
|
35
46
|
|
36
47
|
} // namespace esphome::logger
|
37
48
|
#endif // USE_RP2040
|
@@ -54,7 +54,7 @@ void Logger::pre_setup() {
|
|
54
54
|
#endif
|
55
55
|
}
|
56
56
|
if (!device_is_ready(uart_dev)) {
|
57
|
-
ESP_LOGE(TAG, "%s is not ready.", get_uart_selection_());
|
57
|
+
ESP_LOGE(TAG, "%s is not ready.", LOG_STR_ARG(get_uart_selection_()));
|
58
58
|
} else {
|
59
59
|
this->uart_dev_ = uart_dev;
|
60
60
|
}
|
@@ -77,9 +77,20 @@ void HOT Logger::write_msg_(const char *msg) {
|
|
77
77
|
uart_poll_out(this->uart_dev_, '\n');
|
78
78
|
}
|
79
79
|
|
80
|
-
const
|
81
|
-
|
82
|
-
|
80
|
+
const LogString *Logger::get_uart_selection_() {
|
81
|
+
switch (this->uart_) {
|
82
|
+
case UART_SELECTION_UART0:
|
83
|
+
return LOG_STR("UART0");
|
84
|
+
case UART_SELECTION_UART1:
|
85
|
+
return LOG_STR("UART1");
|
86
|
+
#ifdef USE_LOGGER_USB_CDC
|
87
|
+
case UART_SELECTION_USB_CDC:
|
88
|
+
return LOG_STR("USB_CDC");
|
89
|
+
#endif
|
90
|
+
default:
|
91
|
+
return LOG_STR("UNKNOWN");
|
92
|
+
}
|
93
|
+
}
|
83
94
|
|
84
95
|
} // namespace esphome::logger
|
85
96
|
|
@@ -451,6 +451,7 @@ CONF_GRID_ROWS = "grid_rows"
|
|
451
451
|
CONF_HEADER_MODE = "header_mode"
|
452
452
|
CONF_HOME = "home"
|
453
453
|
CONF_INITIAL_FOCUS = "initial_focus"
|
454
|
+
CONF_SELECTED_DIGIT = "selected_digit"
|
454
455
|
CONF_KEY_CODE = "key_code"
|
455
456
|
CONF_KEYPADS = "keypads"
|
456
457
|
CONF_LAYOUT = "layout"
|
@@ -4,49 +4,112 @@ from esphome.yaml_util import parse_yaml
|
|
4
4
|
|
5
5
|
CONFIG = """
|
6
6
|
- obj:
|
7
|
-
|
7
|
+
id: hello_world_card_
|
8
8
|
pad_all: 12
|
9
|
-
bg_color:
|
9
|
+
bg_color: white
|
10
10
|
height: 100%
|
11
11
|
width: 100%
|
12
|
+
scrollable: false
|
12
13
|
widgets:
|
13
|
-
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
14
|
+
- obj:
|
15
|
+
align: top_mid
|
16
|
+
outline_width: 0
|
17
|
+
border_width: 0
|
18
|
+
pad_all: 4
|
19
|
+
scrollable: false
|
20
|
+
height: size_content
|
21
|
+
width: 100%
|
22
|
+
layout:
|
23
|
+
type: flex
|
24
|
+
flex_flow: row
|
25
|
+
flex_align_cross: center
|
26
|
+
flex_align_track: start
|
27
|
+
flex_align_main: space_between
|
28
|
+
widgets:
|
29
|
+
- button:
|
30
|
+
checkable: true
|
31
|
+
radius: 4
|
32
|
+
text_font: montserrat_20
|
33
|
+
on_click:
|
34
|
+
lvgl.label.update:
|
35
|
+
id: hello_world_label_
|
36
|
+
text: "Clicked!"
|
37
|
+
widgets:
|
38
|
+
- label:
|
39
|
+
text: "Button"
|
40
|
+
- label:
|
41
|
+
id: hello_world_title_
|
42
|
+
text: ESPHome
|
43
|
+
text_font: montserrat_20
|
44
|
+
width: 100%
|
45
|
+
text_align: center
|
46
|
+
on_boot:
|
47
|
+
lvgl.widget.refresh: hello_world_title_
|
48
|
+
hidden: !lambda |-
|
49
|
+
return lv_obj_get_width(lv_scr_act()) < 400;
|
50
|
+
- checkbox:
|
51
|
+
text: Checkbox
|
52
|
+
id: hello_world_checkbox_
|
53
|
+
on_boot:
|
54
|
+
lvgl.widget.refresh: hello_world_checkbox_
|
55
|
+
hidden: !lambda |-
|
56
|
+
return lv_obj_get_width(lv_scr_act()) < 240;
|
57
|
+
on_click:
|
58
|
+
lvgl.label.update:
|
59
|
+
id: hello_world_label_
|
60
|
+
text: "Checked!"
|
61
|
+
- obj:
|
62
|
+
id: hello_world_container_
|
25
63
|
align: center
|
64
|
+
y: 14
|
65
|
+
pad_all: 0
|
66
|
+
outline_width: 0
|
67
|
+
border_width: 0
|
68
|
+
width: 100%
|
69
|
+
height: size_content
|
70
|
+
scrollable: false
|
26
71
|
on_click:
|
27
72
|
lvgl.spinner.update:
|
28
73
|
id: hello_world_spinner_
|
29
74
|
arc_color: springgreen
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
id: hello_world_label_
|
37
|
-
text: "Checked!"
|
38
|
-
- button:
|
39
|
-
pad_all: 8
|
40
|
-
checkable: true
|
41
|
-
align: top_left
|
42
|
-
text_font: montserrat_20
|
43
|
-
on_click:
|
44
|
-
lvgl.label.update:
|
45
|
-
id: hello_world_label_
|
46
|
-
text: "Clicked!"
|
75
|
+
layout:
|
76
|
+
type: flex
|
77
|
+
flex_flow: row_wrap
|
78
|
+
flex_align_cross: center
|
79
|
+
flex_align_track: center
|
80
|
+
flex_align_main: space_evenly
|
47
81
|
widgets:
|
48
|
-
|
49
|
-
|
82
|
+
- spinner:
|
83
|
+
id: hello_world_spinner_
|
84
|
+
indicator:
|
85
|
+
arc_color: tomato
|
86
|
+
height: 100
|
87
|
+
width: 100
|
88
|
+
spin_time: 2s
|
89
|
+
arc_length: 60deg
|
90
|
+
widgets:
|
91
|
+
- label:
|
92
|
+
id: hello_world_label_
|
93
|
+
text: "Hello World!"
|
94
|
+
align: center
|
95
|
+
- obj:
|
96
|
+
id: hello_world_qrcode_
|
97
|
+
outline_width: 0
|
98
|
+
border_width: 0
|
99
|
+
hidden: !lambda |-
|
100
|
+
return lv_obj_get_width(lv_scr_act()) < 300 && lv_obj_get_height(lv_scr_act()) < 400;
|
101
|
+
widgets:
|
102
|
+
- label:
|
103
|
+
text_font: montserrat_14
|
104
|
+
text: esphome.io
|
105
|
+
align: top_mid
|
106
|
+
- qrcode:
|
107
|
+
text: "https://esphome.io"
|
108
|
+
size: 80
|
109
|
+
align: bottom_mid
|
110
|
+
on_boot:
|
111
|
+
lvgl.widget.refresh: hello_world_qrcode_
|
112
|
+
|
50
113
|
- slider:
|
51
114
|
width: 80%
|
52
115
|
align: bottom_mid
|
@@ -21,7 +21,7 @@ class LVGLNumber : public number::Number, public Component {
|
|
21
21
|
void setup() override {
|
22
22
|
float value = this->value_lambda_();
|
23
23
|
if (this->restore_) {
|
24
|
-
this->pref_ = global_preferences->make_preference<float>(this->
|
24
|
+
this->pref_ = global_preferences->make_preference<float>(this->get_preference_hash());
|
25
25
|
if (this->pref_.load(&value)) {
|
26
26
|
this->control_lambda_(value);
|
27
27
|
}
|
@@ -20,7 +20,7 @@ class LVGLSelect : public select::Select, public Component {
|
|
20
20
|
this->set_options_();
|
21
21
|
if (this->restore_) {
|
22
22
|
size_t index;
|
23
|
-
this->pref_ = global_preferences->make_preference<size_t>(this->
|
23
|
+
this->pref_ = global_preferences->make_preference<size_t>(this->get_preference_hash());
|
24
24
|
if (this->pref_.load(&index))
|
25
25
|
this->widget_->set_selected_index(index, LV_ANIM_OFF);
|
26
26
|
}
|
@@ -11,6 +11,7 @@ from ..defines import (
|
|
11
11
|
CONF_ROLLOVER,
|
12
12
|
CONF_SCROLLBAR,
|
13
13
|
CONF_SELECTED,
|
14
|
+
CONF_SELECTED_DIGIT,
|
14
15
|
CONF_TEXTAREA_PLACEHOLDER,
|
15
16
|
)
|
16
17
|
from ..lv_validation import lv_bool, lv_float
|
@@ -38,18 +39,24 @@ def validate_spinbox(config):
|
|
38
39
|
min_val = -1 - max_val
|
39
40
|
range_from = int(config[CONF_RANGE_FROM])
|
40
41
|
range_to = int(config[CONF_RANGE_TO])
|
41
|
-
step =
|
42
|
+
step = config[CONF_SELECTED_DIGIT]
|
43
|
+
digits = config[CONF_DIGITS]
|
42
44
|
if (
|
43
45
|
range_from > max_val
|
44
46
|
or range_from < min_val
|
45
47
|
or range_to > max_val
|
46
48
|
or range_to < min_val
|
47
49
|
):
|
48
|
-
raise cv.Invalid("Range outside allowed limits")
|
49
|
-
if
|
50
|
-
raise cv.Invalid(
|
51
|
-
|
52
|
-
|
50
|
+
raise cv.Invalid("Range outside allowed limits", path=[CONF_RANGE_FROM])
|
51
|
+
if digits <= config[CONF_DECIMAL_PLACES]:
|
52
|
+
raise cv.Invalid(
|
53
|
+
"Number of digits must exceed number of decimal places", path=[CONF_DIGITS]
|
54
|
+
)
|
55
|
+
if step >= digits:
|
56
|
+
raise cv.Invalid(
|
57
|
+
"Initial selected digit must be less than number of digits",
|
58
|
+
path=[CONF_SELECTED_DIGIT],
|
59
|
+
)
|
53
60
|
return config
|
54
61
|
|
55
62
|
|
@@ -59,7 +66,10 @@ SPINBOX_SCHEMA = cv.Schema(
|
|
59
66
|
cv.Optional(CONF_RANGE_FROM, default=0): cv.float_,
|
60
67
|
cv.Optional(CONF_RANGE_TO, default=100): cv.float_,
|
61
68
|
cv.Optional(CONF_DIGITS, default=4): cv.int_range(1, 10),
|
62
|
-
cv.Optional(CONF_STEP
|
69
|
+
cv.Optional(CONF_STEP): cv.invalid(
|
70
|
+
f"{CONF_STEP} has been replaced by {CONF_SELECTED_DIGIT}"
|
71
|
+
),
|
72
|
+
cv.Optional(CONF_SELECTED_DIGIT, default=0): cv.positive_int,
|
63
73
|
cv.Optional(CONF_DECIMAL_PLACES, default=0): cv.int_range(0, 6),
|
64
74
|
cv.Optional(CONF_ROLLOVER, default=False): lv_bool,
|
65
75
|
}
|
@@ -93,13 +103,12 @@ class SpinboxType(WidgetType):
|
|
93
103
|
scale = 10 ** config[CONF_DECIMAL_PLACES]
|
94
104
|
range_from = int(config[CONF_RANGE_FROM]) * scale
|
95
105
|
range_to = int(config[CONF_RANGE_TO]) * scale
|
96
|
-
step =
|
106
|
+
step = config[CONF_SELECTED_DIGIT]
|
97
107
|
w.scale = scale
|
98
|
-
w.step = step
|
99
108
|
w.range_to = range_to
|
100
109
|
w.range_from = range_from
|
101
110
|
lv.spinbox_set_range(w.obj, range_from, range_to)
|
102
|
-
await w.set_property(
|
111
|
+
await w.set_property("step", 10**step)
|
103
112
|
await w.set_property(CONF_ROLLOVER, config)
|
104
113
|
lv.spinbox_set_digit_format(
|
105
114
|
w.obj, digits, digits - config[CONF_DECIMAL_PLACES]
|
@@ -120,7 +129,7 @@ class SpinboxType(WidgetType):
|
|
120
129
|
return config[CONF_RANGE_FROM]
|
121
130
|
|
122
131
|
def get_step(self, config: dict):
|
123
|
-
return config[
|
132
|
+
return 10 ** config[CONF_SELECTED_DIGIT]
|
124
133
|
|
125
134
|
|
126
135
|
spinbox_spec = SpinboxType()
|
@@ -6,7 +6,7 @@ namespace m5stack_8angle {
|
|
6
6
|
void M5Stack8AngleSwitchBinarySensor::update() {
|
7
7
|
int8_t out = this->parent_->read_switch();
|
8
8
|
if (out == -1) {
|
9
|
-
this->status_set_warning("Could not read binary sensor state from M5Stack 8Angle.");
|
9
|
+
this->status_set_warning(LOG_STR("Could not read binary sensor state from M5Stack 8Angle."));
|
10
10
|
return;
|
11
11
|
}
|
12
12
|
this->publish_state(out != 0);
|
@@ -7,7 +7,7 @@ void M5Stack8AngleKnobSensor::update() {
|
|
7
7
|
if (this->parent_ != nullptr) {
|
8
8
|
int32_t raw_pos = this->parent_->read_knob_pos_raw(this->channel_, this->bits_);
|
9
9
|
if (raw_pos == -1) {
|
10
|
-
this->status_set_warning("Could not read knob position from M5Stack 8Angle.");
|
10
|
+
this->status_set_warning(LOG_STR("Could not read knob position from M5Stack 8Angle."));
|
11
11
|
return;
|
12
12
|
}
|
13
13
|
if (this->raw_) {
|
@@ -10,7 +10,8 @@ from esphome.loader import get_component
|
|
10
10
|
CODEOWNERS = ["@clydebarrow"]
|
11
11
|
MULTI_CONF = True
|
12
12
|
|
13
|
-
|
13
|
+
mapping_ns = cg.esphome_ns.namespace("mapping")
|
14
|
+
mapping_class = mapping_ns.class_("Mapping")
|
14
15
|
|
15
16
|
CONF_ENTRIES = "entries"
|
16
17
|
CONF_CLASS = "class"
|
@@ -29,7 +30,11 @@ class IndexType:
|
|
29
30
|
|
30
31
|
INDEX_TYPES = {
|
31
32
|
"int": IndexType(cv.int_, cg.int_, int),
|
32
|
-
"string": IndexType(
|
33
|
+
"string": IndexType(
|
34
|
+
cv.string,
|
35
|
+
cg.std_string,
|
36
|
+
str,
|
37
|
+
),
|
33
38
|
}
|
34
39
|
|
35
40
|
|
@@ -47,7 +52,7 @@ def to_schema(value):
|
|
47
52
|
|
48
53
|
BASE_SCHEMA = cv.Schema(
|
49
54
|
{
|
50
|
-
cv.Required(CONF_ID): cv.declare_id(
|
55
|
+
cv.Required(CONF_ID): cv.declare_id(mapping_class),
|
51
56
|
cv.Required(CONF_FROM): cv.one_of(*INDEX_TYPES, lower=True),
|
52
57
|
cv.Required(CONF_TO): cv.string,
|
53
58
|
},
|
@@ -123,12 +128,15 @@ async def to_code(config):
|
|
123
128
|
if list(entries.values())[0].op != ".":
|
124
129
|
value_type = value_type.operator("ptr")
|
125
130
|
varid = config[CONF_ID]
|
126
|
-
varid.type =
|
131
|
+
varid.type = mapping_class.template(
|
132
|
+
index_type,
|
133
|
+
value_type,
|
134
|
+
)
|
127
135
|
var = MockObj(varid, ".")
|
128
136
|
decl = VariableDeclarationExpression(varid.type, "", varid)
|
129
137
|
add_global(decl)
|
130
138
|
CORE.register_variable(varid, var)
|
131
139
|
|
132
140
|
for key, value in entries.items():
|
133
|
-
cg.add(var.
|
141
|
+
cg.add(var.set(key, value))
|
134
142
|
return var
|