Skip to content

Commit

Permalink
Catch more error types
Browse files Browse the repository at this point in the history
  • Loading branch information
pilotak committed May 31, 2020
2 parents 847e550 + 68a1e2b commit 0070d35
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions custom_components/attributes/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,11 @@ def async_update(self):
try:
self._state = self._template.async_render()
except TemplateError as ex:
if ex.args and ex.args[0].startswith(
"UndefinedError: 'None' has no attribute"):
if ex.args and (
ex.args[0].startswith(
"UndefinedError: 'None' has no attribute") or
ex.args[0].startswith(
"UndefinedError: 'mappingproxy object' has no attribute")):
# Common during HA startup - so just a warning
_LOGGER.warning('Could not render attribute sensor for %s,'
' the state is unknown.', self._entity)
Expand All @@ -244,8 +247,11 @@ def async_update(self):
try:
self._icon = self._icon_template.async_render()
except TemplateError as ex:
if ex.args and ex.args[0].startswith(
"UndefinedError: 'None' has no attribute"):
if ex.args and (
ex.args[0].startswith(
"UndefinedError: 'None' has no attribute") or
ex.args[0].startswith(
"UndefinedError: 'mappingproxy object' has no attribute")):
# Common during HA startup - so just a warning
_LOGGER.warning('Could not render icon template %s,'
' the state is unknown.', self._name)
Expand Down

0 comments on commit 0070d35

Please sign in to comment.