mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Support this variable in template button actions (#71792)
This commit is contained in:
parent
184421dae6
commit
042321be60
@ -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)
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user