From 8067a842c2ff2449d945d0fb855b2384593d86c3 Mon Sep 17 00:00:00 2001 From: Elad Bar Date: Mon, 20 Apr 2020 19:10:18 +0300 Subject: [PATCH] Fix #54 - Added validation if state is not available to restore it --- CHANGELOG.md | 6 ++++++ custom_components/__init__.py | 0 custom_components/blueiris/managers/entity_manager.py | 8 ++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) delete mode 100644 custom_components/__init__.py 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)