Improve handling of template platforms when entity extraction fails (#37831)

Most of the the template platforms would check for
extract_entities failing to extract entities and avoid
setting up a state change listner for MATCH_ALL after
extract_entities had warned that it could not extract
the entities and updates would need to be done manually.
This protection has been extended to all template platforms.

Alter the behavior of extract_entities to return the
successfully extracted entities if one or more templates
fail extraction instead of returning MATCH_ALL
This commit is contained in:
J. Nick Koston 2020-07-14 19:34:35 -10:00 committed by GitHub
parent e938dcfbda
commit 44fefb3216
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 63 additions and 44 deletions

View file

@ -40,8 +40,11 @@ def extract_entities(
else:
invalid_templates.append(template_name.replace("_template", ""))
entity_ids = list(entity_ids)
if invalid_templates:
entity_ids = MATCH_ALL
if not entity_ids:
entity_ids = MATCH_ALL
_LOGGER.warning(
"Template %s '%s' has no entity ids configured to track nor"
" were we able to extract the entities to track from the %s "
@ -51,8 +54,6 @@ def extract_entities(
device_name,
", ".join(invalid_templates),
)
else:
entity_ids = list(entity_ids)
else:
entity_ids = manual_entity_ids