File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 44import argparse
55import logging .config
66import sys
7+ from os import getenv
78from copy import deepcopy
89from hashlib import sha256
910from typing import Any , Optional
@@ -76,6 +77,16 @@ def main() -> None:
7677 # Load, validate and normalise config, or quit.
7778 try :
7879 raw_config = load_config (args .config , args .render )
80+ if raw_config :
81+ if "mqtt" not in raw_config or raw_config ["mqtt" ] is None :
82+ raw_config ["mqtt" ] = {}
83+ raw_config ["mqtt" ]["host" ] = getenv ("MQTT_IO_HOST" , raw_config ["mqtt" ].get ("host" ))
84+ raw_config ["mqtt" ]["port" ] = getenv ("MQTT_IO_PORT" , raw_config ["mqtt" ].get ("port" ))
85+ raw_config ["mqtt" ]["user" ] = getenv ("MQTT_IO_USER" , raw_config ["mqtt" ].get ("user" ))
86+ raw_config ["mqtt" ]["password" ] = getenv ("MQTT_IO_PASSWORD" ,
87+ raw_config ["mqtt" ].get ("password" ))
88+ raw_config ["mqtt" ]["protocol" ] = getenv ("MQTT_IO_PROTOCOL" ,
89+ raw_config ["mqtt" ].get ("protocol" ))
7990 config = validate_and_normalise_main_config (raw_config )
8091 except ConfigValidationFailed as exc :
8192 print (str (exc ), file = sys .stderr )
You can’t perform that action at this time.
0 commit comments