diff --git a/plugin/homeassistant.py b/plugin/homeassistant.py index f048101..c7ffa39 100644 --- a/plugin/homeassistant.py +++ b/plugin/homeassistant.py @@ -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]) @@ -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)