mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 18:48:22 +00:00
Do not cache unit of measurement
This commit is contained in:
parent
6e52d0ddb1
commit
0f515868c1
@ -470,10 +470,12 @@ class SensorEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
|||||||
return self.entity_description.native_unit_of_measurement
|
return self.entity_description.native_unit_of_measurement
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@cached_property
|
@final
|
||||||
|
@property
|
||||||
def __native_unit_of_measurement_compat(self) -> str | None:
|
def __native_unit_of_measurement_compat(self) -> str | None:
|
||||||
"""Process ambiguous units."""
|
"""Process ambiguous units."""
|
||||||
native_unit_of_measurement = self.native_unit_of_measurement
|
if (native_unit_of_measurement := self.native_unit_of_measurement) is None:
|
||||||
|
return None
|
||||||
return AMBIGUOUS_UNITS.get(
|
return AMBIGUOUS_UNITS.get(
|
||||||
native_unit_of_measurement, native_unit_of_measurement
|
native_unit_of_measurement, native_unit_of_measurement
|
||||||
)
|
)
|
||||||
|
@ -772,7 +772,7 @@ STATE_CLASS_UNITS: dict[SensorStateClass | str, set[type[StrEnum] | str | None]]
|
|||||||
SensorStateClass.MEASUREMENT_ANGLE: {DEGREE},
|
SensorStateClass.MEASUREMENT_ANGLE: {DEGREE},
|
||||||
}
|
}
|
||||||
|
|
||||||
AMBIGUOUS_UNITS: dict[str | None, str | None] = {
|
AMBIGUOUS_UNITS: dict[str, str] = {
|
||||||
"\u00b5Sv/h": "μSv/h", # aranet: radiation rate
|
"\u00b5Sv/h": "μSv/h", # aranet: radiation rate
|
||||||
"\u00b5S/cm": UnitOfConductivity.MICROSIEMENS_PER_CM,
|
"\u00b5S/cm": UnitOfConductivity.MICROSIEMENS_PER_CM,
|
||||||
"\u00b5V": UnitOfElectricPotential.MICROVOLT,
|
"\u00b5V": UnitOfElectricPotential.MICROVOLT,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user