Use remove_device helper in tasmota tests (#116617)

This commit is contained in:
epenet 2024-05-18 13:43:21 +02:00 committed by GitHub
parent 1d16e219e4
commit 3a8bdfbfdf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 22 deletions

View file

@ -22,9 +22,11 @@ from hatasmota.utils import (
from homeassistant.components.tasmota.const import DEFAULT_PREFIX, DOMAIN
from homeassistant.const import STATE_UNAVAILABLE
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er
from tests.common import async_fire_mqtt_message
from tests.typing import WebSocketGenerator
DEFAULT_CONFIG = {
"ip": "192.168.15.10",
@ -108,19 +110,17 @@ DEFAULT_SENSOR_CONFIG = {
}
async def remove_device(hass, ws_client, device_id, config_entry_id=None):
async def remove_device(
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
device_id: str,
config_entry_id: str | None = None,
) -> None:
"""Remove config entry from a device."""
if config_entry_id is None:
config_entry_id = hass.config_entries.async_entries(DOMAIN)[0].entry_id
await ws_client.send_json(
{
"id": 5,
"type": "config/device_registry/remove_config_entry",
"config_entry_id": config_entry_id,
"device_id": device_id,
}
)
response = await ws_client.receive_json()
ws_client = await hass_ws_client(hass)
response = await ws_client.remove_device(device_id, config_entry_id)
assert response["success"]