mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 10:47:10 +00:00
Merge branch 'dev-clean' into vera-fixes
Merged with upstream changes
This commit is contained in:
commit
39dee9d17c
@ -961,12 +961,14 @@ class Config(object):
|
|||||||
|
|
||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
""" Converts config to a dictionary. """
|
""" Converts config to a dictionary. """
|
||||||
|
time_zone = self.time_zone or date_util.UTC
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'latitude': self.latitude,
|
'latitude': self.latitude,
|
||||||
'longitude': self.longitude,
|
'longitude': self.longitude,
|
||||||
'temperature_unit': self.temperature_unit,
|
'temperature_unit': self.temperature_unit,
|
||||||
'location_name': self.location_name,
|
'location_name': self.location_name,
|
||||||
'time_zone': self.time_zone.zone,
|
'time_zone': time_zone.zone,
|
||||||
'components': self.components,
|
'components': self.components,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,9 +141,9 @@ def main():
|
|||||||
|
|
||||||
def open_browser(event):
|
def open_browser(event):
|
||||||
""" Open the webinterface in a browser. """
|
""" Open the webinterface in a browser. """
|
||||||
if hass.local_api is not None:
|
if hass.config.api is not None:
|
||||||
import webbrowser
|
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)
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, open_browser)
|
||||||
|
|
||||||
|
@ -103,15 +103,32 @@ def load_yaml_config_file(config_path):
|
|||||||
""" Parse a YAML configuration file. """
|
""" Parse a YAML configuration file. """
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
try:
|
def parse(fname):
|
||||||
with open(config_path) as conf_file:
|
""" Actually parse the file. """
|
||||||
# If configuration file is empty YAML returns None
|
try:
|
||||||
# We convert that to an empty dict
|
with open(fname) as conf_file:
|
||||||
conf_dict = yaml.load(conf_file) or {}
|
# 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:
|
def yaml_include(loader, node):
|
||||||
_LOGGER.exception('Error reading YAML configuration file')
|
"""
|
||||||
raise HomeAssistantError()
|
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):
|
if not isinstance(conf_dict, dict):
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user