Open macdivernl opened 3 days ago
All,
When I call “states.sensor.lowest_energy_price_today.attributes.from_time” it returns the time in UTC / GMT, while I’m in the Amsterdam timezone ( +2 ). In my dashboard it shows the correct time (zone) value.
Any thoughts on how to tweak to extract the local time value from this, to be able to switch power to my boiler at that time, in stead of two hours early?
Thanks / dankjewel!
Marc
I dont know if there is a other filter to convert UTC datetime to local but this will work It converts the datetime to a timestamp and then converts it to local datetime
{{ as_timestamp(states.sensor.lowest_energy_price_today.attributes.from_time) | timestamp_local}}
output: 2024-06-29T13:00:00+02:00
{{ as_timestamp(state_attr('sensor.lowest_energy_price_today', 'from_time')) | timestamp_local }}
output: 2024-06-29T13:00:00+02:00
{{ state_attr('sensor.lowest_energy_price_today', 'from_time') }}
output: 2024-06-29 11:00:00+00:00
or
{{ as_timestamp(state_attr('sensor.lowest_energy_price_today', 'from_time')) | timestamp_custom('%Y-%m-%d %H:%M:%S', true) }}
output: 2024-06-29 13:00:00
of output in nederlands format: (The true parameter specifies local time conversion.)
{{ as_timestamp(state_attr('sensor.lowest_energy_price_today', 'from_time')) | timestamp_custom('%d-%m-%Y %H:%M:%S', true) }}
output: 29-06-2024 13:00:00
as_local did it for me, thanks.
[ message: " Goedkoop begint om {{as_local(states.sensor.lowest_energy_price_today.attributes.from_time).strftime('%H:%M')}}u en is € {{states.sensor.lowest_energy_price_today.state}}."
(Running as a physical instance on a Raspberry Pi)
{{as_local(states.sensor.lowest_energy_price_today.attributes.from_time).strftime('%H:%M')}}
Nice.. I tried as_local but at the end and that did not work
All,
When I call “states.sensor.lowest_energy_price_today.attributes.from_time” it returns the time in UTC / GMT, while I’m in the Amsterdam timezone ( +2 ). In my dashboard it shows the correct time (zone) value.
Any thoughts on how to tweak to extract the local time value from this, to be able to switch power to my boiler at that time, in stead of two hours early?
Thanks / dankjewel!
Marc