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:
1 parent
e938dcfbda
commit
44fefb3216
12 files changed
+63
-44
No files matched your search
@@ -16,7 +16,7 @@ from homeassistant.const import (
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.exceptions import TemplateError
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.event import async_track_state_change
|
||||
from homeassistant.helpers.event import async_track_state_change_event
|
||||
from homeassistant.helpers.script import Script
|
||||
|
||||
from . import extract_entities, initialise_templates
|
||||
@@ -102,7 +102,7 @@ class TemplateLock(LockEntity):
|
||||
"""Register callbacks."""
|
||||
|
||||
@callback
|
||||
def template_lock_state_listener(entity, old_state, new_state):
|
||||
def template_lock_state_listener(event):
|
||||
"""Handle target device state changes."""
|
||||
self.async_schedule_update_ha_state(True)
|
||||
|
||||
@@ -111,7 +111,7 @@ class TemplateLock(LockEntity):
|
||||
"""Update template on startup."""
|
||||
if self._state_entities != MATCH_ALL:
|
||||
# Track state change only for valid templates
|
||||
async_track_state_change(
|
||||
async_track_state_change_event(
|
||||
self._hass, self._state_entities, template_lock_state_listener
|
||||
)
|
||||
self.async_schedule_update_ha_state(True)
|
||||
|
||||
Reference in new issue
Block a user