always create ONVIF status and service capabilities requests during init

This commit is contained in:
Josh Hawkins
2026-07-15 19:23:18 -05:00
parent a7d07792d3
commit bd1892e4af
2 changed files with 35 additions and 10 deletions
+25 -1
View File
@@ -198,7 +198,7 @@ class PtzAutoTrackerThread(threading.Thread):
def run(self): def run(self):
while not self.stop_event.wait(1): while not self.stop_event.wait(1):
self.ptz_autotracker.config_subscriber.check_for_updates() self.ptz_autotracker.check_for_updates()
for camera, camera_config in list(self.config.cameras.items()): for camera, camera_config in list(self.config.cameras.items()):
if not camera_config.enabled: if not camera_config.enabled:
@@ -257,6 +257,7 @@ class PtzAutoTracker:
[ [
CameraConfigUpdateEnum.add, CameraConfigUpdateEnum.add,
CameraConfigUpdateEnum.autotracking, CameraConfigUpdateEnum.autotracking,
CameraConfigUpdateEnum.onvif,
], ],
) )
@@ -276,6 +277,29 @@ class PtzAutoTracker:
# Wait for the coroutine to complete # Wait for the coroutine to complete
future.result() future.result()
def check_for_updates(self) -> None:
"""Apply camera config updates and mirror autotracking state to ptz metrics.
The camera processes read autotracker_enabled rather than the config, so it
has to follow every path that can change autotracking, not just the mqtt
toggle that writes it directly.
"""
updates = self.config_subscriber.check_for_updates()
for cameras in updates.values():
for camera in cameras:
camera_config = self.config.cameras.get(camera)
metrics = self.ptz_metrics.get(camera)
# a camera added at runtime gets its metrics from the maintainer on
# another thread, which seeds them from this same config value
if camera_config is None or metrics is None:
continue
metrics.autotracker_enabled.value = (
camera_config.onvif.autotracking.enabled
)
async def _autotracker_setup(self, camera_config: CameraConfig, camera: str): async def _autotracker_setup(self, camera_config: CameraConfig, camera: str):
logger.debug(f"{camera}: Autotracker init") logger.debug(f"{camera}: Autotracker init")
+3 -2
View File
@@ -344,8 +344,9 @@ class OnvifController:
autotracking_config.enabled_in_config and autotracking_config.enabled autotracking_config.enabled_in_config and autotracking_config.enabled
) )
# autotracking-only: status request and service capabilities # these are local and cost nothing to build, and autotracking can be enabled
if autotracking_enabled: # after a camera is initialized, so always create them rather than baking the
# current config value into init state
status_request = ptz.create_type("GetStatus") status_request = ptz.create_type("GetStatus")
status_request.ProfileToken = profile.token status_request.ProfileToken = profile.token
self.cams[camera_name]["status_request"] = status_request self.cams[camera_name]["status_request"] = status_request