Add persistent notification

This commit is contained in:
Otto Winter 2019-02-15 18:40:46 +01:00
parent f6ae054e9f
commit 06f2aa93a4
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E
2 changed files with 28 additions and 9 deletions

View file

@ -25,8 +25,6 @@ from homeassistant.helpers import template as template_helper
from homeassistant.helpers.logging import KeywordStyleAdapter
from homeassistant.util import slugify as util_slugify
_LOGGER = logging.getLogger(__name__)
# pylint: disable=invalid-name
TIME_PERIOD_ERROR = "offset {} should be format 'HH:MM' or 'HH:MM:SS'"
@ -36,6 +34,7 @@ OLD_ENTITY_ID_VALIDATION = r"^(\w+)\.(\w+)$"
# persistent notification. Rare temporary exception to use a global.
INVALID_SLUGS_FOUND = {}
INVALID_ENTITY_IDS_FOUND = {}
INVALID_EXTRA_KEYS_FOUND = []
# Home Assistant types
@ -661,14 +660,17 @@ class HASchema(vol.Schema):
if err.error_message == 'extra keys not allowed']
if extra_key_errs:
msg = "Your configuration contains extra keys " \
"that the platform does not support. The keys "
msg += ', '.join('[{}]'.format(err.path[-1]) for err in
extra_key_errs)
msg += ' are 42.'
"that the platform does not support.\n" \
"Please remove "
submsg = ', '.join('[{}]'.format(err.path[-1]) for err in
extra_key_errs)
submsg += '. '
if hasattr(data, '__config_file__'):
msg += " (See {}, line {}). ".format(data.__config_file__,
data.__line__)
_LOGGER.warning(msg)
submsg += " (See {}, line {}). ".format(
data.__config_file__, data.__line__)
msg += submsg
logging.getLogger(__name__).warning(msg)
INVALID_EXTRA_KEYS_FOUND.append(submsg)
else:
# This should not happen (all errors should be extra key
# errors). Let's raise the original error anyway.