1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Improve lists for MQTT integration (#113184)

* Improve lists for MQTT integration

* Extra diagnostics tests

* Revert changes where the original version was probably faster

* Revert change to gather and await in series
This commit is contained in:
Jan Bouwhuis
2024-03-13 11:04:59 +01:00
committed by GitHub
parent b1346f3ccd
commit 488dae43d4
11 changed files with 144 additions and 116 deletions

View File

@@ -7,7 +7,7 @@ import pytest
from homeassistant.components import mqtt
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers import device_registry as dr, entity_registry as er
from tests.common import async_fire_mqtt_message
from tests.components.diagnostics import (
@@ -25,6 +25,7 @@ default_config = {
async def test_entry_diagnostics(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
hass_client: ClientSessionGenerator,
mqtt_mock_entry: MqttMockHAClientGenerator,
) -> None:
@@ -260,3 +261,28 @@ async def test_redact_diagnostics(
"mqtt_config": expected_config,
"mqtt_debug_info": expected_debug_info,
}
# Disable the entity and remove the state
ent_registry = er.async_get(hass)
device_tracker_entry = er.async_entries_for_device(ent_registry, device_entry.id)[0]
ent_registry.async_update_entity(
device_tracker_entry.entity_id, disabled_by=er.RegistryEntryDisabler.USER
)
hass.states.async_remove(device_tracker_entry.entity_id)
# Assert disabled entries are filtered
assert await get_diagnostics_for_device(
hass, hass_client, config_entry, device_entry
) == {
"connected": True,
"device": {
"id": device_entry.id,
"name": None,
"name_by_user": None,
"disabled": False,
"disabled_by": None,
"entities": [],
},
"mqtt_config": expected_config,
"mqtt_debug_info": {"entities": [], "triggers": []},
}