@@ -252,6 +252,7 @@ def __init__(
252
252
binding_key = "" ,
253
253
read_timeout : Optional [int ] = None ,
254
254
write_timeout : Optional [int ] = None ,
255
+ enable_wsa : bool = False ,
255
256
) -> None :
256
257
if not _path_isfile (url ):
257
258
raise ONVIFError ("%s doesn`t exist!" % url )
@@ -296,6 +297,7 @@ def __init__(
296
297
self .ws_client : Optional [AsyncServiceProxy ] = None
297
298
self .create_type : Optional [Callable ] = None
298
299
self .loop = asyncio .get_event_loop ()
300
+ self ._enable_wsa = enable_wsa
299
301
300
302
async def setup (self ):
301
303
"""Setup the transport."""
@@ -307,11 +309,15 @@ async def setup(self):
307
309
self .document = await self .loop .run_in_executor (
308
310
None , _cached_document , self .url
309
311
)
312
+ # Some cameras never return a response to GetCapabilities if WS-Addressing is enabled
313
+ # but some cameras require WS-Addressing to be enabled for PullPoint or events to work
314
+ # so we have a flag to enable/disable it which can be changed per service.
315
+ plugins = [WsAddressingPlugin ()] if self ._enable_wsa else []
310
316
self .zeep_client_authless = ZeepAsyncClient (
311
317
wsdl = self .document ,
312
318
transport = self .transport ,
313
319
settings = settings ,
314
- plugins = [ WsAddressingPlugin ()] ,
320
+ plugins = plugins ,
315
321
)
316
322
self .ws_client_authless = self .zeep_client_authless .create_service (
317
323
binding_name , self .xaddr
@@ -321,7 +327,7 @@ async def setup(self):
321
327
wsse = wsse ,
322
328
transport = self .transport ,
323
329
settings = settings ,
324
- plugins = [ WsAddressingPlugin ()] ,
330
+ plugins = plugins ,
325
331
)
326
332
self .ws_client = self .zeep_client .create_service (binding_name , self .xaddr )
327
333
namespace = binding_name [binding_name .find ("{" ) + 1 : binding_name .find ("}" )]
@@ -404,8 +410,10 @@ async def setup(self) -> ONVIFService:
404
410
#
405
411
# If this fails this is OK as it just means we will switch
406
412
# to webhook later when the first notification is received.
413
+ # WSAs enabled per
414
+ # https://github.com/home-assistant/core/issues/83524 https://github.com/home-assistant/core/issues/45513
407
415
service = await self ._device .create_onvif_service (
408
- "pullpoint" , port_type = "NotificationConsumer"
416
+ "pullpoint" , port_type = "NotificationConsumer" , enable_wsa = True
409
417
)
410
418
self ._operation = service .document .bindings [service .binding_name ].get (
411
419
"PullMessages"
@@ -649,6 +657,7 @@ async def create_onvif_service(
649
657
port_type : Optional [str ] = None ,
650
658
read_timeout : Optional [int ] = None ,
651
659
write_timeout : Optional [int ] = None ,
660
+ enable_wsa : bool = False ,
652
661
) -> ONVIFService :
653
662
"""Create ONVIF service client"""
654
663
name = name .lower ()
@@ -687,6 +696,7 @@ async def create_onvif_service(
687
696
binding_key = binding_key ,
688
697
read_timeout = read_timeout ,
689
698
write_timeout = write_timeout ,
699
+ enable_wsa = enable_wsa ,
690
700
)
691
701
await service .setup ()
692
702
@@ -715,8 +725,12 @@ async def create_deviceio_service(self) -> ONVIFService:
715
725
return await self .create_onvif_service ("deviceio" )
716
726
717
727
async def create_events_service (self ) -> ONVIFService :
718
- """Service creation helper."""
719
- return await self .create_onvif_service ("events" )
728
+ """Service creation helper.
729
+
730
+ WSAs enabled per
731
+ https://github.com/home-assistant/core/issues/83524 https://github.com/home-assistant/core/issues/45513
732
+ """
733
+ return await self .create_onvif_service ("events" , enable_wsa = True )
720
734
721
735
async def create_analytics_service (self ) -> ONVIFService :
722
736
"""Service creation helper."""
@@ -735,23 +749,38 @@ async def create_replay_service(self) -> ONVIFService:
735
749
return await self .create_onvif_service ("replay" )
736
750
737
751
async def create_pullpoint_service (self ) -> ONVIFService :
738
- """Service creation helper."""
752
+ """Service creation helper.
753
+
754
+ WSAs enabled per
755
+ https://github.com/home-assistant/core/issues/83524 https://github.com/home-assistant/core/issues/45513
756
+ """
739
757
return await self .create_onvif_service (
740
758
"pullpoint" ,
741
759
port_type = "PullPointSubscription" ,
742
760
read_timeout = _PULLPOINT_TIMEOUT ,
743
761
write_timeout = _PULLPOINT_TIMEOUT ,
762
+ enable_wsa = True ,
744
763
)
745
764
746
765
async def create_notification_service (self ) -> ONVIFService :
747
- """Service creation helper."""
748
- return await self .create_onvif_service ("notification" )
766
+ """Service creation helper.
767
+
768
+ WSAs enabled per
769
+ https://github.com/home-assistant/core/issues/83524 https://github.com/home-assistant/core/issues/45513
770
+ """
771
+ return await self .create_onvif_service ("notification" , enable_wsa = True )
749
772
750
773
async def create_subscription_service (
751
774
self , port_type : Optional [str ] = None
752
775
) -> ONVIFService :
753
- """Service creation helper."""
754
- return await self .create_onvif_service ("subscription" , port_type = port_type )
776
+ """Service creation helper.
777
+
778
+ WSAs enabled per
779
+ https://github.com/home-assistant/core/issues/83524 https://github.com/home-assistant/core/issues/45513
780
+ """
781
+ return await self .create_onvif_service (
782
+ "subscription" , port_type = port_type , enable_wsa = True
783
+ )
755
784
756
785
async def create_receiver_service (self ) -> ONVIFService :
757
786
"""Service creation helper."""
0 commit comments