Use entity registry id in toggle_entity device automations (#94995)

* Use entity registry id in toggle_entity device automations

* Update tests

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Erik Montnemery 2023-06-26 09:59:01 +02:00 committed by GitHub
parent 408c613731
commit a338e7e242
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 1352 additions and 480 deletions

View file

@ -114,7 +114,7 @@ async def test_websocket_get_actions(
config_entry_id=config_entry.entry_id,
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
)
entity_registry.async_get_or_create(
entity_entry = entity_registry.async_get_or_create(
"fake_integration", "test", "5678", device_id=device_entry.id
)
expected_actions = [
@ -122,21 +122,21 @@ async def test_websocket_get_actions(
"domain": "fake_integration",
"type": "turn_off",
"device_id": device_entry.id,
"entity_id": "fake_integration.test_5678",
"entity_id": entity_entry.id,
"metadata": {"secondary": False},
},
{
"domain": "fake_integration",
"type": "turn_on",
"device_id": device_entry.id,
"entity_id": "fake_integration.test_5678",
"entity_id": entity_entry.id,
"metadata": {"secondary": False},
},
{
"domain": "fake_integration",
"type": "toggle",
"device_id": device_entry.id,
"entity_id": "fake_integration.test_5678",
"entity_id": entity_entry.id,
"metadata": {"secondary": False},
},
]
@ -169,7 +169,7 @@ async def test_websocket_get_conditions(
config_entry_id=config_entry.entry_id,
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
)
entity_registry.async_get_or_create(
entity_entry = entity_registry.async_get_or_create(
"fake_integration", "test", "5678", device_id=device_entry.id
)
expected_conditions = [
@ -178,7 +178,7 @@ async def test_websocket_get_conditions(
"domain": "fake_integration",
"type": "is_off",
"device_id": device_entry.id,
"entity_id": "fake_integration.test_5678",
"entity_id": entity_entry.id,
"metadata": {"secondary": False},
},
{
@ -186,7 +186,7 @@ async def test_websocket_get_conditions(
"domain": "fake_integration",
"type": "is_on",
"device_id": device_entry.id,
"entity_id": "fake_integration.test_5678",
"entity_id": entity_entry.id,
"metadata": {"secondary": False},
},
]
@ -223,7 +223,7 @@ async def test_websocket_get_triggers(
config_entry_id=config_entry.entry_id,
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
)
entity_registry.async_get_or_create(
entity_entry = entity_registry.async_get_or_create(
"fake_integration", "test", "5678", device_id=device_entry.id
)
expected_triggers = [
@ -232,7 +232,7 @@ async def test_websocket_get_triggers(
"domain": "fake_integration",
"type": "changed_states",
"device_id": device_entry.id,
"entity_id": "fake_integration.test_5678",
"entity_id": entity_entry.id,
"metadata": {"secondary": False},
},
{
@ -240,7 +240,7 @@ async def test_websocket_get_triggers(
"domain": "fake_integration",
"type": "turned_off",
"device_id": device_entry.id,
"entity_id": "fake_integration.test_5678",
"entity_id": entity_entry.id,
"metadata": {"secondary": False},
},
{
@ -248,7 +248,7 @@ async def test_websocket_get_triggers(
"domain": "fake_integration",
"type": "turned_on",
"device_id": device_entry.id,
"entity_id": "fake_integration.test_5678",
"entity_id": entity_entry.id,
"metadata": {"secondary": False},
},
]