mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
sanitize state_classes (#70090)
This commit is contained in:
parent
abea7d3245
commit
012ef6bb7b
@ -19,6 +19,7 @@ from homeassistant.components.sensor import (
|
|||||||
DEVICE_CLASSES as SENSOR_DEVICE_CLASSES,
|
DEVICE_CLASSES as SENSOR_DEVICE_CLASSES,
|
||||||
DOMAIN as SENSOR_DOMAIN,
|
DOMAIN as SENSOR_DOMAIN,
|
||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
|
STATE_CLASSES as SENSOR_STATE_CLASSES,
|
||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
)
|
)
|
||||||
@ -262,7 +263,10 @@ class SensorFilter(SensorEntity):
|
|||||||
):
|
):
|
||||||
self._device_class = new_state.attributes.get(ATTR_DEVICE_CLASS)
|
self._device_class = new_state.attributes.get(ATTR_DEVICE_CLASS)
|
||||||
|
|
||||||
if self._attr_state_class is None:
|
if (
|
||||||
|
self._attr_state_class is None
|
||||||
|
and new_state.attributes.get(ATTR_STATE_CLASS) in SENSOR_STATE_CLASSES
|
||||||
|
):
|
||||||
self._attr_state_class = new_state.attributes.get(ATTR_STATE_CLASS)
|
self._attr_state_class = new_state.attributes.get(ATTR_STATE_CLASS)
|
||||||
|
|
||||||
if self._unit_of_measurement is None:
|
if self._unit_of_measurement is None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user