Skip to content

Commit

Permalink
Merge pull request #62 from Garulf/fix-select-options
Browse files Browse the repository at this point in the history
Fix select options
  • Loading branch information
Garulf authored Jun 27, 2024
2 parents 6c23276 + 58241a2 commit 065e579
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugin/homeassistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def __init__(self, client, entity):
self.friendly_name = entity.get(
"attributes", "").get("friendly_name", "")
self.state = entity.get("state")
self.attributes = entity["attributes"]
self.attributes = entity["attributes"] or {}
self.target = {"entity_id": self.entity_id}
# for attribute in entity['attributes']:
# setattr(self, attribute, entity['attributes'][attribute])
Expand Down Expand Up @@ -452,7 +452,7 @@ def _select(self, option) -> None:
class Select(BaseEntity):
def __init__(self, client: Client, entity: dict) -> None:
super().__init__(client, entity)
for option in self.attributes["options"]:
for option in self.attributes.get("options", []):
setattr(self, option, partial(self._select, option))
getattr(self, option).name = option
getattr(self, option).__doc__ = 'Set option to "{}"'.format(option)
Expand Down

0 comments on commit 065e579

Please sign in to comment.