Skip to content

Commit

Permalink
Fix for #75
Browse files Browse the repository at this point in the history
  • Loading branch information
dummylabs committed Jan 17, 2023
1 parent 33de87a commit c70af59
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions custom_components/watchman/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,8 @@ def get_entity_state(hass, entry, friendly_names=False):
if entity and entity.attributes.get("friendly_name", None):
if friendly_names:
name = entity.name
if not entity:
state = "missing"
else:
try:
state = entity.state.replace("unavailable", "unavail")
except Exception as e:
_LOGGER.error("Unable to get state for %s: %s. Type: %s", entry, e, type(entity.state))
state = "error"
# fix for #75, some integrations return non-string states
state = "missing" if not entity else str(entity.state).replace("unavailable", "unavail")
return state, name


Expand Down

0 comments on commit c70af59

Please sign in to comment.