Document the target field of the ifttt trigger action (#190530)

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
epenet
2026-11-09 09:35:02 +00:00
committed by GitHub
co-authored by Copilot Autofix powered by AI
parent 53e8397bfa
commit 9fce8322e2
3 changed files with 45 additions and 1 deletions
@@ -20,6 +20,11 @@ trigger:
example: "MY_HA_EVENT"
selector:
text:
target:
example: "my_key_name"
selector:
text:
multiple: true
value1:
example: "Hello World"
selector:
@@ -45,6 +45,10 @@
"description": "The name of the event to send.",
"name": "Event"
},
"target": {
"description": "The names of the configured API keys to send the event to. Sends the event to all keys if this field is omitted.",
"name": "Target"
},
"value1": {
"description": "Generic field to send data via the event.",
"name": "Value 1"
+36 -1
View File
@@ -1,6 +1,6 @@
"""Test the init file of IFTTT."""
from unittest.mock import patch
from unittest.mock import MagicMock, patch
import pytest
from pytest_homeassistant.common import async_setup_component
@@ -82,3 +82,38 @@ async def test_trigger_service_raises_when_ifttt_unreachable(
assert exc_info.value.translation_domain == DOMAIN
assert exc_info.value.translation_key == "trigger_failed"
@pytest.mark.parametrize(
("service_data", "expected_keys"),
[
pytest.param({}, ["secret_a", "secret_b"], id="all_keys"),
pytest.param({"target": "a"}, ["secret_a"], id="single_target"),
pytest.param(
{"target": ["a", "b"]}, ["secret_a", "secret_b"], id="multiple_targets"
),
pytest.param({"target": "unknown"}, [], id="unknown_target"),
],
)
async def test_trigger_service_target(
hass: HomeAssistant,
service_data: dict[str, str | list[str]],
expected_keys: list[str],
) -> None:
"""Test the trigger action sends the event to the targeted API keys."""
await async_setup_component(
hass, DOMAIN, {DOMAIN: {CONF_KEY: {"a": "secret_a", "b": "secret_b"}}}
)
with patch(
"homeassistant.components.ifttt.services.pyfttt.send_event",
return_value=MagicMock(status_code=200),
) as send_event:
await hass.services.async_call(
DOMAIN,
"trigger",
{"event": "test_event", **service_data},
blocking=True,
)
assert [call.args[0] for call in send_event.call_args_list] == expected_keys