Change trigger platform key to trigger (#124357)

* fix

* Fix

* Fix

* Update homeassistant/helpers/config_validation.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Fix

* Fix

* Fix

* Fix

* Add more tests

* Fix

* Fix tests

* Add tests

* Let's see what the CI does

* It fails on the code that tested the thing ofc

* It fails on the code that tested the thing ofc

* Revert test thingy

* Now the test works again, lovely

* Another one

* Fix websocket thingy

* Only copy when needed

* Improve comment

* Remove test

* Fix docstring

* I think this now also work since this transforms trigger to platform

* Add comment

* Update homeassistant/helpers/config_validation.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Update homeassistant/helpers/config_validation.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Update homeassistant/helpers/config_validation.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Check for mapping

* Add test

* Update homeassistant/helpers/config_validation.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Update test to also test for trigger keys

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
Joost Lekkerkerker
2024-09-25 14:19:58 +02:00
committed by GitHub
parent 9d29307532
commit a1906b434f
12 changed files with 185 additions and 58 deletions

View File

@@ -720,12 +720,17 @@ async def test_async_get_device_automations_all_devices_action_exception_throw(
assert "KeyError" in caplog.text
@pytest.mark.parametrize(
"trigger_key",
["trigger", "platform"],
)
async def test_websocket_get_trigger_capabilities(
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
fake_integration,
trigger_key: str,
) -> None:
"""Test we get the expected trigger capabilities through websocket."""
await async_setup_component(hass, "device_automation", {})
@@ -767,11 +772,12 @@ async def test_websocket_get_trigger_capabilities(
assert msg["id"] == 1
assert msg["type"] == TYPE_RESULT
assert msg["success"]
triggers = msg["result"]
triggers: dict = msg["result"]
msg_id = 2
assert len(triggers) == 3 # toggled, turned_on, turned_off
for trigger in triggers:
trigger[trigger_key] = trigger.pop("platform")
await client.send_json(
{
"id": msg_id,