mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +00:00
Use converter factory in sensor platform (#106508)
This is a bit faster than calling .covert
This commit is contained in:
parent
f59e2b0eec
commit
178e4f9e25
@ -671,11 +671,10 @@ class SensorEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
|||||||
converter := UNIT_CONVERTERS.get(device_class)
|
converter := UNIT_CONVERTERS.get(device_class)
|
||||||
):
|
):
|
||||||
# Unit conversion needed
|
# Unit conversion needed
|
||||||
converted_numerical_value = converter.convert(
|
converted_numerical_value = converter.converter_factory(
|
||||||
float(numerical_value),
|
|
||||||
native_unit_of_measurement,
|
native_unit_of_measurement,
|
||||||
unit_of_measurement,
|
unit_of_measurement,
|
||||||
)
|
)(float(numerical_value))
|
||||||
|
|
||||||
# If unit conversion is happening, and there's no rounding for display,
|
# If unit conversion is happening, and there's no rounding for display,
|
||||||
# do a best effort rounding here.
|
# do a best effort rounding here.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user