43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
"""Diagnostics download for ninlight lamps."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from homeassistant.components.diagnostics import async_redact_data
|
|
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .coordinator import NinlightConfigEntry
|
|
from .shared import DATA_SHARED
|
|
|
|
TO_REDACT = {CONF_TOKEN, CONF_HOST, "ssid", "mac", "ip", "sta_ip"}
|
|
|
|
|
|
async def async_get_config_entry_diagnostics(
|
|
hass: HomeAssistant, entry: NinlightConfigEntry
|
|
) -> dict[str, Any]:
|
|
coordinator = entry.runtime_data
|
|
device_type = coordinator.data.info.get("device_type")
|
|
shared = hass.data.get(DATA_SHARED)
|
|
images = (
|
|
[]
|
|
if shared is None
|
|
else [
|
|
{"file": image.path.name, "device_type": image.device_type, "version": image.version}
|
|
for image in shared.catalog.images
|
|
if image.device_type == device_type
|
|
]
|
|
)
|
|
return {
|
|
**async_redact_data(
|
|
{
|
|
"entry": {"data": dict(entry.data), "options": dict(entry.options)},
|
|
"state": coordinator.data.state,
|
|
"info": coordinator.data.info,
|
|
},
|
|
TO_REDACT,
|
|
),
|
|
"firmware_images": images,
|
|
}
|