Support this variable in template button actions (#71792)

This commit is contained in:
Erik Montnemery 2022-05-13 17:28:36 +02:00 committed by GitHub
parent 184421dae6
commit 042321be60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -93,4 +93,4 @@ class TemplateButtonEntity(TemplateEntity, ButtonEntity):
async def async_press(self) -> None:
"""Press the button."""
await self._command_press.async_run(context=self._context)
await self.async_run_script(self._command_press, context=self._context)

View File

@ -68,7 +68,10 @@ async def test_all_optional_config(hass, calls):
"template": {
"unique_id": "test",
"button": {
"press": {"service": "test.automation"},
"press": {
"service": "test.automation",
"data_template": {"caller": "{{ this.entity_id }}"},
},
"device_class": "restart",
"unique_id": "test",
"name": "test",
@ -104,6 +107,7 @@ async def test_all_optional_config(hass, calls):
)
assert len(calls) == 1
assert calls[0].data["caller"] == _TEST_OPTIONS_BUTTON
_verify(
hass,