diff --git a/tests/components/cast/test_media_player.py b/tests/components/cast/test_media_player.py index 5481459b715..1d99adb4723 100644 --- a/tests/components/cast/test_media_player.py +++ b/tests/components/cast/test_media_player.py @@ -813,15 +813,7 @@ async def test_device_registry( chromecast.disconnect.assert_not_called() client = await hass_ws_client(hass) - await client.send_json( - { - "id": 5, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": cast_entry.entry_id, - "device_id": device_entry.id, - } - ) - response = await client.receive_json() + response = await client.remove_device(device_entry.id, cast_entry.entry_id) assert response["success"] await hass.async_block_till_done() diff --git a/tests/components/devolo_home_control/test_init.py b/tests/components/devolo_home_control/test_init.py index 250a31843eb..fa32d67d86c 100644 --- a/tests/components/devolo_home_control/test_init.py +++ b/tests/components/devolo_home_control/test_init.py @@ -83,15 +83,7 @@ async def test_remove_device( assert device_entry client = await hass_ws_client(hass) - await client.send_json( - { - "id": 1, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": entry.entry_id, - "device_id": device_entry.id, - } - ) - response = await client.receive_json() + response = await client.remove_device(device_entry.id, entry.entry_id) assert response["success"] assert device_registry.async_get_device(identifiers={(DOMAIN, "Test")}) is None assert hass.states.get(f"{BINARY_SENSOR_DOMAIN}.test") is None diff --git a/tests/components/fritzbox/test_init.py b/tests/components/fritzbox/test_init.py index 8d7e4249fbd..f0391a03fb7 100644 --- a/tests/components/fritzbox/test_init.py +++ b/tests/components/fritzbox/test_init.py @@ -233,30 +233,14 @@ async def test_remove_device( # try to delete good_device ws_client = await hass_ws_client(hass) - await ws_client.send_json( - { - "id": 5, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": entry.entry_id, - "device_id": good_device.id, - } - ) - response = await ws_client.receive_json() + response = await ws_client.remove_device(good_device.id, entry.entry_id) assert not response["success"] assert response["error"]["code"] == "home_assistant_error" await hass.async_block_till_done() # try to delete orphan_device ws_client = await hass_ws_client(hass) - await ws_client.send_json( - { - "id": 5, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": entry.entry_id, - "device_id": orphan_device.id, - } - ) - response = await ws_client.receive_json() + response = await ws_client.remove_device(orphan_device.id, entry.entry_id) assert response["success"] await hass.async_block_till_done() diff --git a/tests/components/matter/test_init.py b/tests/components/matter/test_init.py index 4472e712b20..37eab91894a 100644 --- a/tests/components/matter/test_init.py +++ b/tests/components/matter/test_init.py @@ -634,15 +634,7 @@ async def test_remove_config_entry_device( assert hass.states.get(entity_id) client = await hass_ws_client(hass) - await client.send_json( - { - "id": 5, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": config_entry.entry_id, - "device_id": device_entry.id, - } - ) - response = await client.receive_json() + response = await client.remove_device(device_entry.id, config_entry.entry_id) assert response["success"] await hass.async_block_till_done() @@ -671,15 +663,7 @@ async def test_remove_config_entry_device_no_node( ) client = await hass_ws_client(hass) - await client.send_json( - { - "id": 5, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": config_entry.entry_id, - "device_id": device_entry.id, - } - ) - response = await client.receive_json() + response = await client.remove_device(device_entry.id, config_entry.entry_id) assert response["success"] await hass.async_block_till_done() diff --git a/tests/components/mqtt/test_device_tracker.py b/tests/components/mqtt/test_device_tracker.py index 680c48d13c7..4a159b8f9b5 100644 --- a/tests/components/mqtt/test_device_tracker.py +++ b/tests/components/mqtt/test_device_tracker.py @@ -274,15 +274,9 @@ async def test_cleanup_device_tracker( # Remove MQTT from the device mqtt_config_entry = hass.config_entries.async_entries(MQTT_DOMAIN)[0] - await ws_client.send_json( - { - "id": 6, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": mqtt_config_entry.entry_id, - "device_id": device_entry.id, - } + response = await ws_client.remove_device( + device_entry.id, mqtt_config_entry.entry_id ) - response = await ws_client.receive_json() assert response["success"] await hass.async_block_till_done() await hass.async_block_till_done() diff --git a/tests/components/mqtt/test_device_trigger.py b/tests/components/mqtt/test_device_trigger.py index 465e87205fa..1ef80c0b81e 100644 --- a/tests/components/mqtt/test_device_trigger.py +++ b/tests/components/mqtt/test_device_trigger.py @@ -986,15 +986,9 @@ async def test_not_fires_on_mqtt_message_after_remove_from_registry( # Remove MQTT from the device mqtt_config_entry = hass.config_entries.async_entries(DOMAIN)[0] - await ws_client.send_json( - { - "id": 6, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": mqtt_config_entry.entry_id, - "device_id": device_entry.id, - } + response = await ws_client.remove_device( + device_entry.id, mqtt_config_entry.entry_id ) - response = await ws_client.receive_json() assert response["success"] await hass.async_block_till_done() @@ -1349,15 +1343,9 @@ async def test_cleanup_trigger( # Remove MQTT from the device mqtt_config_entry = hass.config_entries.async_entries(DOMAIN)[0] - await ws_client.send_json( - { - "id": 6, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": mqtt_config_entry.entry_id, - "device_id": device_entry.id, - } + response = await ws_client.remove_device( + device_entry.id, mqtt_config_entry.entry_id ) - response = await ws_client.receive_json() assert response["success"] await hass.async_block_till_done() await hass.async_block_till_done() diff --git a/tests/components/mqtt/test_discovery.py b/tests/components/mqtt/test_discovery.py index a00af080bf1..38ce5df25d8 100644 --- a/tests/components/mqtt/test_discovery.py +++ b/tests/components/mqtt/test_discovery.py @@ -843,15 +843,9 @@ async def test_cleanup_device( # Remove MQTT from the device mqtt_config_entry = hass.config_entries.async_entries(mqtt.DOMAIN)[0] - await ws_client.send_json( - { - "id": 6, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": mqtt_config_entry.entry_id, - "device_id": device_entry.id, - } + response = await ws_client.remove_device( + device_entry.id, mqtt_config_entry.entry_id ) - response = await ws_client.receive_json() assert response["success"] await hass.async_block_till_done() await hass.async_block_till_done() @@ -985,15 +979,9 @@ async def test_cleanup_device_multiple_config_entries( # Remove MQTT from the device mqtt_config_entry = hass.config_entries.async_entries(mqtt.DOMAIN)[0] - await ws_client.send_json( - { - "id": 6, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": mqtt_config_entry.entry_id, - "device_id": device_entry.id, - } + response = await ws_client.remove_device( + device_entry.id, mqtt_config_entry.entry_id ) - response = await ws_client.receive_json() assert response["success"] await hass.async_block_till_done() diff --git a/tests/components/mqtt/test_init.py b/tests/components/mqtt/test_init.py index cfb8ce7ac04..fc9e596346f 100644 --- a/tests/components/mqtt/test_init.py +++ b/tests/components/mqtt/test_init.py @@ -2850,15 +2850,7 @@ async def test_mqtt_ws_remove_discovered_device( client = await hass_ws_client(hass) mqtt_config_entry = hass.config_entries.async_entries(mqtt.DOMAIN)[0] - await client.send_json( - { - "id": 5, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": mqtt_config_entry.entry_id, - "device_id": device_entry.id, - } - ) - response = await client.receive_json() + response = await client.remove_device(device_entry.id, mqtt_config_entry.entry_id) assert response["success"] # Verify device entry is cleared diff --git a/tests/components/mqtt/test_tag.py b/tests/components/mqtt/test_tag.py index 9a0da989216..9de3b27fc3d 100644 --- a/tests/components/mqtt/test_tag.py +++ b/tests/components/mqtt/test_tag.py @@ -419,15 +419,9 @@ async def test_not_fires_on_mqtt_message_after_remove_from_registry( # Remove MQTT from the device mqtt_config_entry = hass.config_entries.async_entries(MQTT_DOMAIN)[0] - await ws_client.send_json( - { - "id": 6, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": mqtt_config_entry.entry_id, - "device_id": device_entry.id, - } + response = await ws_client.remove_device( + device_entry.id, mqtt_config_entry.entry_id ) - response = await ws_client.receive_json() assert response["success"] tag_mock.reset_mock() @@ -612,15 +606,9 @@ async def test_cleanup_tag( # Remove MQTT from the device mqtt_config_entry = hass.config_entries.async_entries(MQTT_DOMAIN)[0] - await ws_client.send_json( - { - "id": 6, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": mqtt_config_entry.entry_id, - "device_id": device_entry1.id, - } + response = await ws_client.remove_device( + device_entry1.id, mqtt_config_entry.entry_id ) - response = await ws_client.receive_json() assert response["success"] await hass.async_block_till_done() await hass.async_block_till_done() diff --git a/tests/components/mysensors/test_init.py b/tests/components/mysensors/test_init.py index 8c1eeb64b70..7f6ea76d3e1 100644 --- a/tests/components/mysensors/test_init.py +++ b/tests/components/mysensors/test_init.py @@ -41,15 +41,7 @@ async def test_remove_config_entry_device( assert state client = await hass_ws_client(hass) - await client.send_json( - { - "id": 5, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": config_entry.entry_id, - "device_id": device_entry.id, - } - ) - response = await client.receive_json() + response = await client.remove_device(device_entry.id, config_entry.entry_id) assert response["success"] await hass.async_block_till_done() diff --git a/tests/components/rfxtrx/test_init.py b/tests/components/rfxtrx/test_init.py index b969a63a990..43a2a2cdddc 100644 --- a/tests/components/rfxtrx/test_init.py +++ b/tests/components/rfxtrx/test_init.py @@ -112,15 +112,7 @@ async def test_ws_device_remove( # Ask to remove existing device client = await hass_ws_client(hass) - await client.send_json( - { - "id": 5, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": mock_entry.entry_id, - "device_id": device_entry.id, - } - ) - response = await client.receive_json() + response = await client.remove_device(device_entry.id, mock_entry.entry_id) assert response["success"] # Verify device entry is removed diff --git a/tests/components/tasmota/test_init.py b/tests/components/tasmota/test_init.py index 95fb186a46d..72a86fc9986 100644 --- a/tests/components/tasmota/test_init.py +++ b/tests/components/tasmota/test_init.py @@ -168,15 +168,9 @@ async def test_tasmota_ws_remove_discovered_device( client = await hass_ws_client(hass) tasmota_config_entry = hass.config_entries.async_entries(DOMAIN)[0] - await client.send_json( - { - "id": 5, - "config_entry_id": tasmota_config_entry.entry_id, - "type": "config/device_registry/remove_config_entry", - "device_id": device_entry.id, - } + response = await client.remove_device( + device_entry.id, tasmota_config_entry.entry_id ) - response = await client.receive_json() assert response["success"] # Verify device entry is cleared diff --git a/tests/components/zwave_js/test_init.py b/tests/components/zwave_js/test_init.py index 85611262214..66c2c05e530 100644 --- a/tests/components/zwave_js/test_init.py +++ b/tests/components/zwave_js/test_init.py @@ -1365,40 +1365,18 @@ async def test_replace_different_node( driver = client.driver client.driver = None - await ws_client.send_json( - { - "id": 1, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": integration.entry_id, - "device_id": hank_device.id, - } - ) - response = await ws_client.receive_json() + response = await ws_client.remove_device(hank_device.id, integration.entry_id) assert not response["success"] client.driver = driver # Attempting to remove the hank device should pass, but removing the multisensor should not - await ws_client.send_json( - { - "id": 2, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": integration.entry_id, - "device_id": hank_device.id, - } - ) - response = await ws_client.receive_json() + response = await ws_client.remove_device(hank_device.id, integration.entry_id) assert response["success"] - await ws_client.send_json( - { - "id": 3, - "type": "config/device_registry/remove_config_entry", - "config_entry_id": integration.entry_id, - "device_id": multisensor_6_device.id, - } + response = await ws_client.remove_device( + multisensor_6_device.id, integration.entry_id ) - response = await ws_client.receive_json() assert not response["success"]