mirror of
https://github.com/home-assistant/core
synced 2024-09-03 08:14:07 +02:00
34 lines
971 B
Python
34 lines
971 B
Python
"""Diagnostics support for 1-Wire."""
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import asdict
|
|
from typing import Any
|
|
|
|
from homeassistant.components.diagnostics import async_redact_data
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.const import CONF_HOST
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .const import DOMAIN
|
|
from .onewirehub import OneWireHub
|
|
|
|
TO_REDACT = {CONF_HOST}
|
|
|
|
|
|
async def async_get_config_entry_diagnostics(
|
|
hass: HomeAssistant, entry: ConfigEntry
|
|
) -> dict[str, Any]:
|
|
"""Return diagnostics for a config entry."""
|
|
onewire_hub: OneWireHub = hass.data[DOMAIN][entry.entry_id]
|
|
|
|
return {
|
|
"entry": {
|
|
"title": entry.title,
|
|
"data": async_redact_data(entry.data, TO_REDACT),
|
|
"options": {**entry.options},
|
|
},
|
|
"devices": [asdict(device_details) for device_details in onewire_hub.devices]
|
|
if onewire_hub.devices
|
|
else [],
|
|
}
|