Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics support for AirNow."""
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.const import (
9  CONF_API_KEY,
10  CONF_LATITUDE,
11  CONF_LONGITUDE,
12  CONF_UNIQUE_ID,
13 )
14 from homeassistant.core import HomeAssistant
15 
16 from . import AirNowConfigEntry
17 
18 ATTR_LATITUDE_CAP = "Latitude"
19 ATTR_LONGITUDE_CAP = "Longitude"
20 ATTR_REPORTING_AREA = "ReportingArea"
21 ATTR_STATE_CODE = "StateCode"
22 
23 CONF_TITLE = "title"
24 
25 TO_REDACT = {
26  ATTR_LATITUDE_CAP,
27  ATTR_LONGITUDE_CAP,
28  ATTR_REPORTING_AREA,
29  ATTR_STATE_CODE,
30  CONF_API_KEY,
31  CONF_LATITUDE,
32  CONF_LONGITUDE,
33  # The config entry title has latitude/longitude:
34  CONF_TITLE,
35  # The config entry unique ID has latitude/longitude:
36  CONF_UNIQUE_ID,
37 }
38 
39 
41  hass: HomeAssistant, entry: AirNowConfigEntry
42 ) -> dict[str, Any]:
43  """Return diagnostics for a config entry."""
44  coordinator = entry.runtime_data
45 
46  return async_redact_data(
47  {
48  "entry": entry.as_dict(),
49  "data": coordinator.data,
50  },
51  TO_REDACT,
52  )
dict[str, Any] async_get_config_entry_diagnostics(HomeAssistant hass, AirNowConfigEntry entry)
Definition: diagnostics.py:42
dict async_redact_data(Mapping data, Iterable[Any] to_redact)
Definition: util.py:14