From 93f23e7523bea3d7c7d8a0b9185cb954166353f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 15 Feb 2023 16:28:35 +0200 Subject: [PATCH] Do not round Huawei LTE LTE frequency values (#88127) Suggest display precision 0 instead. While at it, fix source info in frequency formatter docstring. --- homeassistant/components/huawei_lte/sensor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/huawei_lte/sensor.py b/homeassistant/components/huawei_lte/sensor.py index 3a59f9a751b..70526929277 100644 --- a/homeassistant/components/huawei_lte/sensor.py +++ b/homeassistant/components/huawei_lte/sensor.py @@ -66,9 +66,9 @@ def format_default(value: StateType) -> tuple[StateType, str | None]: def format_freq_mhz(value: StateType) -> tuple[StateType, UnitOfFrequency]: - """Format a frequency value for which source is in tens of MHz.""" + """Format a frequency value for which source is in tenths of MHz.""" return ( - round(int(value) / 10) if value is not None else None, + float(value) / 10 if value is not None else None, UnitOfFrequency.MEGAHERTZ, ) @@ -237,6 +237,7 @@ SENSOR_META: dict[str, HuaweiSensorGroup] = { key="ltedlfreq", name="LTE downlink frequency", format_fn=format_freq_mhz, + suggested_display_precision=0, device_class=SensorDeviceClass.FREQUENCY, entity_category=EntityCategory.DIAGNOSTIC, ), @@ -244,6 +245,7 @@ SENSOR_META: dict[str, HuaweiSensorGroup] = { key="lteulfreq", name="LTE uplink frequency", format_fn=format_freq_mhz, + suggested_display_precision=0, device_class=SensorDeviceClass.FREQUENCY, entity_category=EntityCategory.DIAGNOSTIC, ),