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)
|
||||
):
|
||||
# Unit conversion needed
|
||||
converted_numerical_value = converter.convert(
|
||||
float(numerical_value),
|
||||
converted_numerical_value = converter.converter_factory(
|
||||
native_unit_of_measurement,
|
||||
unit_of_measurement,
|
||||
)
|
||||
)(float(numerical_value))
|
||||
|
||||
# If unit conversion is happening, and there's no rounding for display,
|
||||
# do a best effort rounding here.
|
||||
|
Loading…
x
Reference in New Issue
Block a user