HI,
I have an E1001 terminal from seeed, and want to show the user the voltage percentage directly after the E1001 coming from deep sleep and I want the Voltage itself in HomeAssistant in the statistics. The view for the user on the ePaper works.
For this reason I put the sensor measurement in the on_boot, wait for the API beeing there and than continue with my program.
My problem is, that on every wakeup after deep sleep the first value HomeAssistant gets is “0” (zero), which “kills” the nicely shown graphs.
See here one cutout of my statistic data:
The IMHO relevant part of my ESPHome yaml:
esphome:
name: ${rmgr_device_name}
friendly_name: ${rmgr_device_name}
project:
name: rmgr.room_manager
version: "1.1.7"
on_boot:
- priority: -100
then:
# make sure, we are connected to HomeAssistant
- wait_until:
condition:
api.connected:
# state_subscription_only: true
timeout: 30s
- lambda: |-
ESP_LOGI("boot", "API connected");
- lambda: |-
auto cause = esp_sleep_get_wakeup_cause();
if (cause == ESP_SLEEP_WAKEUP_EXT0 ||
cause == ESP_SLEEP_WAKEUP_EXT1) {
id(woke_by_button) = true;
ESP_LOGI("wakeup", "Woke up by BUTTON");
} else if (cause == ESP_SLEEP_WAKEUP_TIMER) {
id(woke_by_button) = false;
ESP_LOGI("wakeup", "Woke up by TIMER");
} else {
id(woke_by_button) = false;
ESP_LOGI("wakeup", "Woke up by OTHER cause (%d)", cause);
}
# --- local battery first ---
- output.turn_on: bsp_battery_enable
- delay: 100ms
- component.update: ${rmgr_device_name}_battery_voltage
# --- read battery three times and to get the correct value
# - delay: 50ms
- component.update: ${rmgr_device_name}_battery_voltage
- delay: 50ms
- component.update: ${rmgr_device_name}_battery_voltage
- delay: 50ms
- component.update: ${rmgr_device_name}_battery_voltage
- delay: 450ms
- wait_until:
condition:
# lambda: 'return id(${rmgr_device_name}_battery_voltage).has_state() && !isnan(id(${rmgr_device_name}_battery_voltage).state);'
lambda: 'return id(${rmgr_device_name}_battery_voltage).has_state() && id(${rmgr_device_name}_battery_voltage).state > 2.0;'
# lambda: 'return id(${rmgr_device_name}_battery_voltage).has_state() && !isnan(id(${rmgr_device_name}_battery_voltage).state) && id(${rmgr_device_name}_battery_voltage).state > 2.0;'
timeout: 15s
- lambda: |-
ESP_LOGI("battery", "voltage 1 %3.2f V", id(${rmgr_device_name}_battery_voltage).state);
# make sure at least a part of the calendar data is there
- script.execute: wait_for_valid_a
- component.update: ${rmgr_device_name}_battery_level
- wait_until:
condition:
lambda: 'return id(${rmgr_device_name}_battery_level).has_state() && !isnan(id(${rmgr_device_name}_battery_level).state);'
timeout: 2s
- wait_until:
condition:
lambda: 'return id(ha_time).now().is_valid();'
timeout: 2s
- component.update: ${rmgr_device_name}_wifi_strength
- wait_until:
condition:
lambda: 'return id(${rmgr_device_name}_wifi_strength).has_state() && !isnan(id(${rmgr_device_name}_wifi_strength).state);'
timeout: 2s
- wait_until:
condition:
lambda: |-
return id(rmgr_today_valid_a).has_state();
timeout: 2s
- lambda: |-
ESP_LOGI("boot", "before screenWrite");
- component.update: screenWrite
- lambda: |-
ESP_LOGI("boot", "after screenWrite");
- if:
condition:
binary_sensor.is_on: ${rmgr_device_name}_connected
then:
- if:
condition:
lambda: 'return id(woke_by_button);'
then:
- script.execute: beep
else:
- script.execute: silent_beep
# 1 minute Wakeup time, where the users can interact
- lambda: |-
ESP_LOGI("boot", "before delay 1 min ");
- delay: 1min
- lambda: |-
ESP_LOGI("boot", "before go_to_sleep_screen_then_sleep");
- script.execute: go_to_sleep_screen_then_sleep
I do not understand why this
lambda: 'return id(${rmgr_device_name}_battery_voltage).has_state() && id(${rmgr_device_name}_battery_voltage).state > 2.0;'
is still delivering values below 2 to HomeAssiant.
Does anyone have any idea what I am doing wrong?
Until now I tried:
1.) more component_update of the voltage
2.) longer wait for the battery component to come up: (500ms)
- output.turn_on: bsp_battery_enable
- delay: 100ms
All with no luck. If the ESP is up and the api is there, all the data is coming as expected.
The workaround would be, not to show the battery percentage directly after boot, but only if going to sleep and find a way in HomeAssistant to ignore
${rmgr_device_name}_battery_voltage below let’s say 2.4V as the ESP would not work below this value.
How can I ignore such values in HA from a sensor? Like: I only want to “see” data in HomeAssistant from this sensor between 2 and 5 so say something.
any ideas welcome
thank you
Juergen


