1
mirror of https://github.com/home-assistant/core synced 2024-09-03 08:14:07 +02:00
ha-core/homeassistant/components/tradfri/diagnostics.py
Patrik Lindgren 4b5996c5ed
Drop support for Tradfri groups and YAML configuration (#68033)
* Drop support for Tradfri groups

* Remove context

* Remove async_setup

* Mark removed

* Pass generator expression
2022-04-01 23:26:35 +02:00

36 lines
1.0 KiB
Python

"""Diagnostics support for IKEA Tradfri."""
from __future__ import annotations
from typing import cast
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from .const import CONF_GATEWAY_ID, COORDINATOR, COORDINATOR_LIST, DOMAIN
async def async_get_config_entry_diagnostics(
hass: HomeAssistant, entry: ConfigEntry
) -> dict:
"""Return diagnostics the Tradfri platform."""
entry_data = hass.data[DOMAIN][entry.entry_id]
coordinator_data = entry_data[COORDINATOR]
device_registry = dr.async_get(hass)
device = cast(
dr.DeviceEntry,
device_registry.async_get_device(
identifiers={(DOMAIN, entry.data[CONF_GATEWAY_ID])}
),
)
device_data: list = []
for coordinator in coordinator_data[COORDINATOR_LIST]:
device_data.append(coordinator.device.device_info.model_number)
return {
"gateway_version": device.sw_version,
"device_data": sorted(device_data),
}