home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.07k stars 31.09k forks source link

ValueError: minute must be in 0..59 (ONVIF) #124086

Open NODeeJay opened 3 months ago

NODeeJay commented 3 months ago

The problem

When I use the Onvif integration with ASECAM 4k PoE cameras after a while I get the log spammed with

2024-08-16 23:59:05.984 ERROR (MainThread) [zeep.xsd.types.simple] Error during xml -> python translation
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/zeep/xsd/types/simple.py", line 79, in parse_xmlelement
    return self.pythonvalue(xmlelement.text)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/zeep/xsd/types/builtins.py", line 44, in _wrapper
    return func(self, re.sub(r"[\n\r\t ]", " ", value).strip())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/onvif/types.py", line 25, in pythonvalue
    return super().pythonvalue(value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/zeep/xsd/types/builtins.py", line 44, in _wrapper
    return func(self, re.sub(r"[\n\r\t ]", " ", value).strip())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/zeep/xsd/types/builtins.py", line 180, in pythonvalue
    return isodate.parse_datetime(value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/isodate/isodatetime.py", line 56, in parse_datetime
    tmptime = parse_time(timestring)
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/isodate/isotime.py", line 131, in parse_time
    return time(int(groups['hour']), int(groups['minute']),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: minute must be in 0..59
2024-08-16 23:59:06.321 ERROR (MainThread) [zeep.xsd.types.simple] Error during xml -> python translation

The error repeats rapidly, between those 2 above (23:59:05.984 and 23:59:06.321) are less than 400 ms.

There are already 2 other bug reports, but both got closed automatically due to inactivity. I assume their authors ignored the error at some point with the logging integration or live with it.

https://github.com/home-assistant/core/issues/107797 https://github.com/home-assistant/core/issues/97050

It seems the error goes away after a while. I try to get the debug logs as soon as I find the right moment. Somewhere I read it might occur hourly. Edit: Debug logs attached

What version of Home Assistant Core has the issue?

2024.7.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

onvif

Link to integration documentation on our website

https://www.home-assistant.io/integrations/onvif/

Diagnostics information

home-assistant_onvif_2024-08-16T22-56-42.923Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 3 months ago

Hey there @hunterjm, mind taking a look at this issue as it has been labeled with an integration (onvif) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `onvif` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign onvif` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


onvif documentation onvif source (message by IssueLinks)

issue-triage-workflows[bot] commented 2 weeks ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

tag6 commented 2 weeks ago

The errors are still in the log every hour, many of them, using current home assistant 2024.11.1. At least for my question which I asked in the community (and got the link to this probably related issue) the issue is not resolved. I'd suspect the same library causing the error responsible for cameras and hourly weather forecast which I use in a template sensor.

NODeeJay commented 2 weeks ago

Yes, I linked it in the forum today afternoon to increase attraction to the issue, since the last issues on github just died silently. The problem I have in investigating further is that I don't know where to hook into the ONVIF communication, and it seems neither you, since you suspect met.io. But in your log there is also the onvif.py, which lets me assume the issue might be a camera with onvif.

I checked the code of https://github.com/gweis/isodate/blob/master/src/isodate/isotime.py and found the function, but in isodatetime.py I was not so lucky. Anyway, there was no bug.

You mentioned in the forum there might be somewhere a minute too much, so I went back to the debug log and searched for that. In my case it starts five minutes before the end of the hour. Et voila: <tev:TerminationTime>2024-08-17T00:61:16Z</tev:TerminationTime>

2024-08-17 00:56:17.471 DEBUG (MainThread) [zeep.transports] HTTP Response from http://192.168.234.171:80/onvif/device_service?session=1113177884 (status: 200):
b'<?xml version="1.0" encoding="UTF-8"?>\r\n<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tns1="http://www.onvif.org/ver10/topics">\r\n<SOAP-ENV:Header>\r\n<wsa5:Action>http://www.onvif.org/ver10/events/wsdl/PullPointSubscription/PullMessagesResponse</wsa5:Action>\r\n</SOAP-ENV:Header>\r\n<SOAP-ENV:Body>\r\n<tev:PullMessagesResponse>\r\n<tev:CurrentTime>2024-08-17T00:56:16Z</tev:CurrentTime>\r\n<tev:TerminationTime>2024-08-17T00:61:16Z</tev:TerminationTime>\r\n</tev:PullMessagesResponse>\r\n</SOAP-ENV:Body>\r\n</SOAP-ENV:Envelope>\r\n'
2024-08-17 00:56:17.473 ERROR (MainThread) [zeep.xsd.types.simple] Error during xml -> python translation

When you activate the debug log for onvif in 54 minutes, do you get also a TerminationTime with over 59 minutes?

I will investigate this and get back when I get stuck or found a way (unlikely).

tag6 commented 1 week ago

Yes, I also get an invalid termination time. The errors I got obviously are caused ONVIF too. <wsnt:TerminationTime>2024-11-18T23:60:40Z</wsnt:TerminationTime>