mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 01:35:22 +03:00
Cleanup
This commit is contained in:
parent
02cb5b55ed
commit
121b90a498
@ -5,7 +5,6 @@ import paho.mqtt.client as mqtt
|
||||
|
||||
from frigate.communication.dispatcher import Communicator
|
||||
from frigate.config import FrigateConfig
|
||||
from frigate.types import CameraMetricsTypes
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -38,48 +37,48 @@ class MqttClient(Communicator):
|
||||
"""Set initial state topics."""
|
||||
for camera_name, camera in self.config.cameras.items():
|
||||
self.publish(
|
||||
f"{self.mqtt_config.topic_prefix}/{camera_name}/recordings/state",
|
||||
f"{camera_name}/recordings/state",
|
||||
"ON" if camera.record.enabled else "OFF",
|
||||
retain=True,
|
||||
)
|
||||
self.publish(
|
||||
f"{self.mqtt_config.topic_prefix}/{camera_name}/snapshots/state",
|
||||
f"{camera_name}/snapshots/state",
|
||||
"ON" if camera.snapshots.enabled else "OFF",
|
||||
retain=True,
|
||||
)
|
||||
self.publish(
|
||||
f"{self.mqtt_config.topic_prefix}/{camera_name}/detect/state",
|
||||
f"{camera_name}/detect/state",
|
||||
"ON" if camera.detect.enabled else "OFF",
|
||||
retain=True,
|
||||
)
|
||||
self.publish(
|
||||
f"{self.mqtt_config.topic_prefix}/{camera_name}/motion/state",
|
||||
f"{camera_name}/motion/state",
|
||||
"ON",
|
||||
retain=True,
|
||||
)
|
||||
self.publish(
|
||||
f"{self.mqtt_config.topic_prefix}/{camera_name}/improve_contrast/state",
|
||||
f"{camera_name}/improve_contrast/state",
|
||||
"ON" if camera.motion.improve_contrast else "OFF",
|
||||
retain=True,
|
||||
)
|
||||
self.publish(
|
||||
f"{self.mqtt_config.topic_prefix}/{camera_name}/motion_threshold/state",
|
||||
f"{camera_name}/motion_threshold/state",
|
||||
camera.motion.threshold,
|
||||
retain=True,
|
||||
)
|
||||
self.publish(
|
||||
f"{self.mqtt_config.topic_prefix}/{camera_name}/motion_contour_area/state",
|
||||
f"{camera_name}/motion_contour_area/state",
|
||||
camera.motion.contour_area,
|
||||
retain=True,
|
||||
)
|
||||
self.publish(
|
||||
f"{self.mqtt_config.topic_prefix}/{camera_name}/motion",
|
||||
f"{camera_name}/motion",
|
||||
"OFF",
|
||||
retain=False,
|
||||
)
|
||||
|
||||
self.publish(
|
||||
self.mqtt_config.topic_prefix + "/available", "online", retain=True
|
||||
"available", "online", retain=True
|
||||
)
|
||||
|
||||
def on_mqtt_command(
|
||||
|
||||
@ -39,12 +39,13 @@ class WebSocketClient(Communicator):
|
||||
try:
|
||||
json_message = json.loads(message.data.decode("utf-8"))
|
||||
json_message = {
|
||||
"topic": f"{self.topic_prefix}/{json_message['topic']}",
|
||||
"topic": json_message.get("topic"),
|
||||
"payload": json_message.get("payload"),
|
||||
"retain": json_message.get("retain", False),
|
||||
}
|
||||
except Exception as e:
|
||||
logger.warning("Unable to parse websocket message as valid json.")
|
||||
logger.warning(
|
||||
f"Unable to parse websocket message as valid json: {message.data.decode('utf-8')}"
|
||||
)
|
||||
return
|
||||
|
||||
logger.debug(
|
||||
@ -53,7 +54,6 @@ class WebSocketClient(Communicator):
|
||||
self.receiver(
|
||||
json_message["topic"],
|
||||
json_message["payload"],
|
||||
retain=json_message["retain"],
|
||||
)
|
||||
|
||||
# start a websocket server on 5002
|
||||
|
||||
Loading…
Reference in New Issue
Block a user