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
pull/60814/head
xpac1985 2021-12-01 18:18:58 +01:00 committed by GitHub
parent a6ec646f98
commit b41e020f85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -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))