mirror of
https://github.com/home-assistant/core.git
synced 2026-05-29 11:45:35 +01:00
d766aae436
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: frenck <195327+frenck@users.noreply.github.com>
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
"""Diagnostics support for airOS."""
|
|
|
|
from typing import Any
|
|
|
|
from homeassistant.components.diagnostics import async_redact_data
|
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .coordinator import AirOSConfigEntry
|
|
|
|
IP_REDACT = ["addr", "ipaddr", "ip6addr", "lastip"] # IP related
|
|
HW_REDACT = ["apmac", "hwaddr", "mac"] # MAC address
|
|
TO_REDACT_HA = [CONF_HOST, CONF_PASSWORD]
|
|
TO_REDACT_AIROS = [
|
|
"hostname", # Prevent leaking device naming
|
|
"essid", # Network SSID
|
|
"lat", # GPS latitude to prevent exposing location data.
|
|
"lon", # GPS longitude to prevent exposing location data.
|
|
*HW_REDACT,
|
|
*IP_REDACT,
|
|
]
|
|
|
|
|
|
async def async_get_config_entry_diagnostics(
|
|
hass: HomeAssistant, entry: AirOSConfigEntry
|
|
) -> dict[str, Any]:
|
|
"""Return diagnostics for a config entry."""
|
|
return {
|
|
"entry_data": async_redact_data(entry.data, TO_REDACT_HA),
|
|
"data": {
|
|
"status_data": async_redact_data(
|
|
entry.runtime_data.status.data.to_dict(), TO_REDACT_AIROS
|
|
),
|
|
"firmware_data": async_redact_data(
|
|
entry.runtime_data.firmware.data
|
|
if entry.runtime_data.firmware is not None
|
|
else {},
|
|
TO_REDACT_AIROS,
|
|
),
|
|
},
|
|
}
|