[feat] The configuration can also be loaded from an environment variable
This commit is contained in:
+5
-1
@@ -1,4 +1,5 @@
|
|||||||
import yaml
|
import yaml
|
||||||
|
from os import environ
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@@ -6,7 +7,10 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
def load_yaml(file):
|
def load_yaml(file):
|
||||||
try:
|
try:
|
||||||
stram = open(file, "r")
|
if environ.get("AQARA_MQTT_CONFIG") is not None:
|
||||||
|
stram = environ.get("AQARA_MQTT_CONFIG")
|
||||||
|
else:
|
||||||
|
stram = open(file, "r")
|
||||||
yaml_data = yaml.load(stram)
|
yaml_data = yaml.load(stram)
|
||||||
return yaml_data
|
return yaml_data
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user