core: Onvif port invalid literal for int() with base 10:

The problem

Error started in Core 2023.5 Onvif cams with non standard ports stoped working with Error:

Logger: homeassistant.config_entries
Source: components/onvif/event.py:682
First occurred: 08:27:22 (4 occurrences)
Last logged: 08:31:01

Error setting up entry C06 - 58:10:8c:3f:d3:84 for onvif
Error setting up entry C10 - 58:10:8c:3f:da:11 for onvif
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/httpx/_urlparse.py", line 339, in normalize_port
    port_as_int = int(port)
ValueError: invalid literal for int() with base 10: '8106:8106'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/onvif/__init__.py", line 39, in async_setup_entry
    await device.async_setup()
  File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 151, in async_setup
    self.capabilities.events = await self.async_start_events()
  File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 358, in async_start_events
    return await self.events.async_start(pull_point_support is not False, True)
  File "/usr/src/homeassistant/homeassistant/components/onvif/event.py", line 132, in async_start
    events_via_webhook = try_webhook and await self.webhook_manager.async_start()
  File "/usr/src/homeassistant/homeassistant/components/onvif/event.py", line 635, in async_start
    if not await self._async_start_webhook():
  File "/usr/src/homeassistant/homeassistant/components/onvif/event.py", line 693, in _async_start_webhook
    await self._async_create_webhook_subscription()
  File "/usr/src/homeassistant/homeassistant/components/onvif/event.py", line 682, in _async_create_webhook_subscription
    await self._notification_manager.start()
  File "/usr/local/lib/python3.10/site-packages/onvif/client.py", line 331, in start
    await self._service.SetSynchronizationPoint()
  File "/usr/local/lib/python3.10/site-packages/zeep/proxy.py", line 64, in __call__
    return await self._proxy._binding.send_async(
  File "/usr/local/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 156, in send_async
    response = await client.transport.post_xml(
  File "/usr/local/lib/python3.10/site-packages/zeep/transports.py", line 235, in post_xml
    response = await self.post(address, message, headers)
  File "/usr/local/lib/python3.10/site-packages/zeep/transports.py", line 220, in post
    response = await self.client.post(
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1845, in post
    return await self.request(
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1517, in request
    request = self.build_request(
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 346, in build_request
    url = self._merge_url(url)
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 376, in _merge_url
    merge_url = URL(url)
  File "/usr/local/lib/python3.10/site-packages/httpx/_urls.py", line 113, in __init__
    self._uri_reference = urlparse(url, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/httpx/_urlparse.py", line 246, in urlparse
    parsed_port: typing.Optional[int] = normalize_port(port, scheme)

What version of Home Assistant Core has the issue?

2023.5.1

What was the last working version of Home Assistant Core?

2023.4.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Onvif

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.config_entries
Source: components/onvif/event.py:682
First occurred: 08:27:22 (4 occurrences)
Last logged: 08:31:01

Error setting up entry C06 - 58:10:8c:3f:d3:84 for onvif
Error setting up entry C10 - 58:10:8c:3f:da:11 for onvif
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/httpx/_urlparse.py", line 339, in normalize_port
    port_as_int = int(port)
ValueError: invalid literal for int() with base 10: '8106:8106'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/onvif/__init__.py", line 39, in async_setup_entry
    await device.async_setup()
  File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 151, in async_setup
    self.capabilities.events = await self.async_start_events()
  File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 358, in async_start_events
    return await self.events.async_start(pull_point_support is not False, True)
  File "/usr/src/homeassistant/homeassistant/components/onvif/event.py", line 132, in async_start
    events_via_webhook = try_webhook and await self.webhook_manager.async_start()
  File "/usr/src/homeassistant/homeassistant/components/onvif/event.py", line 635, in async_start
    if not await self._async_start_webhook():
  File "/usr/src/homeassistant/homeassistant/components/onvif/event.py", line 693, in _async_start_webhook
    await self._async_create_webhook_subscription()
  File "/usr/src/homeassistant/homeassistant/components/onvif/event.py", line 682, in _async_create_webhook_subscription
    await self._notification_manager.start()
  File "/usr/local/lib/python3.10/site-packages/onvif/client.py", line 331, in start
    await self._service.SetSynchronizationPoint()
  File "/usr/local/lib/python3.10/site-packages/zeep/proxy.py", line 64, in __call__
    return await self._proxy._binding.send_async(
  File "/usr/local/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 156, in send_async
    response = await client.transport.post_xml(
  File "/usr/local/lib/python3.10/site-packages/zeep/transports.py", line 235, in post_xml
    response = await self.post(address, message, headers)
  File "/usr/local/lib/python3.10/site-packages/zeep/transports.py", line 220, in post
    response = await self.client.post(
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1845, in post
    return await self.request(
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1517, in request
    request = self.build_request(
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 346, in build_request
    url = self._merge_url(url)
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 376, in _merge_url
    merge_url = URL(url)
  File "/usr/local/lib/python3.10/site-packages/httpx/_urls.py", line 113, in __init__
    self._uri_reference = urlparse(url, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/httpx/_urlparse.py", line 246, in urlparse
    parsed_port: typing.Optional[int] = normalize_port(port, scheme)
  File "/usr/local/lib/python3.10/site-packages/httpx/_urlparse.py", line 341, in normalize_port
    raise InvalidURL("Invalid port")
httpx.InvalidURL: Invalid port

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 29 (14 by maintainers)

Commits related to this issue

Most upvoted comments

I’ll try to get the change in 2023.6.x or sooner depending on how busy my day job is next week

@nrsf Can you try the updated fix with onvif-zeep-async==3.1.1? (It may take another iteration or two as I’m working around each new error as you give me new logs)

cd /config
curl -o- -sSL https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d onvif -p 92711
cat /config/custom_components/onvif/manifest.json

Verify that the version displayed above is “onvif-zeep-async==3.1.1” and NOT 2.1.1

Restart HA

Test

Delete /config/custom_components/onvif and restart after testing is completed to restore the core version

So it’s getting further. That’s good. Will need some more adjustments

Thanks. That looks right.

Will have to dig some more to see how that can happen

What do you have the port set to?

Please post diagnostics.