Support for dynamic MQTT user configuration #4883 (#4956)

* Support for dynamic MQTT user configuration #4883

* Fix substitute condition & docs
This commit is contained in:
Pierre Belanger 2023-01-07 18:10:48 -05:00 committed by GitHub
parent 57dce4ec38
commit bcbf0061ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -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_'.

View File

@ -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