Custom integration connecting Home Assistant to a Reticulum network over a TCPClientInterface and exchanging LXMF messages, with an Assist conversation bridge, notify entity, sensors (incl. interface telemetry), buttons, services, bus events and device triggers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
"""Diagnostics support for Reticulum."""
|
|
|
|
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 CONF_ALLOWED_IDENTITIES, CONF_DEFAULT_RECIPIENT, DOMAIN
|
|
|
|
TO_REDACT = {CONF_DEFAULT_RECIPIENT, CONF_ALLOWED_IDENTITIES}
|
|
|
|
|
|
async def async_get_config_entry_diagnostics(
|
|
hass: HomeAssistant, entry: ConfigEntry
|
|
) -> dict[str, Any]:
|
|
"""Return diagnostics for a config entry."""
|
|
runtime = hass.data[DOMAIN][entry.entry_id]
|
|
state = runtime.manager.state
|
|
return {
|
|
"entry": {
|
|
"data": dict(entry.data),
|
|
"options": async_redact_data(dict(entry.options), TO_REDACT),
|
|
},
|
|
"state": {
|
|
"started": state.started,
|
|
"interface_online": state.interface_online,
|
|
"lxmf_address": state.lxmf_address,
|
|
"display_name": state.display_name,
|
|
"messages_received": state.messages_received,
|
|
"messages_sent": state.messages_sent,
|
|
"messages_failed": state.messages_failed,
|
|
"peer_count": len(state.peers),
|
|
"peers": [
|
|
{"name": p.display_name, "hops": p.hops, "stamp_cost": p.stamp_cost}
|
|
for p in state.peers.values()
|
|
],
|
|
},
|
|
}
|