Need help to extract midle text and add 2 hours to the value

Enity: sensor.hugin_arrival_time
image


I want just the 10:39 text
The state gives me 08:39. So it seems like somewhere it adjust to my time zone (Oslo, norway)
Tried this:

{% set text = states(‘sensor.hugin_arrival_time’) %}
{{ text.split(‘T’)[1]|replace("+00:00","") }}

That gives me 08:39:04. But I want it to be 10:39

Any thoughts?

That’s a standard time ode that should easily be converted to a datetime object using strptime. Once you do that you can use time delta objects to do time math properly and then use strptime to format the display you want.

See this thread. The op does exactly that in his template in the first post. The rest of the thread has a lot of why you would.

2 Likes
{{ (states('sensor.hugin_arrival_time')|as_datetime|as_local).strftime('%H:%M') }}
2 Likes