mirror of https://github.com/home-assistant/core
39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
"""Diagnostics support for MelCloud."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from homeassistant.components.diagnostics import async_redact_data
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.const import CONF_TOKEN, CONF_USERNAME
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers import entity_registry as er
|
|
|
|
TO_REDACT = {
|
|
CONF_USERNAME,
|
|
CONF_TOKEN,
|
|
}
|
|
|
|
|
|
async def async_get_config_entry_diagnostics(
|
|
hass: HomeAssistant, entry: ConfigEntry
|
|
) -> dict[str, Any]:
|
|
"""Return diagnostics for the config entry."""
|
|
ent_reg = er.async_get(hass)
|
|
entities = [
|
|
entity.entity_id
|
|
for entity in er.async_entries_for_config_entry(ent_reg, entry.entry_id)
|
|
]
|
|
|
|
entity_states = {entity: hass.states.get(entity) for entity in entities}
|
|
|
|
entry_dict = entry.as_dict()
|
|
if "data" in entry_dict:
|
|
entry_dict["data"] = async_redact_data(entry_dict["data"], TO_REDACT)
|
|
|
|
return {
|
|
"entry": entry_dict,
|
|
"entities": entity_states,
|
|
}
|