@@ -52,6 +52,7 @@ def __init__(
52
52
self ._shutdown = False
53
53
self ._subscription_lost_callback = subscription_lost_callback
54
54
self ._cancel_subscription_renew : asyncio .TimerHandle | None = None
55
+ self ._service : ONVIFService | None = None
55
56
56
57
@property
57
58
def closed (self ) -> bool :
@@ -94,10 +95,10 @@ async def shutdown(self) -> None:
94
95
async def _start (self ) -> float :
95
96
"""Setup the processor. Returns the next renewal call at time."""
96
97
97
- async def _set_synchronization_point (self , service : ONVIFService ) -> float :
98
+ async def set_synchronization_point (self ) -> float :
98
99
"""Set the synchronization point."""
99
100
try :
100
- await service .SetSynchronizationPoint ()
101
+ await self . _service .SetSynchronizationPoint ()
101
102
except (Fault , asyncio .TimeoutError , TransportError , TypeError ):
102
103
logger .debug ("%s: SetSynchronizationPoint failed" , self ._service .url )
103
104
@@ -229,12 +230,12 @@ async def _start(self) -> float:
229
230
#
230
231
# If this fails this is OK as it just means we will switch
231
232
# to webhook later when the first notification is received.
232
- service = await self ._device .create_onvif_service (
233
+ self . _service = await self ._device .create_onvif_service (
233
234
"pullpoint" , port_type = "NotificationConsumer"
234
235
)
235
- self ._operation = service . document .bindings [service . binding_name ]. get (
236
- "PullMessages"
237
- )
236
+ self ._operation = self . _service . document .bindings [
237
+ self . _service . binding_name
238
+ ]. get ( "PullMessages" )
238
239
self ._subscription = await device .create_subscription_service (
239
240
"NotificationConsumer"
240
241
)
@@ -250,7 +251,6 @@ async def _start(self) -> float:
250
251
)
251
252
renewal_call_at = self ._calculate_next_renewal_call_at (result )
252
253
logger .debug ("%s: Start the notification manager" , self ._device .host )
253
- await self ._set_synchronization_point (service )
254
254
return renewal_call_at
255
255
256
256
def process (self , content : bytes ) -> Any | None :
@@ -273,16 +273,6 @@ def process(self, content: bytes) -> Any | None:
273
273
class PullPointManager (BaseManager ):
274
274
"""Manager for PullPoint."""
275
275
276
- def __init__ (
277
- self ,
278
- device : ONVIFCamera ,
279
- interval : dt .timedelta ,
280
- subscription_lost_callback : Callable [[], None ],
281
- ) -> None :
282
- """Initialize the PullPoint processor."""
283
- super ().__init__ (device , interval , subscription_lost_callback )
284
- self ._service : ONVIFService | None = None
285
-
286
276
async def _start (self ) -> float :
287
277
"""Start the PullPoint manager.
288
278
@@ -318,7 +308,6 @@ async def _start(self) -> float:
318
308
)
319
309
renewal_call_at = self ._calculate_next_renewal_call_at (result )
320
310
logger .debug ("%s: Start the notification manager" , self ._device .host )
321
- await self ._set_synchronization_point (self ._service )
322
311
return renewal_call_at
323
312
324
313
def get_service (self ) -> ONVIFService :
0 commit comments