mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +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:
|
async def async_press(self) -> None:
|
||||||
"""Press the button."""
|
"""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": {
|
"template": {
|
||||||
"unique_id": "test",
|
"unique_id": "test",
|
||||||
"button": {
|
"button": {
|
||||||
"press": {"service": "test.automation"},
|
"press": {
|
||||||
|
"service": "test.automation",
|
||||||
|
"data_template": {"caller": "{{ this.entity_id }}"},
|
||||||
|
},
|
||||||
"device_class": "restart",
|
"device_class": "restart",
|
||||||
"unique_id": "test",
|
"unique_id": "test",
|
||||||
"name": "test",
|
"name": "test",
|
||||||
@ -104,6 +107,7 @@ async def test_all_optional_config(hass, calls):
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert len(calls) == 1
|
assert len(calls) == 1
|
||||||
|
assert calls[0].data["caller"] == _TEST_OPTIONS_BUTTON
|
||||||
|
|
||||||
_verify(
|
_verify(
|
||||||
hass,
|
hass,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user