Be aware that with this sensor you get a state ‘unknown’ after a restart of HA. Thats the state until the next time trigger.
You can avoid the ‘unkown’ state, by adding a ‘homeassistant start’ trigger. It will be the value of that moment.
If thats not good enough, you could use the HACS ‘var’ component and use an automation to set the var value every day at 00:00. This solution is HA restart proof.
I am using code similar to this to update a sensor value. It works great the first trigger time but noticed it didn’t update the following days. When I looed in the list of entities I can see duplicates of the entity have been created. It looks like each time this is trigger it tries to create a new entity, adds a _3 or_4 or whatever the next number up is to the entity name and then stores the desired value in that new entity. Is there something I am missing in my code that is making it do this?
Sample yaml:
template:
- trigger:
- platform: time
at: "00:30:00"
sensor:
- name: "Estimate Solar Eneregy at 0030"
state: >
{{ (states('sensor.energy_production_today')) }}
unit_of_measurement: "kWh"
Looks ok. I have the same type of template sensor with as an extra the device_class defined (device_class: energy).
You could look in the log to see what happens around 00:30:00