Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics support for Ambient PWS."""
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 CONF_API_KEY, CONF_LOCATION, CONF_UNIQUE_ID
9 from homeassistant.core import HomeAssistant
10 
11 from . import AmbientStationConfigEntry
12 from .const import CONF_APP_KEY
13 
14 CONF_API_KEY_CAMEL = "apiKey"
15 CONF_APP_KEY_CAMEL = "appKey"
16 CONF_DEVICE_ID_CAMEL = "deviceId"
17 CONF_MAC_ADDRESS = "mac_address"
18 CONF_MAC_ADDRESS_CAMEL = "macAddress"
19 CONF_TITLE = "title"
20 CONF_TZ = "tz"
21 
22 TO_REDACT = {
23  CONF_API_KEY,
24  CONF_API_KEY_CAMEL,
25  CONF_APP_KEY,
26  CONF_APP_KEY_CAMEL,
27  CONF_DEVICE_ID_CAMEL,
28  CONF_LOCATION,
29  CONF_MAC_ADDRESS,
30  CONF_MAC_ADDRESS_CAMEL,
31  CONF_TZ,
32  # Config entry title and unique ID may contain sensitive data:
33  CONF_TITLE,
34  CONF_UNIQUE_ID,
35 }
36 
37 
39  hass: HomeAssistant, entry: AmbientStationConfigEntry
40 ) -> dict[str, Any]:
41  """Return diagnostics for a config entry."""
42  return {
43  "entry": async_redact_data(entry.as_dict(), TO_REDACT),
44  "stations": async_redact_data(entry.runtime_data.stations, TO_REDACT),
45  }
dict[str, Any] async_get_config_entry_diagnostics(HomeAssistant hass, AmbientStationConfigEntry entry)
Definition: diagnostics.py:40
dict async_redact_data(Mapping data, Iterable[Any] to_redact)
Definition: util.py:14