mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Improve AsusWRT diagnostics (#69826)
This commit is contained in:
parent
ce1f074ca9
commit
a27f61cf07
@ -3,9 +3,16 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
import attr
|
||||||
|
|
||||||
from homeassistant.components.diagnostics import async_redact_data
|
from homeassistant.components.diagnostics import async_redact_data
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import (
|
||||||
|
ATTR_CONNECTIONS,
|
||||||
|
ATTR_IDENTIFIERS,
|
||||||
|
CONF_PASSWORD,
|
||||||
|
CONF_USERNAME,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
|
|
||||||
@ -13,6 +20,7 @@ from .const import DATA_ASUSWRT, DOMAIN
|
|||||||
from .router import AsusWrtRouter
|
from .router import AsusWrtRouter
|
||||||
|
|
||||||
TO_REDACT = {CONF_PASSWORD, CONF_USERNAME}
|
TO_REDACT = {CONF_PASSWORD, CONF_USERNAME}
|
||||||
|
TO_REDACT_DEV = {ATTR_CONNECTIONS, ATTR_IDENTIFIERS}
|
||||||
|
|
||||||
|
|
||||||
async def async_get_config_entry_diagnostics(
|
async def async_get_config_entry_diagnostics(
|
||||||
@ -33,11 +41,7 @@ async def async_get_config_entry_diagnostics(
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
data["device"] = {
|
data["device"] = {
|
||||||
"name": hass_device.name,
|
**async_redact_data(attr.asdict(hass_device), TO_REDACT_DEV),
|
||||||
"name_by_user": hass_device.name_by_user,
|
|
||||||
"disabled": hass_device.disabled,
|
|
||||||
"disabled_by": hass_device.disabled_by,
|
|
||||||
"device_info": async_redact_data(dict(router.device_info), {"identifiers"}),
|
|
||||||
"entities": {},
|
"entities": {},
|
||||||
"tracked_devices": [],
|
"tracked_devices": [],
|
||||||
}
|
}
|
||||||
@ -59,16 +63,12 @@ async def async_get_config_entry_diagnostics(
|
|||||||
state_dict.pop("context", None)
|
state_dict.pop("context", None)
|
||||||
|
|
||||||
data["device"]["entities"][entity_entry.entity_id] = {
|
data["device"]["entities"][entity_entry.entity_id] = {
|
||||||
"name": entity_entry.name,
|
**async_redact_data(
|
||||||
"original_name": entity_entry.original_name,
|
attr.asdict(
|
||||||
"disabled": entity_entry.disabled,
|
entity_entry, filter=lambda attr, value: attr.name != "entity_id"
|
||||||
"disabled_by": entity_entry.disabled_by,
|
),
|
||||||
"entity_category": entity_entry.entity_category,
|
TO_REDACT,
|
||||||
"device_class": entity_entry.device_class,
|
),
|
||||||
"original_device_class": entity_entry.original_device_class,
|
|
||||||
"icon": entity_entry.icon,
|
|
||||||
"original_icon": entity_entry.original_icon,
|
|
||||||
"unit_of_measurement": entity_entry.unit_of_measurement,
|
|
||||||
"state": state_dict,
|
"state": state_dict,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user