Just upgraded to 2022.6.5 and not sure if this was there before but the last_seen timestamp shows incorrect where it seems to indicate the UTC+2 but it does not do that correctly.
I am in CET timezone
EDIT: HA, MQTT, Z2M and MariaDb containers are all in CET TZ
The whole EU is in CEST, now (summertime saving, UTC+2).
Are you actually in a CET country that doesn’t apply summertime?
All containers are the same TZ Europe/Paris…and you see that the last-update and last changed do not show the +2 hence I am confused what the difference
last-update and last changed just show you the local time, without expliciting the TZ. “Europe/Paris” is actually UTC+2 in summertime, i.e. now.
The +02:00
tells you the TZ the datetime before is in, not that you should add/remove 2 to the time.
More confused now… the last_seen is (up to 1 sec almost) exactly the same as the last_updated … so why does one show the +2 and the other not? Sorry for possibly sounding dense
EDIT: for automations, I have this
last_triggered: 2022-06-10T19:31:36.963857+00:00
which is what I would expect +0
What’s confusing about that? It makes sense to me that the sensor would be updated after being seen, no?
Actually, just because last_seen
is an attribute of the sensor, it will always be updated after that attribute changes.
last_changed
is about the last time the state of the sensor changed
last_updated
is the last time the state or the attributes changed
Still not happy with this
If I see three times and all are indeed (almost) exactly the same then I donot expect on to have +2 then other +0 and the last one no + at all
EDIT, it is not critical, just not logical as well
2022-06-10T19:31:36.963857+00:00
= 2022-06-10T21:31:36.963857+02:00
It’s just a notation thing, the times are perfectly equivalent.
It’s like
T+0 = (T+2)-2
Now, I agree that last_triggered
should use the proper TZ, but it’s just cosmetic.
If you check the trace of the automation, you’ll see that local time is used in the UI.
last_seen is an attribute that’s coming from your device, where last_updated and last_changed are made by home assistant. What integration are you using to create that sensor?
Last seen comes through a zigbee / z2m…
The reason why I donot like all those differences is that it become fiddly with templates…but again, not important
it does not become fiddly with templates, simply use the as_datetime
or as_timestamp
filter and it will convert it to the correct time without any other conversions.
ok…I will look at that, used strp / strf a lot
And that’s your problem. You shouldn’t need either of those filters, as_datetime will convert any ISO formatted timestamp into a datetime without a format.
FYI, just looking at the zigbee2mqtt options, you can set last_seen to output ISO_8601 timestamps instead of ISO_8601_local and it will have UTC timestamps instead of local timestamps. That’s why I mentioned that your last_seen was coming from the device as the device has the control over it. And as it turns out, you can control that from Zigbee2MQTT.
https://www.zigbee2mqtt.io/guide/configuration/mqtt.html#mqtt-behaviour
advanced:
# Optional: Add a last_seen attribute to MQTT messages, contains date/time of last Zigbee message
# possible values are: disable (default), ISO_8601, ISO_8601_local, epoch (default: disable)
last_seen: 'disable'
EDIT: It looks like the default behavior is 'disable'
, so you’re the one who must have set it to 'ISO_8601_local'
?
Thanks a lot