Merge pull request #20 from seblucas/env-var-config-2

Add support for environment variable to load the configuration
This commit is contained in:
2018-10-27 15:30:51 +03:00
committed by GitHub
+4
View File
@@ -1,4 +1,5 @@
import yaml
from os import environ
import logging
_LOGGER = logging.getLogger(__name__)
@@ -6,6 +7,9 @@ _LOGGER = logging.getLogger(__name__)
def load_yaml(file):
try:
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)
return yaml_data