mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Improve warning message in template rendering (#5806)
* improve warning message when template is none * improve error message when template is none * improve error message when template is none * improve error message when template is none
This commit is contained in:
parent
db6c166abe
commit
08efe2bf6d
@ -118,7 +118,8 @@ class BinarySensorTemplate(BinarySensorDevice):
|
|||||||
if ex.args and ex.args[0].startswith(
|
if ex.args and ex.args[0].startswith(
|
||||||
"UndefinedError: 'None' has no attribute"):
|
"UndefinedError: 'None' has no attribute"):
|
||||||
# Common during HA startup - so just a warning
|
# Common during HA startup - so just a warning
|
||||||
_LOGGER.warning(ex)
|
_LOGGER.warning('Could not render template %s,'
|
||||||
|
' the state is unknown.', self._name)
|
||||||
return
|
return
|
||||||
_LOGGER.error(ex)
|
_LOGGER.error('Could not render template %s: %s', self._name, ex)
|
||||||
self._state = False
|
self._state = False
|
||||||
|
@ -131,10 +131,11 @@ class SensorTemplate(Entity):
|
|||||||
if ex.args and ex.args[0].startswith(
|
if ex.args and ex.args[0].startswith(
|
||||||
"UndefinedError: 'None' has no attribute"):
|
"UndefinedError: 'None' has no attribute"):
|
||||||
# Common during HA startup - so just a warning
|
# Common during HA startup - so just a warning
|
||||||
_LOGGER.warning(ex)
|
_LOGGER.warning('Could not render template %s,'
|
||||||
|
' the state is unknown.', self._name)
|
||||||
return
|
return
|
||||||
self._state = None
|
self._state = None
|
||||||
_LOGGER.error(ex)
|
_LOGGER.error('Could not render template %s: %s', self._name, ex)
|
||||||
|
|
||||||
if self._icon_template is not None:
|
if self._icon_template is not None:
|
||||||
try:
|
try:
|
||||||
@ -143,7 +144,9 @@ class SensorTemplate(Entity):
|
|||||||
if ex.args and ex.args[0].startswith(
|
if ex.args and ex.args[0].startswith(
|
||||||
"UndefinedError: 'None' has no attribute"):
|
"UndefinedError: 'None' has no attribute"):
|
||||||
# Common during HA startup - so just a warning
|
# Common during HA startup - so just a warning
|
||||||
_LOGGER.warning(ex)
|
_LOGGER.warning('Could not render icon template %s,'
|
||||||
|
' the state is unknown.', self._name)
|
||||||
return
|
return
|
||||||
self._icon = super().icon
|
self._icon = super().icon
|
||||||
_LOGGER.error(ex)
|
_LOGGER.error('Could not render icon template %s: %s',
|
||||||
|
self._name, ex)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user