mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Do not validate device classes when entity state is unknown (#84860)
This commit is contained in:
parent
7a7f986444
commit
f8fa676ac8
@ -968,6 +968,7 @@ class SensorEntity(Entity):
|
||||
# Validate unit of measurement used for sensors with a device class
|
||||
if (
|
||||
not self._invalid_unit_of_measurement_reported
|
||||
and value is not None
|
||||
and device_class
|
||||
and (units := DEVICE_CLASS_UNITS.get(device_class)) is not None
|
||||
and native_unit_of_measurement not in units
|
||||
|
@ -1144,7 +1144,7 @@ async def test_device_classes_with_invalid_unit_of_measurement(
|
||||
platform.init(empty=True)
|
||||
platform.ENTITIES["0"] = platform.MockSensor(
|
||||
name="Test",
|
||||
native_value=None,
|
||||
native_value="1.0",
|
||||
device_class=device_class,
|
||||
native_unit_of_measurement="INVALID!",
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user