Skip to content

Commit

Permalink
Removed entity / device delete upon restarting HA
Browse files Browse the repository at this point in the history
  • Loading branch information
elad-bar committed Feb 4, 2022
1 parent 2a348e6 commit 4e7bc05
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Changelog

## 1.1.8

- Removed entity / device delete upon restarting HA

## 1.1.7

- Added support for long term statistics
-

## 1.1.6

- Upgraded code to support breaking changes of HA v2012.12.0
Expand Down
19 changes: 0 additions & 19 deletions custom_components/edgeos/managers/entity_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ def update(self):
async def _async_update(self):
step = "Mark as ignore"
try:
entities_to_delete = []

for entity in self.get_all_entities():
entities_to_delete.append(entity.unique_id)

step = "Create components"

self.create_components()
Expand Down Expand Up @@ -160,9 +155,6 @@ async def _async_update(self):
if entity.status == ENTITY_STATUS_CREATED:
entity_item = self.entity_registry.async_get(entity_id)

if entity.unique_id in entities_to_delete:
entities_to_delete.remove(entity.unique_id)

step = f"Mark as created - {domain} -> {entity_key}"

entity_component = domain_component(
Expand Down Expand Up @@ -202,17 +194,6 @@ async def _async_update(self):
if len(entities_to_add) > 0:
async_add_entities(entities_to_add, True)

if len(entities_to_delete) > 0:
_LOGGER.info(f"Following items will be deleted: {entities_to_delete}")

for domain in SIGNALS:
entities = dict(self.get_entities(domain))

for entity_key in entities:
entity = entities[entity_key]
if entity.unique_id in entities_to_delete:
await self.ha.delete_entity(domain, entity.name)

except Exception as ex:
self.log_exception(ex, f"Failed to update, step: {step}")

Expand Down
2 changes: 1 addition & 1 deletion custom_components/edgeos/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"codeowners": ["@elad-bar"],
"requirements": ["aiohttp"],
"config_flow": true,
"version": "1.1.7",
"version": "1.1.8",
"iot_class": "local_polling"
}

0 comments on commit 4e7bc05

Please sign in to comment.