From b41e020f85e15fa829aae573ca9fc6b01605407f Mon Sep 17 00:00:00 2001 From: xpac1985 Date: Wed, 1 Dec 2021 18:18:58 +0100 Subject: [PATCH] Better warning if unit of sensor is unsupported for its device class (#60665) * Better warning if unit of sensor is unsupported for its device class * Prettify the code --- homeassistant/components/sensor/recorder.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/recorder.py b/homeassistant/components/sensor/recorder.py index 8bddc74693e..25cb81ded12 100644 --- a/homeassistant/components/sensor/recorder.py +++ b/homeassistant/components/sensor/recorder.py @@ -266,7 +266,12 @@ def _normalize_states( hass.data[WARN_UNSUPPORTED_UNIT] = set() if entity_id not in hass.data[WARN_UNSUPPORTED_UNIT]: hass.data[WARN_UNSUPPORTED_UNIT].add(entity_id) - _LOGGER.warning("%s has unknown unit %s", entity_id, unit) + _LOGGER.warning( + "%s has unit %s which is unsupported for device_class %s", + entity_id, + unit, + device_class, + ) continue fstates.append((UNIT_CONVERSIONS[device_class][unit](fstate), state))