I have a template I only update daily, at midnight. I then use this number in other calculations. It works as expected, however I have the problem that after a restart the sensor is shown as “unavailable” until next midnight.
Here is the template sensor
- trigger: ## Daily at midnight
- platform: time
at:
- "00:00:01"
sensor:
- name: "Utility El usage Day increasingtotal temp-number"
state: >
{{ states('sensor.develco_zhemi101_f21a021b_smartenergy_metering_summation_delivered') }}
I have tried to find a way to update a helper from the sensor, as this will keep the state after a reboot, however can not figure out how
I have tried with a template that also update at restart. It works, however the number will be wrong, as it is not from midnight (will show the number from restart time)
I have tried using a utility sensor, and have the number comming form “laststate”. This works, however takes up a lot of space in the DB, for only this one small number (utility sensor will update every time the original entity updates, which is a lot)
Ideas? I can not figure out how to do this in a simple way
Easiest solution would be a automation updating a “helper”. However I can not figure out how.
Your proposed solution doesn’t work the same way as your original Trigger-based Template Sensor.
The Template Sensor updates once a day (at one minute past midnight).
The automation uses a Time Pattern Trigger that updates every minute (1440 times a day).
If you want it to work the same way, replace the Time Pattern Trigger with a Time Trigger identical to the one you used in the Trigger-based Template Sensor.