Example #1
0
def load_config(path):
    try:
        config = yaml_util.load_yaml(path)
    except OSError:
        raise ESPHomeYAMLError(
            u"Could not read configuration file at {}".format(path))
    core.RAW_CONFIG = config

    if CONF_ESPHOMEYAML not in config:
        raise ESPHomeYAMLError(u"No esphomeyaml section in config")
    core_conf = config[CONF_ESPHOMEYAML]
    if CONF_PLATFORM not in core_conf:
        raise ESPHomeYAMLError("esphomeyaml.platform not specified.")
    esp_platform = unicode(core_conf[CONF_PLATFORM])
    esp_platform = esp_platform.upper()
    if '8266' in esp_platform:
        esp_platform = ESP_PLATFORM_ESP8266
    if '32' in esp_platform:
        esp_platform = ESP_PLATFORM_ESP32
    core.ESP_PLATFORM = esp_platform
    if CONF_BOARD not in core_conf:
        raise ESPHomeYAMLError("esphomeyaml.board not specified.")
    core.BOARD = unicode(core_conf[CONF_BOARD])
    core.SIMPLIFY = cv.boolean(core_conf.get(CONF_SIMPLIFY, True))

    try:
        result = validate_config(config)
    except Exception:
        print(u"Unexpected exception while reading configuration:")
        raise

    return result
Example #2
0
def load_config(path):
    try:
        config = yaml_util.load_yaml(path)
    except OSError:
        raise ESPHomeYAMLError(u"Could not read configuration file at {}".format(path))
    core.RAW_CONFIG = config
    core_config.preload_core_config(config)

    try:
        result = validate_config(config)
    except ESPHomeYAMLError:
        raise
    except Exception:
        _LOGGER.error(u"Unexpected exception while reading configuration:")
        raise

    return result
Example #3
0
def load_config():
    try:
        config = yaml_util.load_yaml(CORE.config_path)
    except OSError:
        raise EsphomeyamlError(u"Invalid YAML at {}".format(CORE.config_path))
    CORE.raw_config = config
    config = substitutions.do_substitution_pass(config)
    core_config.preload_core_config(config)

    try:
        result = validate_config(config)
    except EsphomeyamlError:
        raise
    except Exception:
        _LOGGER.error(u"Unexpected exception while reading configuration:")
        raise

    return result