mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-09 00:44:32 +02:00
added HA diagnostics implementation
This commit is contained in:
parent
e67c5a942c
commit
5d7dc89fa0
1 changed files with 57 additions and 0 deletions
57
custom_components/mikrotik_router/diagnostics.py
Normal file
57
custom_components/mikrotik_router/diagnostics.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
"""Diagnostics support for Mikrotik Router."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.diagnostics import async_redact_data
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
TO_REDACT = {
|
||||
"ip-address",
|
||||
"client-ip-address",
|
||||
"address",
|
||||
"active-address",
|
||||
"mac-address",
|
||||
"active-mac-address",
|
||||
"orig-mac-address",
|
||||
"port-mac-address",
|
||||
"client-mac-address",
|
||||
"client-id",
|
||||
"active-client-id",
|
||||
"eeprom",
|
||||
"sfp-vendor-serial",
|
||||
"gateway",
|
||||
"dns-server",
|
||||
"wins-server",
|
||||
"ntp-server",
|
||||
"caps-manager",
|
||||
"serial-number",
|
||||
"source",
|
||||
"from-addresses",
|
||||
"to-addresses",
|
||||
"src-address",
|
||||
"dst-address",
|
||||
"username",
|
||||
"password",
|
||||
"caller-id",
|
||||
"target",
|
||||
"ssid",
|
||||
}
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, config_entry: ConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
controller = hass.data[DOMAIN][config_entry.entry_id]
|
||||
diag: dict[str, Any] = {}
|
||||
diag["entry"]: dict[str, Any] = {}
|
||||
|
||||
diag["entry"]["data"] = async_redact_data(config_entry.data, TO_REDACT)
|
||||
diag["entry"]["options"] = async_redact_data(config_entry.options, TO_REDACT)
|
||||
diag["data"] = async_redact_data(controller.data, TO_REDACT)
|
||||
|
||||
return diag
|
Loading…
Add table
Add a link
Reference in a new issue