diff --git a/README.md b/README.md index 05a1404c6..ff06c9fb9 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ docker run --rm \ -e RTSP_URL='' \ -e REGIONS=',,,,,:,,,,,' \ -e MQTT_HOST='your.mqtthost.com' \ +-e MQTT_USER='username' \ +-e MQTT_PASS='password' \ -e MQTT_TOPIC_PREFIX='cameras/1' \ -e DEBUG='0' \ frigate:latest @@ -57,6 +59,8 @@ Example docker-compose: RTSP_URL: "" REGIONS: ",,,,,:,,,,," MQTT_HOST: "your.mqtthost.com" + MQTT_USER: "username" #optional + MQTT_PASS: "password" #optional MQTT_TOPIC_PREFIX: "cameras/1" DEBUG: "0" ``` diff --git a/detect_objects.py b/detect_objects.py index 0171e767d..00468775b 100644 --- a/detect_objects.py +++ b/detect_objects.py @@ -24,6 +24,8 @@ from frigate.object_detection import detect_objects RTSP_URL = os.getenv('RTSP_URL') MQTT_HOST = os.getenv('MQTT_HOST') +MQTT_USER = os.getenv('MQTT_USER') +MQTT_PASS = os.getenv('MQTT_PASS') MQTT_TOPIC_PREFIX = os.getenv('MQTT_TOPIC_PREFIX') # REGIONS = "350,0,300,50:400,350,250,50:400,750,250,50" @@ -145,6 +147,9 @@ def main(): client = mqtt.Client() client.on_connect = on_connect client.will_set(MQTT_TOPIC_PREFIX+'/available', payload='offline', qos=1, retain=True) + if not MQTT_USER is None: + client.username_pw_set(MQTT_USER, password=MQTT_PASS) + client.connect(MQTT_HOST, 1883, 60) client.loop_start()