diff --git a/CHANGELOG.md b/CHANGELOG.md index 79daa23..d2a4053 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 2020-04-20 + +**Fixed bugs:** + +- Added validation if state is not available to restore it [\#54](https://github.com/elad-bar/ha-bleuiris/issues/54) + ## 2020-04-19 **Fixed bugs:** diff --git a/custom_components/__init__.py b/custom_components/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/custom_components/blueiris/managers/entity_manager.py b/custom_components/blueiris/managers/entity_manager.py index 229febd..2078414 100644 --- a/custom_components/blueiris/managers/entity_manager.py +++ b/custom_components/blueiris/managers/entity_manager.py @@ -196,10 +196,14 @@ async def _async_update(self): entity_component.entity_id = entity_id state = self.hass.states.get(entity_id) - restored = state.attributes.get("restored", False) - if restored: + if state is None: + restored = True + else: + restored = state.attributes.get("restored", False) _LOGGER.info(f"Entity {entity.name} restored | {entity_id}") + + if restored: entities_to_add.append(entity_component) else: entities_to_add.append(entity_component)