diff --git a/homeassistant/__init__.py b/homeassistant/__init__.py index 132482d4bfa..09069924e6b 100644 --- a/homeassistant/__init__.py +++ b/homeassistant/__init__.py @@ -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, } diff --git a/homeassistant/__main__.py b/homeassistant/__main__.py index 83a8c499718..316529ce74e 100644 --- a/homeassistant/__main__.py +++ b/homeassistant/__main__.py @@ -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) diff --git a/homeassistant/config.py b/homeassistant/config.py index b4f70cd1952..b24c224f543 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -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(