System time format wrong?

I keep getting messages in my logfile about time being wrong.

Logger: homeassistant.components.onvif
Source: components/onvif/device.py:206
Integration: ONVIF (documentation, issues)
First occurred: 12:13:18 PM (3 occurrences)
Last logged: 12:13:18 PM

The date/time on the device (UTC) is '2021-10-08 10:14:57+00:00', which is different from the system '2021-10-08 10:13:17.598551+00:00', this could lead to authentication issues
The date/time on the device (UTC) is '2021-10-08 10:14:40+00:00', which is different from the system '2021-10-08 10:13:17.577622+00:00', this could lead to authentication issues
The date/time on the device (UTC) is '2021-10-08 10:13:27+00:00', which is different from the system '2021-10-08 10:13:17.619424+00:00', this could lead to authentication issues

As you can see the system time is in a very strange format (to me at least) and I am not sure why this is the case or what I could do to correct this… Anyone any ideas what might be the cause of this?

1 Like

the time is different on your camera vs home assistant. Change the time on your camera.

But the time on my camera is correct and also displays correct. The system time is in this strange format:
‘2021-10-08 10:13:17.619424+00:00’

That’s UTC. UTC is a generic time zone that systems use to translate one timezone into another. All software typically thinks in UTC and displays the users local timezone. This is just how things are done. Anyways, notice how your minutes don’t match the UTC minutes on the home assistant system?

The last line out of the log:
‘2021-10-08 10:13:27+00:00’, Camera
‘2021-10-08 10:13:17.619424+00:00’ system

Minutes are the same, aren’t they? It is the seconds which are of. And what I don’t understand is the decimals behind the seconds marker of the system time, that cannot be correct, can it?

that’s microseconds, it’s fine. Those don’t need to match exactly, that’s just how the systems are outputting the timeformat. The take away from the message is that your 2 times aren’t the same. I would assume 10 second difference is ok. However this doesn’t appear to be ok:

'2021-10-08 10:14:57+00:00', which is different from the system '2021-10-08 10:13:17.598551+00:00', 
'2021-10-08 10:14:40+00:00', which is different from the system '2021-10-08 10:13:17.577622+00:00

that’s almost 2 minutes in both cases.

Also, notice how the system time is near identical where your camera time is erratic.

Thanks for the quick reply and information. Ok I get the miliseconds… I was actually almost hoping for this to be an issue, since I was thinking this timeformat also caused an issue in SQL Queries, but maybe it is not. I did see a seperate fix for the SQL issue got merged in the 2021.10.1 release so I will wait for a bit to see if that solved the SQL stuff.

Anyhow…back to the cameras…guess I will just have to live with the warnings then (i am very good at ignoring those if required…:wink: since I cannot change the time on the camera. It only allows me to select a timezone, which is set correctly.

Thanks!

Does your camera have access to the internet? There’s ways to setup your network so that IP cameras can properly grab the current time from the internet without having access to anything else.

They do and I think they also should sync automatically. It are cheap china cams (wansview) which do offer the ONVIF protocol which I used to integrate them. So probably not much else I can do.

Well, then just ignore them. It’s really only a problem if they stop authenticating. And when they do, I’d probably just restart the camera.

and previously [homeassistant.components.onvif] The date/time on the device is different from the system this could lead to authentication issues · Issue #51836 · home-assistant/core · GitHub and Onvif integration is not picking up your Timezone · Issue #34522 · home-assistant/core · GitHub which are same issue - closed by the all to aggressive stale bot

I asked on Discord for a dev to add the ONVIF label to the 68216 and then we all have to keep on poking the stale bot to keep the bug open. The stale bot for this project is way too aggresive. Especially with the short time you have from it warns till it closes the bug.

HA gets it’s time from the internet. If your camera is set manually, you have to change it on the camera. That’s a bug in the camera, not home assistant.

The UTC+1 is the time zone! Copenhagen is Central European Time or UTC +1 (+DST offset).

UTC by definition has no DST! UTC is always UTC

We are now several people that have either reported or confirmed the problem and we have different cameras. They cannot all be wrong

There is a problem with the ONVIF integration. It does not recognize the DST offset of an extra hour for the camera.

The camera has the DST feature and it correctly displays the time in the on screen text in the video stream

That’s not how time works. UTC can’t be +1. It’s always +0, even with DST. Your local time has DST applied. That’s a bug in the camera.

Lastly, if it’s truely a bug in the python code, you should be opening the issue up on the python client that HA uses.

There are no open DST bugs in the Python ONVIF. The reports that were closed are rather old so it should have been reported by now.

You’re welcome to continue writing the bug up, however if the camera is reporting UTC wrong, then it’s a bug in the camera. You’ve already stated that it’s time has an offset and that’s wrong. I’m not sure what to tell you. UTC is always +0, because it’s UTC. It never has DST applied because it’s UTC.

Looking at the code it’s also possible that your camera is not applying DST. That would also cause problems.

I did not say the camera is reporting the wrong time.

I am saying that the ONVIF integration is getting the time wrong - offset by an hour - only when DST in effective. The camera shows the right time. Others have reported the same issue with camera of a different brand. Do we all have broken cameras? Not likely

I can definitively say: Home assistant’s time is correct. With local and with the TZ. The code for comparison is here and you can see it’s getting the time info from the camera. So if anything is incorrect via time, it’s the time from the camera.