Good morning community,
with the help of numerous threads I read here I could set up battery monitoring of my ESPhome based ESP-01 temperature sensors which was (!) working reliably until I chose to update my Home Assistant installation to v8.0 which rendered the battery monitoring unusable.
I’m monitoring the temperature and humidity updates (which are also updated every 15 min. if there’s no value change) and an automation checks if the value exceeds 3600sec. Prior to the OS and Core updates, if a sensor didn’t send an update within the last hour, an alert is sent via mail/app to check the battery. But now, this isn’t working anymore.
I used the developer tools and saw that the seconds value since the last update cycle is still calculated correctly when pasting the code from my configuration.yaml.
library_lastupdate:
friendly_name: "Sensor library last update"
value_template: >-
462
unit_of_measurement: "Seconds"
device_class: timestamp
configuration.yaml
sensor
- platform: template
sensors:
library_lastupdate:
friendly_name: "Sensor library last update"
value_template: >-
{% if states.sensor.library_temperature.last_updated > states.sensor.library_humidity.last_updated %}
{{ (as_timestamp(now()) - as_timestamp((states.sensor.library_temperature.last_updated) | default(0)) | int ) | round(0) }}
{% else %}
{{ (as_timestamp(now()) - as_timestamp((states.sensor.library_humidity.last_updated) | default(0)) | int ) | round(0) }}
{% endif %}
unit_of_measurement: "Seconds"
device_class: timestamp
This is the automation comparing the value of the sensor above to the threshold value of 3600sec.
- id: '1641394205454'
alias: 'Temperature Sensor Library (App): Battery warning'
trigger:
- platform: numeric_state
entity_id: sensor.library_lastupdate
above: '3600'
for:
hours: 0
minutes: 0
seconds: 0
milliseconds: 0
condition:
- condition: time
after: 07:00
before: '22:00'
action:
- service: notify.mobile_app_floriantelefon
data:
message: Please change battery!
title: 'Temperatur sensor library: battery empty!'
From my point of view either the sensor value is not correctly evaluated by the automation or the automation is no working correctly anymore but I know where to look at to further troubleshoot this.
Thanks a lot for any useful hints.
Florian