Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics support for bond."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
7 from homeassistant.components.diagnostics import async_redact_data
8 from homeassistant.core import HomeAssistant
9 
10 from . import BondConfigEntry
11 
12 TO_REDACT = {"access_token"}
13 
14 
16  hass: HomeAssistant, entry: BondConfigEntry
17 ) -> dict[str, Any]:
18  """Return diagnostics for a config entry."""
19  data = entry.runtime_data
20  hub = data.hub
21  return {
22  "entry": {
23  "title": entry.title,
24  "data": async_redact_data(entry.data, TO_REDACT),
25  },
26  "hub": {
27  "version": hub._version, # noqa: SLF001
28  },
29  "devices": [
30  {
31  "device_id": device.device_id,
32  "props": device.props,
33  "attrs": device._attrs, # noqa: SLF001
34  "supported_actions": device._supported_actions, # noqa: SLF001
35  }
36  for device in hub.devices
37  ],
38  }
dict[str, Any] async_get_config_entry_diagnostics(HomeAssistant hass, BondConfigEntry entry)
Definition: diagnostics.py:17
dict async_redact_data(Mapping data, Iterable[Any] to_redact)
Definition: util.py:14