mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-26 19:06:11 +01:00
use enabled_in_config for switch in HA integration (#8630)
This commit is contained in:
parent
cadb1a6a5b
commit
7b520e8a9d
@ -185,6 +185,13 @@ class Dispatcher:
|
|||||||
ptz_autotracker_settings = self.config.cameras[camera_name].onvif.autotracking
|
ptz_autotracker_settings = self.config.cameras[camera_name].onvif.autotracking
|
||||||
|
|
||||||
if payload == "ON":
|
if payload == "ON":
|
||||||
|
if not self.config.cameras[
|
||||||
|
camera_name
|
||||||
|
].onvif.autotracking.enabled_in_config:
|
||||||
|
logger.error(
|
||||||
|
"Autotracking must be enabled in the config to be turned on via MQTT."
|
||||||
|
)
|
||||||
|
return
|
||||||
if not self.ptz_metrics[camera_name]["ptz_autotracker_enabled"].value:
|
if not self.ptz_metrics[camera_name]["ptz_autotracker_enabled"].value:
|
||||||
logger.info(f"Turning on ptz autotracker for {camera_name}")
|
logger.info(f"Turning on ptz autotracker for {camera_name}")
|
||||||
self.ptz_metrics[camera_name]["ptz_autotracker_enabled"].value = True
|
self.ptz_metrics[camera_name]["ptz_autotracker_enabled"].value = True
|
||||||
|
@ -71,7 +71,7 @@ class MqttClient(Communicator): # type: ignore[misc]
|
|||||||
)
|
)
|
||||||
self.publish(
|
self.publish(
|
||||||
f"{camera_name}/ptz_autotracker/state",
|
f"{camera_name}/ptz_autotracker/state",
|
||||||
"ON" if camera.onvif.autotracking.enabled else "OFF",
|
"ON" if camera.onvif.autotracking.enabled_in_config else "OFF",
|
||||||
retain=True,
|
retain=True,
|
||||||
)
|
)
|
||||||
self.publish(
|
self.publish(
|
||||||
|
@ -184,6 +184,9 @@ class PtzAutotrackConfig(FrigateBaseModel):
|
|||||||
default=[],
|
default=[],
|
||||||
title="Internal value used for PTZ movements based on the speed of your camera's motor.",
|
title="Internal value used for PTZ movements based on the speed of your camera's motor.",
|
||||||
)
|
)
|
||||||
|
enabled_in_config: Optional[bool] = Field(
|
||||||
|
title="Keep track of original state of autotracking."
|
||||||
|
)
|
||||||
|
|
||||||
@validator("movement_weights", pre=True)
|
@validator("movement_weights", pre=True)
|
||||||
def validate_weights(cls, v):
|
def validate_weights(cls, v):
|
||||||
@ -1191,6 +1194,9 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
# set config pre-value
|
# set config pre-value
|
||||||
camera_config.record.enabled_in_config = camera_config.record.enabled
|
camera_config.record.enabled_in_config = camera_config.record.enabled
|
||||||
camera_config.audio.enabled_in_config = camera_config.audio.enabled
|
camera_config.audio.enabled_in_config = camera_config.audio.enabled
|
||||||
|
camera_config.onvif.autotracking.enabled_in_config = (
|
||||||
|
camera_config.onvif.autotracking.enabled
|
||||||
|
)
|
||||||
|
|
||||||
# Add default filters
|
# Add default filters
|
||||||
object_keys = camera_config.objects.track
|
object_keys = camera_config.objects.track
|
||||||
|
@ -208,7 +208,10 @@ class PtzAutoTracker:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
self.autotracker_init[camera] = False
|
self.autotracker_init[camera] = False
|
||||||
if camera_config.onvif.autotracking.enabled:
|
if (
|
||||||
|
camera_config.onvif.autotracking.enabled
|
||||||
|
and camera_config.onvif.autotracking.enabled_in_config
|
||||||
|
):
|
||||||
self._autotracker_setup(camera_config, camera)
|
self._autotracker_setup(camera_config, camera)
|
||||||
|
|
||||||
def _autotracker_setup(self, camera_config, camera):
|
def _autotracker_setup(self, camera_config, camera):
|
||||||
|
Loading…
Reference in New Issue
Block a user