Protect Huawei LTE against None ltedl/ulfreq (#54411)

Refs https://github.com/home-assistant/core/issues/54400
This commit is contained in:
Ville Skyttä 2021-09-05 21:42:22 +03:00 committed by GitHub
parent 5a2bcd2763
commit 4e1e7a4a71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -193,11 +193,17 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
),
(KEY_DEVICE_SIGNAL, "ltedlfreq"): SensorMeta(
name="Downlink frequency",
formatter=lambda x: (round(int(x) / 10), FREQUENCY_MEGAHERTZ),
formatter=lambda x: (
round(int(x) / 10) if x is not None else None,
FREQUENCY_MEGAHERTZ,
),
),
(KEY_DEVICE_SIGNAL, "lteulfreq"): SensorMeta(
name="Uplink frequency",
formatter=lambda x: (round(int(x) / 10), FREQUENCY_MEGAHERTZ),
formatter=lambda x: (
round(int(x) / 10) if x is not None else None,
FREQUENCY_MEGAHERTZ,
),
),
KEY_MONITORING_CHECK_NOTIFICATIONS: SensorMeta(
exclude=re.compile(