From 79bdd71da707c384bc4fc38234f231c3f7538eaa Mon Sep 17 00:00:00 2001 From: soluga <33458264+soluga@users.noreply.github.com> Date: Thu, 24 Feb 2022 01:29:26 +0100 Subject: [PATCH] Don't try to resolve state if native_value is Null (#67134) --- homeassistant/components/wolflink/sensor.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/wolflink/sensor.py b/homeassistant/components/wolflink/sensor.py index f1a94cbbe20..a39b03fbd9f 100644 --- a/homeassistant/components/wolflink/sensor.py +++ b/homeassistant/components/wolflink/sensor.py @@ -152,10 +152,11 @@ class WolfLinkState(WolfLinkSensor): def native_value(self): """Return the state converting with supported values.""" state = super().native_value - resolved_state = [ - item for item in self.wolf_object.items if item.value == int(state) - ] - if resolved_state: - resolved_name = resolved_state[0].name - return STATES.get(resolved_name, resolved_name) + if state is not None: + resolved_state = [ + item for item in self.wolf_object.items if item.value == int(state) + ] + if resolved_state: + resolved_name = resolved_state[0].name + return STATES.get(resolved_name, resolved_name) return state