def _load_config(self, force): """Load the actual config.""" # Check for a cached version of the config if not force and self._cache is not None: config, last_update = self._cache modtime = os.path.getmtime(self.path) if config and last_update > modtime: return False, config is_updated = self._cache is not None try: config = load_yaml(self.path, Secrets(Path(self.hass.config.config_dir))) except FileNotFoundError: raise ConfigNotFound from None self._cache = (config, time.time()) return is_updated, config
async def async_hass_config_yaml(hass: HomeAssistant) -> dict: """Load YAML from a Home Assistant configuration file. This function allow a component inside the asyncio loop to reload its configuration by itself. Include package merge. """ if hass.config.config_dir is None: secrets = None else: secrets = Secrets(Path(hass.config.config_dir)) # Not using async_add_executor_job because this is an internal method. config = await hass.loop.run_in_executor( None, load_yaml_config_file, hass.config.path(YAML_CONFIG_FILE), secrets, ) core_config = config.get(CONF_CORE, {}) await merge_packages_config(hass, config, core_config.get(CONF_PACKAGES, {})) return config
def secrets_proxy(*args): secrets = Secrets(*args) res["secret_cache"] = secrets._cache return secrets