Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics support for Netatmo."""
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.config_entries import ConfigEntry
9 from homeassistant.core import HomeAssistant
10 
11 from .const import DATA_HANDLER, DOMAIN
12 from .data_handler import ACCOUNT, NetatmoDataHandler
13 
14 TO_REDACT = {
15  "access_token",
16  "refresh_token",
17  "restricted_access_token",
18  "restricted_refresh_token",
19  "webhook_id",
20  "cloudhook_url",
21  "lat_ne",
22  "lat_sw",
23  "lon_ne",
24  "lon_sw",
25  "coordinates",
26  "name",
27  "timetable",
28  "zones",
29  "pseudo",
30  "url",
31 }
32 
33 
35  hass: HomeAssistant, config_entry: ConfigEntry
36 ) -> dict[str, Any]:
37  """Return diagnostics for a config entry."""
38  data_handler: NetatmoDataHandler = hass.data[DOMAIN][config_entry.entry_id][
39  DATA_HANDLER
40  ]
41 
42  return {
43  "info": async_redact_data(
44  {
45  **config_entry.as_dict(),
46  "webhook_registered": data_handler.webhook,
47  },
48  TO_REDACT,
49  ),
50  "data": {
51  ACCOUNT: async_redact_data(
52  getattr(data_handler.account, "raw_data"),
53  TO_REDACT,
54  )
55  },
56  }
dict async_redact_data(Mapping data, Iterable[Any] to_redact)
Definition: util.py:14
dict[str, Any] async_get_config_entry_diagnostics(HomeAssistant hass, ConfigEntry config_entry)
Definition: diagnostics.py:36