From 178e4f9e25cd8e7562fe4b8801523f4a9acc043c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 27 Dec 2023 13:06:36 -1000 Subject: [PATCH] Use converter factory in sensor platform (#106508) This is a bit faster than calling .covert --- homeassistant/components/sensor/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/sensor/__init__.py b/homeassistant/components/sensor/__init__.py index 5fca119d5b5..c82254bdcb1 100644 --- a/homeassistant/components/sensor/__init__.py +++ b/homeassistant/components/sensor/__init__.py @@ -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.