Merge pull request #1294 from home-assistant/dev

Release 188
This commit is contained in:
Pascal Vizeli 2019-09-15 15:07:39 +02:00 committed by GitHub
commit 120465b88d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -2,7 +2,7 @@
from pathlib import Path
from ipaddress import ip_network
HASSIO_VERSION = "187"
HASSIO_VERSION = "188"
URL_HASSIO_ADDONS = "https://github.com/home-assistant/hassio-addons"

View File

@ -5,12 +5,15 @@ from pathlib import Path
from typing import Dict
from ruamel.yaml import YAML, YAMLError
import voluptuous as vol
from .coresys import CoreSys, CoreSysAttributes
from .utils import AsyncThrottle
_LOGGER: logging.Logger = logging.getLogger(__name__)
SECRETS_SCHEMA = vol.Schema({str: vol.Any(str, int, None, float)})
class SecretsManager(CoreSysAttributes):
"""Manage Home Assistant secrets."""
@ -50,8 +53,12 @@ class SecretsManager(CoreSysAttributes):
# Read secrets
try:
yaml = YAML()
self.secrets = await self.sys_run_in_executor(yaml.load, self.path_secrets)
data = await self.sys_run_in_executor(yaml.load, self.path_secrets) or {}
self.secrets = SECRETS_SCHEMA(data)
except YAMLError as err:
_LOGGER.error("Can't process Home Assistant secrets: %s", err)
except vol.Invalid:
_LOGGER.warning("Home Assistant secrets have a invalid format")
else:
_LOGGER.debug("Reload Home Assistant secrets: %s", len(self.secrets))