mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 17:25:22 +03:00
Add all info to mqtt command
This commit is contained in:
parent
105b132e47
commit
cc6551b570
@ -91,11 +91,23 @@ def create_mqtt_client(config: FrigateConfig, camera_metrics):
|
||||
|
||||
def on_motion_command(client, userdata, message):
|
||||
payload = message.payload.decode()
|
||||
logger.debug(f"on_improve_contrast_toggle: {message.topic} {payload}")
|
||||
logger.debug(f"on_motion_toggle: {message.topic} {payload}")
|
||||
|
||||
camera_name = message.topic.split("/")[3]
|
||||
|
||||
|
||||
if payload == "ON":
|
||||
if not camera_metrics[camera_name]["motion_enabled"].value:
|
||||
logger.info(f"Turning on motion for {camera_name} via mqtt")
|
||||
camera_metrics[camera_name]["motion_enabled"].value = True
|
||||
elif payload == "OFF":
|
||||
if camera_metrics[camera_name]["motion_enabled"].value:
|
||||
logger.info(f"Turning off motion for {camera_name} via mqtt")
|
||||
camera_metrics[camera_name]["motion_enabled"].value = False
|
||||
else:
|
||||
logger.warning(f"Received unsupported value at {message.topic}: {payload}")
|
||||
|
||||
state_topic = f"{message.topic[:-4]}/state"
|
||||
client.publish(state_topic, payload, retain=True)
|
||||
|
||||
def on_improve_contrast_command(client, userdata, message):
|
||||
payload = message.payload.decode()
|
||||
@ -164,6 +176,10 @@ def create_mqtt_client(config: FrigateConfig, camera_metrics):
|
||||
client.message_callback_add(
|
||||
f"{mqtt_config.topic_prefix}/{name}/detect/set", on_detect_command
|
||||
)
|
||||
client.message_callback_add(
|
||||
f"{mqtt_config.topic_prefix}/{name}/motion/set",
|
||||
on_motion_command
|
||||
)
|
||||
client.message_callback_add(
|
||||
f"{mqtt_config.topic_prefix}/{name}/improve_contrast/set",
|
||||
on_improve_contrast_command,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user