Added support for YAML configuration files

This commit is contained in:
theolind 2015-02-28 16:56:58 +01:00
parent 4ef17270b5
commit 356732189c
2 changed files with 15 additions and 9 deletions

View File

@ -110,17 +110,20 @@ def from_config_file(config_path, hass=None):
# Set config dir to directory holding config file
hass.config_dir = os.path.abspath(os.path.dirname(config_path))
# Read config
config = configparser.ConfigParser()
config.read(config_path)
# check config file type
if(os.path.splitext(config_path)[1] == '.yaml'):
# Read yaml
config_dict = yaml.load(io.open(config_path, 'r'))
else:
# Read config
config = configparser.ConfigParser()
config.read(config_path)
config_dict = {}
for section in config.sections():
config_dict[section] = {}
for section in config.sections():
config_dict[section] = {}
for key, val in config.items(section):
config_dict[section][key] = val
for key, val in config.items(section):
config_dict[section][key] = val
return from_config_dict(config_dict, hass)

View File

@ -29,3 +29,6 @@ pushbullet.py>=0.7.1
# thermostat.nest
python-nest>=2.1
# pyyaml
pyyaml