mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Add device list to ZHA config entry diagnostics (#111549)
* Add device list to ZHA config entry diagnostics * add logical type
This commit is contained in:
parent
e854ce5c21
commit
5d1b78a29d
@ -28,6 +28,7 @@ from .core.const import (
|
||||
UNKNOWN,
|
||||
)
|
||||
from .core.device import ZHADevice
|
||||
from .core.gateway import ZHAGateway
|
||||
from .core.helpers import async_get_zha_device, get_zha_data, get_zha_gateway
|
||||
|
||||
KEYS_TO_REDACT = {
|
||||
@ -63,7 +64,8 @@ async def async_get_config_entry_diagnostics(
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
zha_data = get_zha_data(hass)
|
||||
app = get_zha_gateway(hass).application_controller
|
||||
gateway: ZHAGateway = get_zha_gateway(hass)
|
||||
app = gateway.application_controller
|
||||
|
||||
energy_scan = await app.energy_scan(
|
||||
channels=Channels.ALL_CHANNELS, duration_exp=4, count=1
|
||||
@ -86,6 +88,14 @@ async def async_get_config_entry_diagnostics(
|
||||
"zigpy_zigate": version("zigpy-zigate"),
|
||||
"zhaquirks": version("zha-quirks"),
|
||||
},
|
||||
"devices": [
|
||||
{
|
||||
"manufacturer": device.manufacturer,
|
||||
"model": device.model,
|
||||
"logical_type": device.device_type,
|
||||
}
|
||||
for device in gateway.devices.values()
|
||||
],
|
||||
},
|
||||
KEYS_TO_REDACT,
|
||||
)
|
||||
|
@ -27,6 +27,7 @@ CONFIG_ENTRY_DIAGNOSTICS_KEYS = [
|
||||
"config_entry",
|
||||
"application_state",
|
||||
"versions",
|
||||
"devices",
|
||||
]
|
||||
|
||||
|
||||
@ -83,6 +84,21 @@ async def test_diagnostics_for_config_entry(
|
||||
str(k): 100 * v / 255 for k, v in scan.items()
|
||||
}
|
||||
|
||||
assert isinstance(diagnostics_data["devices"], list)
|
||||
assert len(diagnostics_data["devices"]) == 2
|
||||
assert diagnostics_data["devices"] == [
|
||||
{
|
||||
"manufacturer": "Coordinator Manufacturer",
|
||||
"model": "Coordinator Model",
|
||||
"logical_type": "Coordinator",
|
||||
},
|
||||
{
|
||||
"manufacturer": "FakeManufacturer",
|
||||
"model": "FakeModel",
|
||||
"logical_type": "EndDevice",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
async def test_diagnostics_for_device(
|
||||
hass: HomeAssistant,
|
||||
|
Loading…
x
Reference in New Issue
Block a user