From e7c536ea312dc2266b34a56a6d44607a65470d93 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Sun, 1 Mar 2020 07:23:56 -0600 Subject: [PATCH] allow mqtt password to be set by env var --- detect_objects.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/detect_objects.py b/detect_objects.py index a0dd52e3b..f1cbedea4 100644 --- a/detect_objects.py +++ b/detect_objects.py @@ -1,3 +1,4 @@ +import os import cv2 import time import datetime @@ -16,6 +17,8 @@ from frigate.object_processing import TrackedObjectProcessor from frigate.util import EventsPerSecond from frigate.edgetpu import EdgeTPUProcess +FRIGATE_VARS = {k: v for k, v in os.environ.items() if k.startswith('FRIGATE_')} + with open('/config/config.yml') as f: CONFIG = yaml.safe_load(f) @@ -24,6 +27,8 @@ MQTT_PORT = CONFIG.get('mqtt', {}).get('port', 1883) MQTT_TOPIC_PREFIX = CONFIG.get('mqtt', {}).get('topic_prefix', 'frigate') MQTT_USER = CONFIG.get('mqtt', {}).get('user') MQTT_PASS = CONFIG.get('mqtt', {}).get('password') +if not MQTT_PASS is None: + MQTT_PASS = MQTT_PASS.format(**FRIGATE_VARS) MQTT_CLIENT_ID = CONFIG.get('mqtt', {}).get('client_id', 'frigate') # Set the default FFmpeg config