Hi,
I want to create an automation for the PICNIC integration, for creating a calendar item for the moment my order will be delivered. Very simple automation, however…
If you look at the sensor (in this example; sensor.picnic_last_order_eta_end
) I notice a ‘T’ between date and time and also notice 1 hour offset between checking the state in a template and checkling the state by opening the entry in the GUI. See screenshots below. Any thoughts???
Time offset:
And within a template, same:
m0wlheld
(Christoph Dahlen)
January 18, 2022, 8:47am
2
verguldebarman:
Any thoughts
That’s UTC time in ISO format and you can use the as_datetime
filter to get rid of the ‘T’
{{ states('sensor.picnic_last_order_eta_end') | as_datetime }}
Thanks for your quick response!
Tried that also already, result, still an offset of 1 hour…:
m0wlheld
(Christoph Dahlen)
January 18, 2022, 8:56am
4
What’s the timezone of your HA installation? UTC is GMT, CET (e.g. Europe/Berlin) is (currently) GMT/UTC + 1
m0wlheld
(Christoph Dahlen)
January 18, 2022, 9:01am
6
So, everything is corrent. The UTC time from the sensor is mapped to the local timezone when being displayed.
Yeah. I guess you are right. My problem still isn’t solved tho…
How do I create a template so {{ states(‘sensor.picnic_last_order_eta_end’) | as_datetime }}
is used in the automation in my timezone ?
As per the folowing service in my automation:
service: google.add_event
data:
calendar_id: [email protected]
start_date_time: '{{ states(''sensor.picnic_last_order_eta_start'')| as_datetime }}'
end_date_time: '{{ states(''sensor.picnic_last_order_eta_end'')| as_datetime }}'
summary: Picnic ETA
This ends up in an appointment in my Google calendar with an incorrect offset of 1 hour (1h too early)
Do you have any suggestions?
m0wlheld
(Christoph Dahlen)
January 18, 2022, 10:24am
8
try combinations with as_local
, like
"{{ states('sensor.picnic_last_order_eta_end') | as_local }}"
Yeah!!! This does the trick:
{{ states('sensor.picnic_last_order_eta_end') | as_datetime | as_local}}
1 Like