mirror of
https://github.com/home-assistant/core.git
synced 2026-09-05 10:05:52 -05:00
Use compat UOM in _is_valid_suggested_unit (#152350)
Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
co-authored by
Erik Montnemery
parent
51c35eb631
commit
87be2ba823
@@ -371,7 +371,11 @@ class NumberEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
@final
|
||||
@property
|
||||
def __native_unit_of_measurement_compat(self) -> str | None:
|
||||
"""Process ambiguous units."""
|
||||
"""Handle wrong character coding in unit provided by integrations.
|
||||
|
||||
NumberEntity should read the number's native unit through this property instead
|
||||
of through native_unit_of_measurement.
|
||||
"""
|
||||
native_unit_of_measurement = self.native_unit_of_measurement
|
||||
return AMBIGUOUS_UNITS.get(
|
||||
native_unit_of_measurement, native_unit_of_measurement
|
||||
|
||||
@@ -366,7 +366,7 @@ class SensorEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
because a unit converter supports both.
|
||||
"""
|
||||
# No need to check the unit converter if the units are the same
|
||||
if self.native_unit_of_measurement == suggested_unit_of_measurement:
|
||||
if self.__native_unit_of_measurement_compat == suggested_unit_of_measurement:
|
||||
return True
|
||||
|
||||
# Make sure there is a unit converter and it supports both units
|
||||
@@ -478,7 +478,11 @@ class SensorEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
@final
|
||||
@property
|
||||
def __native_unit_of_measurement_compat(self) -> str | None:
|
||||
"""Process ambiguous units."""
|
||||
"""Handle wrong character coding in unit provided by integrations.
|
||||
|
||||
SensorEntity should read the sensor's native unit through this property instead
|
||||
of through native_unit_of_measurement.
|
||||
"""
|
||||
native_unit_of_measurement = self.native_unit_of_measurement
|
||||
return AMBIGUOUS_UNITS.get(
|
||||
native_unit_of_measurement,
|
||||
|
||||
Reference in New Issue
Block a user