From b9a72034f99c535c5c5d238aa0c879c5f7e996eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 6 May 2019 20:15:28 +0300 Subject: [PATCH] huawei_lte: handle icons for None sensor values gracefully (#23649) --- homeassistant/components/huawei_lte/sensor.py | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/huawei_lte/sensor.py b/homeassistant/components/huawei_lte/sensor.py index 008e54e88a5..5dac3c2c787 100644 --- a/homeassistant/components/huawei_lte/sensor.py +++ b/homeassistant/components/huawei_lte/sensor.py @@ -62,37 +62,37 @@ SENSOR_META = { name="RSRQ", # http://www.lte-anbieter.info/technik/rsrq.php icon=lambda x: - x >= -5 and "mdi:signal-cellular-3" - or x >= -8 and "mdi:signal-cellular-2" - or x >= -11 and "mdi:signal-cellular-1" - or "mdi:signal-cellular-outline" + (x is None or x < -11) and "mdi:signal-cellular-outline" + or x < -8 and "mdi:signal-cellular-1" + or x < -5 and "mdi:signal-cellular-2" + or "mdi:signal-cellular-3" ), "device_signal.rsrp": dict( name="RSRP", # http://www.lte-anbieter.info/technik/rsrp.php icon=lambda x: - x >= -80 and "mdi:signal-cellular-3" - or x >= -95 and "mdi:signal-cellular-2" - or x >= -110 and "mdi:signal-cellular-1" - or "mdi:signal-cellular-outline" + (x is None or x < -110) and "mdi:signal-cellular-outline" + or x < -95 and "mdi:signal-cellular-1" + or x < -80 and "mdi:signal-cellular-2" + or "mdi:signal-cellular-3" ), "device_signal.rssi": dict( name="RSSI", # https://eyesaas.com/wi-fi-signal-strength/ icon=lambda x: - x >= -60 and "mdi:signal-cellular-3" - or x >= -70 and "mdi:signal-cellular-2" - or x >= -80 and "mdi:signal-cellular-1" - or "mdi:signal-cellular-outline" + (x is None or x < -80) and "mdi:signal-cellular-outline" + or x < -70 and "mdi:signal-cellular-1" + or x < -60 and "mdi:signal-cellular-2" + or "mdi:signal-cellular-3" ), "device_signal.sinr": dict( name="SINR", # http://www.lte-anbieter.info/technik/sinr.php icon=lambda x: - x >= 10 and "mdi:signal-cellular-3" - or x >= 5 and "mdi:signal-cellular-2" - or x >= 0 and "mdi:signal-cellular-1" - or "mdi:signal-cellular-outline" + (x is None or x < 0) and "mdi:signal-cellular-outline" + or x < 5 and "mdi:signal-cellular-1" + or x < 10 and "mdi:signal-cellular-2" + or "mdi:signal-cellular-3" ), }