From bcbf0061fff35a0e6914668e1823d9f50325e5a9 Mon Sep 17 00:00:00 2001 From: Pierre Belanger Date: Sat, 7 Jan 2023 18:10:48 -0500 Subject: [PATCH] Support for dynamic MQTT user configuration #4883 (#4956) * Support for dynamic MQTT user configuration #4883 * Fix substitute condition & docs --- docs/docs/configuration/index.md | 2 ++ frigate/config.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/docs/configuration/index.md b/docs/docs/configuration/index.md index 0489da3aa..0c46c4028 100644 --- a/docs/docs/configuration/index.md +++ b/docs/docs/configuration/index.md @@ -52,6 +52,8 @@ mqtt: # NOTE: must be unique if you are running multiple instances client_id: frigate # Optional: user + # NOTE: MQTT user can be specified with an environment variables that must begin with 'FRIGATE_'. + # e.g. user: '{FRIGATE_MQTT_USER}' user: mqtt_user # Optional: password # NOTE: MQTT password can be specified with an environment variables that must begin with 'FRIGATE_'. diff --git a/frigate/config.py b/frigate/config.py index 6e6c120be..7c4e945aa 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -863,8 +863,9 @@ class FrigateConfig(FrigateBaseModel): """Merge camera config with globals.""" config = self.copy(deep=True) - # MQTT password substitution - if config.mqtt.password: + # MQTT user/password substitutions + if config.mqtt.user or config.mqtt.password: + config.mqtt.user = config.mqtt.user.format(**FRIGATE_ENV_VARS) config.mqtt.password = config.mqtt.password.format(**FRIGATE_ENV_VARS) # Global config to propagate down to camera level