what has worked up to this timechange? strptime on timedeltas, that’s not true. You’re mixing up functionality. Strfttime, and strptime has never worked on timedeltas, only datetimes.
just think of it this way:
What’s tuesday - monday? 1 day. Ok, what day of the week is that? Don’t have an answer? That’s because there is no answer, hence why strftime and striptime do not work on timedeltas. Because timedeltas are a change in time. Stftime and strptime include formats that would not be possible on a time delta, like %A which is the day of the week as a word.
sorry, should have been more specific… I meant to say, the first template here worked fine up to the time change in HA. It showed the time in HH:MM m and now shows the microseconds output.
it’s possible that the datetimes didn’t track microseconds which didn’t translate to the timedelta, but you would have still gotten a day and zero all the way out.
Home Assistant changed the details of its time zone implementation, starting w/ 2021.6.x. Specifically, it switched from the pytz package to Python’s new native zoneinfo library.
as you can see here, I did try the microsecond removal myself, but thought it hacky… though at the time I thought it showed only HH:MM and not :SS too… maybe not.
Indeed. I’m always confused about what device_class: timestamp actually expects.
I redid the test, and the UTC time correctly display in my local TZ w/o transformation.
Are you saying that the UTC time returned by MQTT is not actually UTC but local?
Then, it’s just wrong, and you have to “correct” it manually, indeed, no magic here.
OTOH, there might be a setting on whatever sends the message to set the correct TZ…
Where is it 2 hours off? The example I posted, using the datetime string you provided (Zulu time = UTC), clearly shows the resulting ISO8601 string remains as UTC.
what would be the exact remark I should bring across to the author here…
what is still confusing me is, that the Z is correct for the Utc time is 2 hours behind my zone, and when using that it shows the correct time difference.
My issue is to show that Z time in my local time
yes, in the template editor, but did you also use it in the frontend and using device_class: timestamp?
separate topic, trying to use the {{as_datetime(0|timestamp_utc).isoformat()}} jinja template in JS.
Python uses dt.utc_from_timestamp(0)
please help me translate this?
Having a hard time here, because the online tutorials dont use the jinja used here…
thanks
Both seem to show about the same time with the attribute being 19 seconds behind now, which is what I expect. If I convert both of those with as_timestamp, I get:
Now as timestamp: {{ as_timestamp(now()) }}
Attribute as timestamp: {{ as_timestamp(state_attr("sensor.my_sensor_name","LastUpdated")) }}
displays:
Now as timestamp: 1628155860.00095
Attribute as timestamp: 1628159441.0
This for some reasons is showing a difference of 3581 seconds. I’m assuming this is because of daylight savings and my current local time is +1, but I don’t want to just use a hacky -3600 bit of maths as this will break each time we switch from daylight savings. Where am I going wrong?