File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 29
29
from onvif .definition import SERVICES
30
30
from onvif .exceptions import ONVIFAuthError , ONVIFError , ONVIFTimeoutError
31
31
32
- from .util import extract_subcodes_as_strings , is_auth_error , stringify_onvif_error
32
+ from .util import normalize_url , stringify_onvif_error
33
33
34
34
logger = logging .getLogger ("onvif" )
35
35
logging .basicConfig (level = logging .INFO )
@@ -577,7 +577,7 @@ async def _start(self) -> float:
577
577
# pylint: disable=protected-access
578
578
device .xaddrs [
579
579
"http://www.onvif.org/ver10/events/wsdl/NotificationConsumer"
580
- ] = result .SubscriptionReference .Address ._value_1
580
+ ] = normalize_url ( result .SubscriptionReference .Address ._value_1 )
581
581
# Create subscription manager
582
582
# 5.2.3 BASIC NOTIFICATION INTERFACE - NOTIFY
583
583
# Call SetSynchronizationPoint to generate a notification message
@@ -657,7 +657,7 @@ async def _start(self) -> float:
657
657
# pylint: disable=protected-access
658
658
device .xaddrs [
659
659
"http://www.onvif.org/ver10/events/wsdl/PullPointSubscription"
660
- ] = result .SubscriptionReference .Address ._value_1
660
+ ] = normalize_url ( result .SubscriptionReference .Address ._value_1 )
661
661
# Create subscription manager
662
662
self ._subscription = await device .create_subscription_service (
663
663
"PullPointSubscription"
Original file line number Diff line number Diff line change 2
2
from __future__ import annotations
3
3
4
4
from typing import Any
5
+ from urllib .parse import urlparse , urlunparse
5
6
6
7
from zeep .exceptions import Fault
7
8
8
9
10
+ def normalize_url (url : str ) -> str :
11
+ """Normalize URL.
12
+
13
+ Some cameras respond with <wsa5:Address>http://192.168.1.106:8106:8106/onvif/Subscription?Idx=43</wsa5:Address>
14
+ https://github.com/home-assistant/core/issues/92603#issuecomment-1537213126
15
+ """
16
+ parsed = urlparse (url )
17
+ if "[" not in parsed .netloc and parsed .netloc .count (":" ) > 1 :
18
+ net_location = parsed .netloc .split (":" , 3 )
19
+ net_location .pop ()
20
+ return urlunparse (parsed ._replace (netloc = ":" .join (net_location )))
21
+ return url
22
+
23
+
9
24
def extract_subcodes_as_strings (subcodes : Any ) -> list [str ]:
10
25
"""Stringify ONVIF subcodes."""
11
26
if isinstance (subcodes , list ):
You can’t perform that action at this time.
0 commit comments