Skip to content

Commit

Permalink
Fix #57 and continue runing if invalid entities are found
Browse files Browse the repository at this point in the history
  • Loading branch information
slashback100 committed Jun 10, 2022
1 parent a4b535f commit df638a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions custom_components/presence_simulation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ async def async_expand_entities(entities):
#to make it asyncable, not sure it is needed
await asyncio.sleep(0)
if hass.states.get(entity) is None:
_LOGGER.error("Error when trying to identify entity %s, it seems it doesn't exist", entity)
raise Exception("Entity is not known by HA, see log for more details")
_LOGGER.error("Error when trying to identify entity %s, it seems it doesn't exist. Continuing without this entity", entity)
else:
if 'entity_id' in hass.states.get(entity).attributes:
#get the list of the associated entities
Expand Down Expand Up @@ -179,6 +178,12 @@ async def handle_presence_simulation(call, restart=False, entities_after_restart
entity.internal_turn_off()
return

if len(expanded_entities) == 0:
_LOGGER.error("Error during identifing entities, no valid entities has been found")
running = False
entity.internal_turn_off()
return

if not restart:
#set attribute on the switch
try:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/presence_simulation/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"issue_tracker": "https://github.com/slashback100/presence_simulation/issues",
"dependencies": ["history", "recorder", "scene"],
"config_flow": true,
"version": "1.17",
"version": "1.18",
"codeowners": [
"@slashback100"
],
Expand Down

0 comments on commit df638a2

Please sign in to comment.