Use TemplateStateFromEntityId in Template trigger entity (#130136)

This commit is contained in:
G Johansson 2024-11-08 22:09:43 +01:00 committed by GitHub
parent 48e7fed901
commit 742eca5927
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.template import TemplateStateFromEntityId
from homeassistant.helpers.trigger_template_entity import TriggerBaseEntity
from homeassistant.helpers.update_coordinator import CoordinatorEntity
@ -41,11 +42,11 @@ class TriggerEntity( # pylint: disable=hass-enforce-class-module
def _process_data(self) -> None:
"""Process new data."""
this = None
if state := self.hass.states.get(self.entity_id):
this = state.as_dict()
run_variables = self.coordinator.data["run_variables"]
variables = {"this": this, **(run_variables or {})}
variables = {
"this": TemplateStateFromEntityId(self.hass, self.entity_id),
**(run_variables or {}),
}
self._render_templates(variables)