mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-30 10:37:42 +03:00
dispatcher and mqtt
This commit is contained in:
parent
efc9ae1532
commit
329a33bad7
@ -75,6 +75,7 @@ class Dispatcher:
|
|||||||
"birdseye_mode": self._on_birdseye_mode_command,
|
"birdseye_mode": self._on_birdseye_mode_command,
|
||||||
"review_alerts": self._on_alerts_command,
|
"review_alerts": self._on_alerts_command,
|
||||||
"review_detections": self._on_detections_command,
|
"review_detections": self._on_detections_command,
|
||||||
|
"genai": self._on_genai_command,
|
||||||
}
|
}
|
||||||
self._global_settings_handlers: dict[str, Callable] = {
|
self._global_settings_handlers: dict[str, Callable] = {
|
||||||
"notifications": self._on_global_notification_command,
|
"notifications": self._on_global_notification_command,
|
||||||
@ -737,3 +738,28 @@ class Dispatcher:
|
|||||||
review_settings,
|
review_settings,
|
||||||
)
|
)
|
||||||
self.publish(f"{camera_name}/review_detections/state", payload, retain=True)
|
self.publish(f"{camera_name}/review_detections/state", payload, retain=True)
|
||||||
|
|
||||||
|
def _on_genai_command(self, camera_name: str, payload: str) -> None:
|
||||||
|
"""Callback for GenAI topic."""
|
||||||
|
genai_settings = self.config.cameras[camera_name].genai
|
||||||
|
|
||||||
|
if payload == "ON":
|
||||||
|
if not self.config.cameras[camera_name].genai.enabled_in_config:
|
||||||
|
logger.error(
|
||||||
|
"GenAI must be enabled in the config to be turned on via MQTT."
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
if not genai_settings.enabled:
|
||||||
|
logger.info(f"Turning on GenAI for {camera_name}")
|
||||||
|
genai_settings.enabled = True
|
||||||
|
elif payload == "OFF":
|
||||||
|
if genai_settings.enabled:
|
||||||
|
logger.info(f"Turning off GenAI for {camera_name}")
|
||||||
|
genai_settings.enabled = False
|
||||||
|
|
||||||
|
self.config_updater.publish_update(
|
||||||
|
CameraConfigUpdateTopic(CameraConfigUpdateEnum.genai, camera_name),
|
||||||
|
genai_settings,
|
||||||
|
)
|
||||||
|
self.publish(f"{camera_name}/genai/state", payload, retain=True)
|
||||||
|
|||||||
@ -122,6 +122,11 @@ class MqttClient(Communicator): # type: ignore[misc]
|
|||||||
"ON" if camera.review.detections.enabled_in_config else "OFF",
|
"ON" if camera.review.detections.enabled_in_config else "OFF",
|
||||||
retain=True,
|
retain=True,
|
||||||
)
|
)
|
||||||
|
self.publish(
|
||||||
|
f"{camera_name}/genai/state",
|
||||||
|
"ON" if camera.genai.enabled_in_config else "OFF",
|
||||||
|
retain=True,
|
||||||
|
)
|
||||||
|
|
||||||
if self.config.notifications.enabled_in_config:
|
if self.config.notifications.enabled_in_config:
|
||||||
self.publish(
|
self.publish(
|
||||||
@ -215,6 +220,7 @@ class MqttClient(Communicator): # type: ignore[misc]
|
|||||||
"birdseye_mode",
|
"birdseye_mode",
|
||||||
"review_alerts",
|
"review_alerts",
|
||||||
"review_detections",
|
"review_detections",
|
||||||
|
"genai",
|
||||||
]
|
]
|
||||||
|
|
||||||
for name in self.config.cameras.keys():
|
for name in self.config.cameras.keys():
|
||||||
|
|||||||
@ -17,6 +17,7 @@ class CameraConfigUpdateEnum(str, Enum):
|
|||||||
birdseye = "birdseye"
|
birdseye = "birdseye"
|
||||||
detect = "detect"
|
detect = "detect"
|
||||||
enabled = "enabled"
|
enabled = "enabled"
|
||||||
|
genai = "genai"
|
||||||
motion = "motion" # includes motion and motion masks
|
motion = "motion" # includes motion and motion masks
|
||||||
notifications = "notifications"
|
notifications = "notifications"
|
||||||
objects = "objects"
|
objects = "objects"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user