diff --git a/homeassistant/components/binary_sensor/template.py b/homeassistant/components/binary_sensor/template.py index e097c7c0ea4..fa60412c77f 100644 --- a/homeassistant/components/binary_sensor/template.py +++ b/homeassistant/components/binary_sensor/template.py @@ -118,7 +118,8 @@ class BinarySensorTemplate(BinarySensorDevice): if ex.args and ex.args[0].startswith( "UndefinedError: 'None' has no attribute"): # 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 - _LOGGER.error(ex) + _LOGGER.error('Could not render template %s: %s', self._name, ex) self._state = False diff --git a/homeassistant/components/sensor/template.py b/homeassistant/components/sensor/template.py index 2535bea1539..aba42519e60 100644 --- a/homeassistant/components/sensor/template.py +++ b/homeassistant/components/sensor/template.py @@ -131,10 +131,11 @@ class SensorTemplate(Entity): if ex.args and ex.args[0].startswith( "UndefinedError: 'None' has no attribute"): # 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 self._state = None - _LOGGER.error(ex) + _LOGGER.error('Could not render template %s: %s', self._name, ex) if self._icon_template is not None: try: @@ -143,7 +144,9 @@ class SensorTemplate(Entity): if ex.args and ex.args[0].startswith( "UndefinedError: 'None' has no attribute"): # 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 self._icon = super().icon - _LOGGER.error(ex) + _LOGGER.error('Could not render icon template %s: %s', + self._name, ex)