From aa476b392cf5b0022fbc2508f749cf53aac2d3e9 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 1 Sep 2020 14:18:11 +0200 Subject: [PATCH] Filter out disconnected Shelly sensors (#39516) --- homeassistant/components/shelly/sensor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index 815b83d1882..953499762a0 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -37,7 +37,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities): for block in wrapper.device.blocks: for attr in SENSORS: - if not hasattr(block, attr): + # Filter out non-existing sensors and sensors without a value + if getattr(block, attr, None) is None: continue sensors.append(ShellySensor(wrapper, block, attr))