Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics support for IQVIA."""
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.const import CONF_UNIQUE_ID
10 from homeassistant.core import HomeAssistant
11 from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
12 
13 from .const import CONF_ZIP_CODE, DOMAIN
14 
15 CONF_CITY = "City"
16 CONF_DISPLAY_LOCATION = "DisplayLocation"
17 CONF_MARKET = "Market"
18 CONF_TITLE = "title"
19 CONF_ZIP_CAP = "ZIP"
20 CONF_STATE_CAP = "State"
21 
22 TO_REDACT = {
23  CONF_CITY,
24  CONF_DISPLAY_LOCATION,
25  CONF_MARKET,
26  CONF_STATE_CAP,
27  # Config entry title and unique ID may contain sensitive data:
28  CONF_TITLE,
29  CONF_UNIQUE_ID,
30  CONF_ZIP_CAP,
31  CONF_ZIP_CODE,
32 }
33 
34 
36  hass: HomeAssistant, entry: ConfigEntry
37 ) -> dict[str, Any]:
38  """Return diagnostics for a config entry."""
39  coordinators: dict[str, DataUpdateCoordinator[dict[str, Any]]] = hass.data[DOMAIN][
40  entry.entry_id
41  ]
42 
43  return {
44  "entry": async_redact_data(entry.as_dict(), TO_REDACT),
45  "data": async_redact_data(
46  {
47  data_type: coordinator.data
48  for data_type, coordinator in coordinators.items()
49  },
50  TO_REDACT,
51  ),
52  }
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 entry)
Definition: diagnostics.py:37