esphome 2025.8.4__py3-none-any.whl → 2025.9.0b2__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/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 +7 -2
- esphome/components/ethernet/ethernet_component.cpp +49 -3
- esphome/components/ethernet/ethernet_component.h +2 -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_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.h +2 -2
- 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 +4 -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 +67 -10
- esphome/espota2.py +13 -6
- esphome/helpers.py +68 -83
- esphome/resolver.py +67 -0
- esphome/util.py +9 -6
- esphome/wizard.py +39 -26
- {esphome-2025.8.4.dist-info → esphome-2025.9.0b2.dist-info}/METADATA +9 -9
- {esphome-2025.8.4.dist-info → esphome-2025.9.0b2.dist-info}/RECORD +364 -333
- /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.0b2.dist-info}/WHEEL +0 -0
- {esphome-2025.8.4.dist-info → esphome-2025.9.0b2.dist-info}/entry_points.txt +0 -0
- {esphome-2025.8.4.dist-info → esphome-2025.9.0b2.dist-info}/licenses/LICENSE +0 -0
- {esphome-2025.8.4.dist-info → esphome-2025.9.0b2.dist-info}/top_level.txt +0 -0
@@ -15,11 +15,11 @@ namespace safe_mode {
|
|
15
15
|
static const char *const TAG = "safe_mode";
|
16
16
|
|
17
17
|
void SafeModeComponent::dump_config() {
|
18
|
-
ESP_LOGCONFIG(TAG, "Safe Mode:");
|
19
18
|
ESP_LOGCONFIG(TAG,
|
20
|
-
"
|
21
|
-
"
|
22
|
-
"
|
19
|
+
"Safe Mode:\n"
|
20
|
+
" Successful after: %" PRIu32 "s\n"
|
21
|
+
" Invoke after: %u attempts\n"
|
22
|
+
" Duration: %" PRIu32 "s",
|
23
23
|
this->safe_mode_boot_is_good_after_ / 1000, // because milliseconds
|
24
24
|
this->safe_mode_num_attempts_,
|
25
25
|
this->safe_mode_enable_time_ / 1000); // because milliseconds
|
@@ -27,7 +27,7 @@ void SafeModeComponent::dump_config() {
|
|
27
27
|
if (this->safe_mode_rtc_value_ > 1 && this->safe_mode_rtc_value_ != SafeModeComponent::ENTER_SAFE_MODE_MAGIC) {
|
28
28
|
auto remaining_restarts = this->safe_mode_num_attempts_ - this->safe_mode_rtc_value_;
|
29
29
|
if (remaining_restarts) {
|
30
|
-
ESP_LOGW(TAG, "Last reset
|
30
|
+
ESP_LOGW(TAG, "Last reset too quick; invoke in %" PRIu32 " restarts", remaining_restarts);
|
31
31
|
} else {
|
32
32
|
ESP_LOGW(TAG, "SAFE MODE IS ACTIVE");
|
33
33
|
}
|
@@ -72,43 +72,45 @@ bool SafeModeComponent::should_enter_safe_mode(uint8_t num_attempts, uint32_t en
|
|
72
72
|
this->safe_mode_boot_is_good_after_ = boot_is_good_after;
|
73
73
|
this->safe_mode_num_attempts_ = num_attempts;
|
74
74
|
this->rtc_ = global_preferences->make_preference<uint32_t>(233825507UL, false);
|
75
|
-
this->safe_mode_rtc_value_ = this->read_rtc_();
|
76
75
|
|
77
|
-
|
76
|
+
uint32_t rtc_val = this->read_rtc_();
|
77
|
+
this->safe_mode_rtc_value_ = rtc_val;
|
78
78
|
|
79
|
-
|
80
|
-
|
79
|
+
bool is_manual = rtc_val == SafeModeComponent::ENTER_SAFE_MODE_MAGIC;
|
80
|
+
|
81
|
+
if (is_manual) {
|
82
|
+
ESP_LOGI(TAG, "Manual mode");
|
81
83
|
} else {
|
82
|
-
ESP_LOGCONFIG(TAG, "
|
84
|
+
ESP_LOGCONFIG(TAG, "Unsuccessful boot attempts: %" PRIu32, rtc_val);
|
83
85
|
}
|
84
86
|
|
85
|
-
if (
|
86
|
-
|
87
|
+
if (rtc_val < num_attempts && !is_manual) {
|
88
|
+
// increment counter
|
89
|
+
this->write_rtc_(rtc_val + 1);
|
90
|
+
return false;
|
91
|
+
}
|
87
92
|
|
88
|
-
|
89
|
-
ESP_LOGE(TAG, "Boot loop detected. Proceeding");
|
90
|
-
}
|
93
|
+
this->clean_rtc();
|
91
94
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
App.reboot();
|
96
|
-
});
|
95
|
+
if (!is_manual) {
|
96
|
+
ESP_LOGE(TAG, "Boot loop detected");
|
97
|
+
}
|
97
98
|
|
98
|
-
|
99
|
-
|
100
|
-
|
99
|
+
this->status_set_error();
|
100
|
+
this->set_timeout(enable_time, []() {
|
101
|
+
ESP_LOGW(TAG, "Timeout, restarting");
|
102
|
+
App.reboot();
|
103
|
+
});
|
101
104
|
|
102
|
-
|
105
|
+
// Delay here to allow power to stabilize before Wi-Fi/Ethernet is initialised
|
106
|
+
delay(300); // NOLINT
|
107
|
+
App.setup();
|
103
108
|
|
104
|
-
|
109
|
+
ESP_LOGW(TAG, "SAFE MODE IS ACTIVE");
|
105
110
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
this->write_rtc_(this->safe_mode_rtc_value_ + 1);
|
110
|
-
return false;
|
111
|
-
}
|
111
|
+
this->safe_mode_callback_.call();
|
112
|
+
|
113
|
+
return true;
|
112
114
|
}
|
113
115
|
|
114
116
|
void SafeModeComponent::write_rtc_(uint32_t val) {
|
@@ -6,9 +6,15 @@ namespace script {
|
|
6
6
|
|
7
7
|
static const char *const TAG = "script";
|
8
8
|
|
9
|
+
#ifdef USE_STORE_LOG_STR_IN_FLASH
|
10
|
+
void ScriptLogger::esp_log_(int level, int line, const __FlashStringHelper *format, const char *param) {
|
11
|
+
esp_log_printf_(level, TAG, line, format, param);
|
12
|
+
}
|
13
|
+
#else
|
9
14
|
void ScriptLogger::esp_log_(int level, int line, const char *format, const char *param) {
|
10
15
|
esp_log_printf_(level, TAG, line, format, param);
|
11
16
|
}
|
17
|
+
#endif
|
12
18
|
|
13
19
|
} // namespace script
|
14
20
|
} // namespace esphome
|
@@ -10,6 +10,15 @@ namespace script {
|
|
10
10
|
|
11
11
|
class ScriptLogger {
|
12
12
|
protected:
|
13
|
+
#ifdef USE_STORE_LOG_STR_IN_FLASH
|
14
|
+
void esp_logw_(int line, const __FlashStringHelper *format, const char *param) {
|
15
|
+
esp_log_(ESPHOME_LOG_LEVEL_WARN, line, format, param);
|
16
|
+
}
|
17
|
+
void esp_logd_(int line, const __FlashStringHelper *format, const char *param) {
|
18
|
+
esp_log_(ESPHOME_LOG_LEVEL_DEBUG, line, format, param);
|
19
|
+
}
|
20
|
+
void esp_log_(int level, int line, const __FlashStringHelper *format, const char *param);
|
21
|
+
#else
|
13
22
|
void esp_logw_(int line, const char *format, const char *param) {
|
14
23
|
esp_log_(ESPHOME_LOG_LEVEL_WARN, line, format, param);
|
15
24
|
}
|
@@ -17,6 +26,7 @@ class ScriptLogger {
|
|
17
26
|
esp_log_(ESPHOME_LOG_LEVEL_DEBUG, line, format, param);
|
18
27
|
}
|
19
28
|
void esp_log_(int level, int line, const char *format, const char *param);
|
29
|
+
#endif
|
20
30
|
};
|
21
31
|
|
22
32
|
/// The abstract base class for all script types.
|
@@ -57,7 +67,8 @@ template<typename... Ts> class SingleScript : public Script<Ts...> {
|
|
57
67
|
public:
|
58
68
|
void execute(Ts... x) override {
|
59
69
|
if (this->is_action_running()) {
|
60
|
-
this->esp_logw_(__LINE__, "Script '%s' is already running! (mode: single)",
|
70
|
+
this->esp_logw_(__LINE__, ESPHOME_LOG_FORMAT("Script '%s' is already running! (mode: single)"),
|
71
|
+
this->name_.c_str());
|
61
72
|
return;
|
62
73
|
}
|
63
74
|
|
@@ -74,7 +85,7 @@ template<typename... Ts> class RestartScript : public Script<Ts...> {
|
|
74
85
|
public:
|
75
86
|
void execute(Ts... x) override {
|
76
87
|
if (this->is_action_running()) {
|
77
|
-
this->esp_logd_(__LINE__, "Script '%s' restarting (mode: restart)", this->name_.c_str());
|
88
|
+
this->esp_logd_(__LINE__, ESPHOME_LOG_FORMAT("Script '%s' restarting (mode: restart)"), this->name_.c_str());
|
78
89
|
this->stop_action();
|
79
90
|
}
|
80
91
|
|
@@ -93,11 +104,13 @@ template<typename... Ts> class QueueingScript : public Script<Ts...>, public Com
|
|
93
104
|
// num_runs_ is the number of *queued* instances, so total number of instances is
|
94
105
|
// num_runs_ + 1
|
95
106
|
if (this->max_runs_ != 0 && this->num_runs_ + 1 >= this->max_runs_) {
|
96
|
-
this->esp_logw_(__LINE__, "Script '%s' maximum number of queued runs exceeded!",
|
107
|
+
this->esp_logw_(__LINE__, ESPHOME_LOG_FORMAT("Script '%s' maximum number of queued runs exceeded!"),
|
108
|
+
this->name_.c_str());
|
97
109
|
return;
|
98
110
|
}
|
99
111
|
|
100
|
-
this->esp_logd_(__LINE__, "Script '%s' queueing new instance (mode: queued)",
|
112
|
+
this->esp_logd_(__LINE__, ESPHOME_LOG_FORMAT("Script '%s' queueing new instance (mode: queued)"),
|
113
|
+
this->name_.c_str());
|
101
114
|
this->num_runs_++;
|
102
115
|
this->var_queue_.push(std::make_tuple(x...));
|
103
116
|
return;
|
@@ -143,7 +156,8 @@ template<typename... Ts> class ParallelScript : public Script<Ts...> {
|
|
143
156
|
public:
|
144
157
|
void execute(Ts... x) override {
|
145
158
|
if (this->max_runs_ != 0 && this->automation_parent_->num_running() >= this->max_runs_) {
|
146
|
-
this->esp_logw_(__LINE__, "Script '%s' maximum number of parallel runs exceeded!",
|
159
|
+
this->esp_logw_(__LINE__, ESPHOME_LOG_FORMAT("Script '%s' maximum number of parallel runs exceeded!"),
|
160
|
+
this->name_.c_str());
|
147
161
|
return;
|
148
162
|
}
|
149
163
|
this->trigger(x...);
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import esphome.codegen as cg
|
2
2
|
from esphome.components import modbus, sensor
|
3
|
-
from esphome.components.atm90e32.sensor import CONF_PHASE_A, CONF_PHASE_B, CONF_PHASE_C
|
4
3
|
import esphome.config_validation as cv
|
5
4
|
from esphome.const import (
|
6
5
|
CONF_ACTIVE_POWER,
|
@@ -12,7 +11,10 @@ from esphome.const import (
|
|
12
11
|
CONF_ID,
|
13
12
|
CONF_IMPORT_ACTIVE_ENERGY,
|
14
13
|
CONF_IMPORT_REACTIVE_ENERGY,
|
14
|
+
CONF_PHASE_A,
|
15
15
|
CONF_PHASE_ANGLE,
|
16
|
+
CONF_PHASE_B,
|
17
|
+
CONF_PHASE_C,
|
16
18
|
CONF_POWER_FACTOR,
|
17
19
|
CONF_REACTIVE_POWER,
|
18
20
|
CONF_TOTAL_POWER,
|
@@ -16,7 +16,7 @@ from esphome.const import (
|
|
16
16
|
CONF_TRIGGER_ID,
|
17
17
|
CONF_WEB_SERVER,
|
18
18
|
)
|
19
|
-
from esphome.core import CORE, coroutine_with_priority
|
19
|
+
from esphome.core import CORE, CoroPriority, coroutine_with_priority
|
20
20
|
from esphome.core.entity_helpers import entity_duplicate_validator, setup_entity
|
21
21
|
from esphome.cpp_generator import MockObjClass
|
22
22
|
|
@@ -124,7 +124,7 @@ async def new_select(config, *args, options: list[str]):
|
|
124
124
|
return var
|
125
125
|
|
126
126
|
|
127
|
-
@coroutine_with_priority(
|
127
|
+
@coroutine_with_priority(CoroPriority.CORE)
|
128
128
|
async def to_code(config):
|
129
129
|
cg.add_global(select_ns.using)
|
130
130
|
|
@@ -12,8 +12,8 @@ namespace select {
|
|
12
12
|
#define LOG_SELECT(prefix, type, obj) \
|
13
13
|
if ((obj) != nullptr) { \
|
14
14
|
ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
|
15
|
-
if (!(obj)->
|
16
|
-
ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->
|
15
|
+
if (!(obj)->get_icon_ref().empty()) { \
|
16
|
+
ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon_ref().c_str()); \
|
17
17
|
} \
|
18
18
|
}
|
19
19
|
|
@@ -29,6 +29,19 @@ static const int8_t SEN5X_INDEX_SCALE_FACTOR = 10; //
|
|
29
29
|
static const int8_t SEN5X_MIN_INDEX_VALUE = 1 * SEN5X_INDEX_SCALE_FACTOR; // must be adjusted by the scale factor
|
30
30
|
static const int16_t SEN5X_MAX_INDEX_VALUE = 500 * SEN5X_INDEX_SCALE_FACTOR; // must be adjusted by the scale factor
|
31
31
|
|
32
|
+
static const LogString *rht_accel_mode_to_string(RhtAccelerationMode mode) {
|
33
|
+
switch (mode) {
|
34
|
+
case LOW_ACCELERATION:
|
35
|
+
return LOG_STR("LOW");
|
36
|
+
case MEDIUM_ACCELERATION:
|
37
|
+
return LOG_STR("MEDIUM");
|
38
|
+
case HIGH_ACCELERATION:
|
39
|
+
return LOG_STR("HIGH");
|
40
|
+
default:
|
41
|
+
return LOG_STR("UNKNOWN");
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
32
45
|
void SEN5XComponent::setup() {
|
33
46
|
// the sensor needs 1000 ms to enter the idle state
|
34
47
|
this->set_timeout(1000, [this]() {
|
@@ -50,7 +63,7 @@ void SEN5XComponent::setup() {
|
|
50
63
|
uint32_t stop_measurement_delay = 0;
|
51
64
|
// In order to query the device periodic measurement must be ceased
|
52
65
|
if (raw_read_status) {
|
53
|
-
ESP_LOGD(TAG, "
|
66
|
+
ESP_LOGD(TAG, "Data is available; stopping periodic measurement");
|
54
67
|
if (!this->write_command(SEN5X_CMD_STOP_MEASUREMENTS)) {
|
55
68
|
ESP_LOGE(TAG, "Failed to stop measurements");
|
56
69
|
this->mark_failed();
|
@@ -71,7 +84,8 @@ void SEN5XComponent::setup() {
|
|
71
84
|
this->serial_number_[0] = static_cast<bool>(uint16_t(raw_serial_number[0]) & 0xFF);
|
72
85
|
this->serial_number_[1] = static_cast<uint16_t>(raw_serial_number[0] & 0xFF);
|
73
86
|
this->serial_number_[2] = static_cast<uint16_t>(raw_serial_number[1] >> 8);
|
74
|
-
|
87
|
+
ESP_LOGV(TAG, "Serial number %02d.%02d.%02d", this->serial_number_[0], this->serial_number_[1],
|
88
|
+
this->serial_number_[2]);
|
75
89
|
|
76
90
|
uint16_t raw_product_name[16];
|
77
91
|
if (!this->get_register(SEN5X_CMD_GET_PRODUCT_NAME, raw_product_name, 16, 20)) {
|
@@ -88,45 +102,43 @@ void SEN5XComponent::setup() {
|
|
88
102
|
// first char
|
89
103
|
current_char = *current_int >> 8;
|
90
104
|
if (current_char) {
|
91
|
-
product_name_.push_back(current_char);
|
105
|
+
this->product_name_.push_back(current_char);
|
92
106
|
// second char
|
93
107
|
current_char = *current_int & 0xFF;
|
94
108
|
if (current_char) {
|
95
|
-
product_name_.push_back(current_char);
|
109
|
+
this->product_name_.push_back(current_char);
|
96
110
|
}
|
97
111
|
}
|
98
112
|
current_int++;
|
99
113
|
} while (current_char && --max);
|
100
114
|
|
101
115
|
Sen5xType sen5x_type = UNKNOWN;
|
102
|
-
if (product_name_ == "SEN50") {
|
116
|
+
if (this->product_name_ == "SEN50") {
|
103
117
|
sen5x_type = SEN50;
|
104
118
|
} else {
|
105
|
-
if (product_name_ == "SEN54") {
|
119
|
+
if (this->product_name_ == "SEN54") {
|
106
120
|
sen5x_type = SEN54;
|
107
121
|
} else {
|
108
|
-
if (product_name_ == "SEN55") {
|
122
|
+
if (this->product_name_ == "SEN55") {
|
109
123
|
sen5x_type = SEN55;
|
110
124
|
}
|
111
125
|
}
|
112
|
-
ESP_LOGD(TAG, "
|
126
|
+
ESP_LOGD(TAG, "Product name: %s", this->product_name_.c_str());
|
113
127
|
}
|
114
128
|
if (this->humidity_sensor_ && sen5x_type == SEN50) {
|
115
|
-
ESP_LOGE(TAG, "
|
116
|
-
this->product_name_.c_str());
|
129
|
+
ESP_LOGE(TAG, "Relative humidity requires a SEN54 or SEN55");
|
117
130
|
this->humidity_sensor_ = nullptr; // mark as not used
|
118
131
|
}
|
119
132
|
if (this->temperature_sensor_ && sen5x_type == SEN50) {
|
120
|
-
ESP_LOGE(TAG, "
|
121
|
-
this->product_name_.c_str());
|
133
|
+
ESP_LOGE(TAG, "Temperature requires a SEN54 or SEN55");
|
122
134
|
this->temperature_sensor_ = nullptr; // mark as not used
|
123
135
|
}
|
124
136
|
if (this->voc_sensor_ && sen5x_type == SEN50) {
|
125
|
-
ESP_LOGE(TAG, "
|
137
|
+
ESP_LOGE(TAG, "VOC requires a SEN54 or SEN55");
|
126
138
|
this->voc_sensor_ = nullptr; // mark as not used
|
127
139
|
}
|
128
140
|
if (this->nox_sensor_ && sen5x_type != SEN55) {
|
129
|
-
ESP_LOGE(TAG, "
|
141
|
+
ESP_LOGE(TAG, "NOx requires a SEN55");
|
130
142
|
this->nox_sensor_ = nullptr; // mark as not used
|
131
143
|
}
|
132
144
|
|
@@ -137,7 +149,7 @@ void SEN5XComponent::setup() {
|
|
137
149
|
return;
|
138
150
|
}
|
139
151
|
this->firmware_version_ >>= 8;
|
140
|
-
|
152
|
+
ESP_LOGV(TAG, "Firmware version %d", this->firmware_version_);
|
141
153
|
|
142
154
|
if (this->voc_sensor_ && this->store_baseline_) {
|
143
155
|
uint32_t combined_serial =
|
@@ -150,7 +162,7 @@ void SEN5XComponent::setup() {
|
|
150
162
|
|
151
163
|
if (this->pref_.load(&this->voc_baselines_storage_)) {
|
152
164
|
ESP_LOGI(TAG, "Loaded VOC baseline state0: 0x%04" PRIX32 ", state1: 0x%04" PRIX32,
|
153
|
-
this->voc_baselines_storage_.state0, voc_baselines_storage_.state1);
|
165
|
+
this->voc_baselines_storage_.state0, this->voc_baselines_storage_.state1);
|
154
166
|
}
|
155
167
|
|
156
168
|
// Initialize storage timestamp
|
@@ -158,13 +170,13 @@ void SEN5XComponent::setup() {
|
|
158
170
|
|
159
171
|
if (this->voc_baselines_storage_.state0 > 0 && this->voc_baselines_storage_.state1 > 0) {
|
160
172
|
ESP_LOGI(TAG, "Setting VOC baseline from save state0: 0x%04" PRIX32 ", state1: 0x%04" PRIX32,
|
161
|
-
this->voc_baselines_storage_.state0, voc_baselines_storage_.state1);
|
173
|
+
this->voc_baselines_storage_.state0, this->voc_baselines_storage_.state1);
|
162
174
|
uint16_t states[4];
|
163
175
|
|
164
|
-
states[0] = voc_baselines_storage_.state0 >> 16;
|
165
|
-
states[1] = voc_baselines_storage_.state0 & 0xFFFF;
|
166
|
-
states[2] = voc_baselines_storage_.state1 >> 16;
|
167
|
-
states[3] = voc_baselines_storage_.state1 & 0xFFFF;
|
176
|
+
states[0] = this->voc_baselines_storage_.state0 >> 16;
|
177
|
+
states[1] = this->voc_baselines_storage_.state0 & 0xFFFF;
|
178
|
+
states[2] = this->voc_baselines_storage_.state1 >> 16;
|
179
|
+
states[3] = this->voc_baselines_storage_.state1 & 0xFFFF;
|
168
180
|
|
169
181
|
if (!this->write_command(SEN5X_CMD_VOC_ALGORITHM_STATE, states, 4)) {
|
170
182
|
ESP_LOGE(TAG, "Failed to set VOC baseline from saved state");
|
@@ -182,11 +194,11 @@ void SEN5XComponent::setup() {
|
|
182
194
|
delay(20);
|
183
195
|
uint16_t secs[2];
|
184
196
|
if (this->read_data(secs, 2)) {
|
185
|
-
auto_cleaning_interval_ = secs[0] << 16 | secs[1];
|
197
|
+
this->auto_cleaning_interval_ = secs[0] << 16 | secs[1];
|
186
198
|
}
|
187
199
|
}
|
188
|
-
if (acceleration_mode_.has_value()) {
|
189
|
-
result = this->write_command(SEN5X_CMD_RHT_ACCELERATION_MODE, acceleration_mode_.value());
|
200
|
+
if (this->acceleration_mode_.has_value()) {
|
201
|
+
result = this->write_command(SEN5X_CMD_RHT_ACCELERATION_MODE, this->acceleration_mode_.value());
|
190
202
|
} else {
|
191
203
|
result = this->write_command(SEN5X_CMD_RHT_ACCELERATION_MODE);
|
192
204
|
}
|
@@ -197,7 +209,7 @@ void SEN5XComponent::setup() {
|
|
197
209
|
return;
|
198
210
|
}
|
199
211
|
delay(20);
|
200
|
-
if (!acceleration_mode_.has_value()) {
|
212
|
+
if (!this->acceleration_mode_.has_value()) {
|
201
213
|
uint16_t mode;
|
202
214
|
if (this->read_data(mode)) {
|
203
215
|
this->acceleration_mode_ = RhtAccelerationMode(mode);
|
@@ -227,19 +239,18 @@ void SEN5XComponent::setup() {
|
|
227
239
|
}
|
228
240
|
|
229
241
|
if (!this->write_command(cmd)) {
|
230
|
-
ESP_LOGE(TAG, "Error starting continuous measurements
|
242
|
+
ESP_LOGE(TAG, "Error starting continuous measurements");
|
231
243
|
this->error_code_ = MEASUREMENT_INIT_FAILED;
|
232
244
|
this->mark_failed();
|
233
245
|
return;
|
234
246
|
}
|
235
|
-
initialized_ = true;
|
236
|
-
ESP_LOGD(TAG, "Sensor initialized");
|
247
|
+
this->initialized_ = true;
|
237
248
|
});
|
238
249
|
});
|
239
250
|
}
|
240
251
|
|
241
252
|
void SEN5XComponent::dump_config() {
|
242
|
-
ESP_LOGCONFIG(TAG, "
|
253
|
+
ESP_LOGCONFIG(TAG, "SEN5X:");
|
243
254
|
LOG_I2C_DEVICE(this);
|
244
255
|
if (this->is_failed()) {
|
245
256
|
switch (this->error_code_) {
|
@@ -247,16 +258,16 @@ void SEN5XComponent::dump_config() {
|
|
247
258
|
ESP_LOGW(TAG, ESP_LOG_MSG_COMM_FAIL);
|
248
259
|
break;
|
249
260
|
case MEASUREMENT_INIT_FAILED:
|
250
|
-
ESP_LOGW(TAG, "Measurement
|
261
|
+
ESP_LOGW(TAG, "Measurement initialization failed");
|
251
262
|
break;
|
252
263
|
case SERIAL_NUMBER_IDENTIFICATION_FAILED:
|
253
|
-
ESP_LOGW(TAG, "Unable to read
|
264
|
+
ESP_LOGW(TAG, "Unable to read serial ID");
|
254
265
|
break;
|
255
266
|
case PRODUCT_NAME_FAILED:
|
256
267
|
ESP_LOGW(TAG, "Unable to read product name");
|
257
268
|
break;
|
258
269
|
case FIRMWARE_FAILED:
|
259
|
-
ESP_LOGW(TAG, "Unable to read
|
270
|
+
ESP_LOGW(TAG, "Unable to read firmware version");
|
260
271
|
break;
|
261
272
|
default:
|
262
273
|
ESP_LOGW(TAG, "Unknown setup error");
|
@@ -264,26 +275,17 @@ void SEN5XComponent::dump_config() {
|
|
264
275
|
}
|
265
276
|
}
|
266
277
|
ESP_LOGCONFIG(TAG,
|
267
|
-
"
|
278
|
+
" Product name: %s\n"
|
268
279
|
" Firmware version: %d\n"
|
269
280
|
" Serial number %02d.%02d.%02d",
|
270
|
-
this->product_name_.c_str(), this->firmware_version_, serial_number_[0], serial_number_[1],
|
271
|
-
serial_number_[2]);
|
281
|
+
this->product_name_.c_str(), this->firmware_version_, this->serial_number_[0], this->serial_number_[1],
|
282
|
+
this->serial_number_[2]);
|
272
283
|
if (this->auto_cleaning_interval_.has_value()) {
|
273
|
-
ESP_LOGCONFIG(TAG, " Auto cleaning interval %" PRId32 "
|
284
|
+
ESP_LOGCONFIG(TAG, " Auto cleaning interval: %" PRId32 "s", this->auto_cleaning_interval_.value());
|
274
285
|
}
|
275
286
|
if (this->acceleration_mode_.has_value()) {
|
276
|
-
|
277
|
-
|
278
|
-
ESP_LOGCONFIG(TAG, " Low RH/T acceleration mode");
|
279
|
-
break;
|
280
|
-
case MEDIUM_ACCELERATION:
|
281
|
-
ESP_LOGCONFIG(TAG, " Medium RH/T acceleration mode");
|
282
|
-
break;
|
283
|
-
case HIGH_ACCELERATION:
|
284
|
-
ESP_LOGCONFIG(TAG, " High RH/T acceleration mode");
|
285
|
-
break;
|
286
|
-
}
|
287
|
+
ESP_LOGCONFIG(TAG, " RH/T acceleration mode: %s",
|
288
|
+
LOG_STR_ARG(rht_accel_mode_to_string(this->acceleration_mode_.value())));
|
287
289
|
}
|
288
290
|
LOG_UPDATE_INTERVAL(this);
|
289
291
|
LOG_SENSOR(" ", "PM 1.0", this->pm_1_0_sensor_);
|
@@ -297,7 +299,7 @@ void SEN5XComponent::dump_config() {
|
|
297
299
|
}
|
298
300
|
|
299
301
|
void SEN5XComponent::update() {
|
300
|
-
if (!initialized_) {
|
302
|
+
if (!this->initialized_) {
|
301
303
|
return;
|
302
304
|
}
|
303
305
|
|
@@ -320,8 +322,8 @@ void SEN5XComponent::update() {
|
|
320
322
|
this->voc_baselines_storage_.state1 = state1;
|
321
323
|
|
322
324
|
if (this->pref_.save(&this->voc_baselines_storage_)) {
|
323
|
-
ESP_LOGI(TAG, "Stored VOC baseline state0: 0x%04" PRIX32 "
|
324
|
-
this->voc_baselines_storage_.state0, voc_baselines_storage_.state1);
|
325
|
+
ESP_LOGI(TAG, "Stored VOC baseline state0: 0x%04" PRIX32 ", state1: 0x%04" PRIX32,
|
326
|
+
this->voc_baselines_storage_.state0, this->voc_baselines_storage_.state1);
|
325
327
|
} else {
|
326
328
|
ESP_LOGW(TAG, "Could not store VOC baselines");
|
327
329
|
}
|
@@ -333,7 +335,7 @@ void SEN5XComponent::update() {
|
|
333
335
|
|
334
336
|
if (!this->write_command(SEN5X_CMD_READ_MEASUREMENT)) {
|
335
337
|
this->status_set_warning();
|
336
|
-
ESP_LOGD(TAG, "
|
338
|
+
ESP_LOGD(TAG, "Write error: read measurement (%d)", this->last_error_);
|
337
339
|
return;
|
338
340
|
}
|
339
341
|
this->set_timeout(20, [this]() {
|
@@ -341,7 +343,7 @@ void SEN5XComponent::update() {
|
|
341
343
|
|
342
344
|
if (!this->read_data(measurements, 8)) {
|
343
345
|
this->status_set_warning();
|
344
|
-
ESP_LOGD(TAG, "
|
346
|
+
ESP_LOGD(TAG, "Read data error (%d)", this->last_error_);
|
345
347
|
return;
|
346
348
|
}
|
347
349
|
|
@@ -413,7 +415,7 @@ bool SEN5XComponent::write_tuning_parameters_(uint16_t i2c_command, const GasTun
|
|
413
415
|
params[5] = tuning.gain_factor;
|
414
416
|
auto result = write_command(i2c_command, params, 6);
|
415
417
|
if (!result) {
|
416
|
-
ESP_LOGE(TAG, "
|
418
|
+
ESP_LOGE(TAG, "Set tuning parameters failed (command=%0xX, err=%d)", i2c_command, this->last_error_);
|
417
419
|
}
|
418
420
|
return result;
|
419
421
|
}
|
@@ -424,7 +426,7 @@ bool SEN5XComponent::write_temperature_compensation_(const TemperatureCompensati
|
|
424
426
|
params[1] = compensation.normalized_offset_slope;
|
425
427
|
params[2] = compensation.time_constant;
|
426
428
|
if (!write_command(SEN5X_CMD_TEMPERATURE_COMPENSATION, params, 3)) {
|
427
|
-
ESP_LOGE(TAG, "
|
429
|
+
ESP_LOGE(TAG, "Set temperature_compensation failed (%d)", this->last_error_);
|
428
430
|
return false;
|
429
431
|
}
|
430
432
|
return true;
|
@@ -433,7 +435,7 @@ bool SEN5XComponent::write_temperature_compensation_(const TemperatureCompensati
|
|
433
435
|
bool SEN5XComponent::start_fan_cleaning() {
|
434
436
|
if (!write_command(SEN5X_CMD_START_CLEANING_FAN)) {
|
435
437
|
this->status_set_warning();
|
436
|
-
ESP_LOGE(TAG, "
|
438
|
+
ESP_LOGE(TAG, "Start fan cleaning failed (%d)", this->last_error_);
|
437
439
|
return false;
|
438
440
|
} else {
|
439
441
|
ESP_LOGD(TAG, "Fan auto clean started");
|
esphome/components/sen5x/sen5x.h
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
namespace esphome {
|
10
10
|
namespace sen5x {
|
11
11
|
|
12
|
-
enum ERRORCODE {
|
12
|
+
enum ERRORCODE : uint8_t {
|
13
13
|
COMMUNICATION_FAILED,
|
14
14
|
SERIAL_NUMBER_IDENTIFICATION_FAILED,
|
15
15
|
MEASUREMENT_INIT_FAILED,
|
@@ -18,19 +18,17 @@ enum ERRORCODE {
|
|
18
18
|
UNKNOWN
|
19
19
|
};
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
enum RhtAccelerationMode : uint16_t {
|
22
|
+
LOW_ACCELERATION = 0,
|
23
|
+
MEDIUM_ACCELERATION = 1,
|
24
|
+
HIGH_ACCELERATION = 2,
|
25
|
+
};
|
26
26
|
|
27
27
|
struct Sen5xBaselines {
|
28
28
|
int32_t state0;
|
29
29
|
int32_t state1;
|
30
30
|
} PACKED; // NOLINT
|
31
31
|
|
32
|
-
enum RhtAccelerationMode : uint16_t { LOW_ACCELERATION = 0, MEDIUM_ACCELERATION = 1, HIGH_ACCELERATION = 2 };
|
33
|
-
|
34
32
|
struct GasTuning {
|
35
33
|
uint16_t index_offset;
|
36
34
|
uint16_t learning_time_offset_hours;
|
@@ -46,6 +44,12 @@ struct TemperatureCompensation {
|
|
46
44
|
uint16_t time_constant;
|
47
45
|
};
|
48
46
|
|
47
|
+
// Shortest time interval of 3H for storing baseline values.
|
48
|
+
// Prevents wear of the flash because of too many write operations
|
49
|
+
static const uint32_t SHORTEST_BASELINE_STORE_INTERVAL = 10800;
|
50
|
+
// Store anyway if the baseline difference exceeds the max storage diff value
|
51
|
+
static const uint32_t MAXIMUM_STORAGE_DIFF = 50;
|
52
|
+
|
49
53
|
class SEN5XComponent : public PollingComponent, public sensirion_common::SensirionI2CDevice {
|
50
54
|
public:
|
51
55
|
void setup() override;
|
@@ -102,8 +106,14 @@ class SEN5XComponent : public PollingComponent, public sensirion_common::Sensiri
|
|
102
106
|
protected:
|
103
107
|
bool write_tuning_parameters_(uint16_t i2c_command, const GasTuning &tuning);
|
104
108
|
bool write_temperature_compensation_(const TemperatureCompensation &compensation);
|
109
|
+
|
110
|
+
uint32_t seconds_since_last_store_;
|
111
|
+
uint16_t firmware_version_;
|
105
112
|
ERRORCODE error_code_;
|
113
|
+
uint8_t serial_number_[4];
|
106
114
|
bool initialized_{false};
|
115
|
+
bool store_baseline_;
|
116
|
+
|
107
117
|
sensor::Sensor *pm_1_0_sensor_{nullptr};
|
108
118
|
sensor::Sensor *pm_2_5_sensor_{nullptr};
|
109
119
|
sensor::Sensor *pm_4_0_sensor_{nullptr};
|
@@ -115,18 +125,14 @@ class SEN5XComponent : public PollingComponent, public sensirion_common::Sensiri
|
|
115
125
|
// SEN55 only
|
116
126
|
sensor::Sensor *nox_sensor_{nullptr};
|
117
127
|
|
118
|
-
std::string product_name_;
|
119
|
-
uint8_t serial_number_[4];
|
120
|
-
uint16_t firmware_version_;
|
121
|
-
Sen5xBaselines voc_baselines_storage_;
|
122
|
-
bool store_baseline_;
|
123
|
-
uint32_t seconds_since_last_store_;
|
124
|
-
ESPPreferenceObject pref_;
|
125
128
|
optional<RhtAccelerationMode> acceleration_mode_;
|
126
129
|
optional<uint32_t> auto_cleaning_interval_;
|
127
130
|
optional<GasTuning> voc_tuning_params_;
|
128
131
|
optional<GasTuning> nox_tuning_params_;
|
129
132
|
optional<TemperatureCompensation> temperature_compensation_;
|
133
|
+
ESPPreferenceObject pref_;
|
134
|
+
std::string product_name_;
|
135
|
+
Sen5xBaselines voc_baselines_storage_;
|
130
136
|
};
|
131
137
|
|
132
138
|
} // namespace sen5x
|