From 297e2f1c0c2b56d9b8576094fbfda575335f93e2 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Sun, 8 Dec 2019 09:09:55 -0600 Subject: [PATCH] allow mqtt client_id to be set for multi frigate setups --- config/config.example.yml | 1 + detect_objects.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/config.example.yml b/config/config.example.yml index ed16b53f7..d8b42224b 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -3,6 +3,7 @@ web_port: 5000 mqtt: host: mqtt.server.com topic_prefix: frigate +# client_id: frigate # Optional -- set to override default client id of 'frigate' if running multiple instances # user: username # Optional -- Uncomment for use # password: password # Optional -- Uncomment for use diff --git a/detect_objects.py b/detect_objects.py index a3dfb2215..474c9c2b6 100644 --- a/detect_objects.py +++ b/detect_objects.py @@ -17,6 +17,7 @@ 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') +MQTT_CLIENT_ID = CONFIG.get('mqtt', {}).get('client_id', 'frigate') WEB_PORT = CONFIG.get('web_port', 5000) DEBUG = (CONFIG.get('debug', '0') == '1') @@ -36,7 +37,7 @@ def main(): print ("Unable to connect to MQTT: Connection refused. Error code: " + str(rc)) # publish a message to signal that the service is running client.publish(MQTT_TOPIC_PREFIX+'/available', 'online', retain=True) - client = mqtt.Client(client_id="frigate") + client = mqtt.Client(client_id=MQTT_CLIENT_ID) client.on_connect = on_connect client.will_set(MQTT_TOPIC_PREFIX+'/available', payload='offline', qos=1, retain=True) if not MQTT_USER is None: