Sfoglia il codice sorgente

allow mqtt client_id to be set for multi frigate setups

Blake Blackshear 5 anni fa
parent
commit
297e2f1c0c
2 ha cambiato i file con 3 aggiunte e 1 eliminazioni
  1. 1 0
      config/config.example.yml
  2. 2 1
      detect_objects.py

+ 1 - 0
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
 

+ 2 - 1
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: