Don't try to resolve state if native_value is Null (#67134)

pull/67149/head
soluga 2022-02-24 01:29:26 +01:00 committed by GitHub
parent a5383e40eb
commit 79bdd71da7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -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