Merge branch 'dev-clean' into vera-fixes

Merged with upstream changes
This commit is contained in:
jamespcole 2015-05-18 19:27:21 +10:00
commit 39dee9d17c
3 changed files with 30 additions and 11 deletions

View File

@ -961,12 +961,14 @@ class Config(object):
def as_dict(self):
""" Converts config to a dictionary. """
time_zone = self.time_zone or date_util.UTC
return {
'latitude': self.latitude,
'longitude': self.longitude,
'temperature_unit': self.temperature_unit,
'location_name': self.location_name,
'time_zone': self.time_zone.zone,
'time_zone': time_zone.zone,
'components': self.components,
}

View File

@ -141,9 +141,9 @@ def main():
def open_browser(event):
""" Open the webinterface in a browser. """
if hass.local_api is not None:
if hass.config.api is not None:
import webbrowser
webbrowser.open(hass.local_api.base_url)
webbrowser.open(hass.config.api.base_url)
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, open_browser)

View File

@ -103,15 +103,32 @@ def load_yaml_config_file(config_path):
""" Parse a YAML configuration file. """
import yaml
try:
with open(config_path) as conf_file:
# If configuration file is empty YAML returns None
# We convert that to an empty dict
conf_dict = yaml.load(conf_file) or {}
def parse(fname):
""" Actually parse the file. """
try:
with open(fname) as conf_file:
# If configuration file is empty YAML returns None
# We convert that to an empty dict
conf_dict = yaml.load(conf_file) or {}
except yaml.YAMLError:
_LOGGER.exception('Error reading YAML configuration file %s',
fname)
raise HomeAssistantError()
return conf_dict
except yaml.YAMLError:
_LOGGER.exception('Error reading YAML configuration file')
raise HomeAssistantError()
def yaml_include(loader, node):
"""
Loads another YAML file and embeds it using the !include tag.
Example:
device_tracker: !include device_tracker.yaml
"""
fname = os.path.join(os.path.dirname(loader.name), node.value)
return parse(fname)
yaml.add_constructor('!include', yaml_include)
conf_dict = parse(config_path)
if not isinstance(conf_dict, dict):
_LOGGER.error(