mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Do not round Huawei LTE LTE frequency values (#88127)
Suggest display precision 0 instead. While at it, fix source info in frequency formatter docstring.
This commit is contained in:
parent
cf11a30689
commit
93f23e7523
@ -66,9 +66,9 @@ def format_default(value: StateType) -> tuple[StateType, str | None]:
|
|||||||
|
|
||||||
|
|
||||||
def format_freq_mhz(value: StateType) -> tuple[StateType, UnitOfFrequency]:
|
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 (
|
return (
|
||||||
round(int(value) / 10) if value is not None else None,
|
float(value) / 10 if value is not None else None,
|
||||||
UnitOfFrequency.MEGAHERTZ,
|
UnitOfFrequency.MEGAHERTZ,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -237,6 +237,7 @@ SENSOR_META: dict[str, HuaweiSensorGroup] = {
|
|||||||
key="ltedlfreq",
|
key="ltedlfreq",
|
||||||
name="LTE downlink frequency",
|
name="LTE downlink frequency",
|
||||||
format_fn=format_freq_mhz,
|
format_fn=format_freq_mhz,
|
||||||
|
suggested_display_precision=0,
|
||||||
device_class=SensorDeviceClass.FREQUENCY,
|
device_class=SensorDeviceClass.FREQUENCY,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
),
|
),
|
||||||
@ -244,6 +245,7 @@ SENSOR_META: dict[str, HuaweiSensorGroup] = {
|
|||||||
key="lteulfreq",
|
key="lteulfreq",
|
||||||
name="LTE uplink frequency",
|
name="LTE uplink frequency",
|
||||||
format_fn=format_freq_mhz,
|
format_fn=format_freq_mhz,
|
||||||
|
suggested_display_precision=0,
|
||||||
device_class=SensorDeviceClass.FREQUENCY,
|
device_class=SensorDeviceClass.FREQUENCY,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user