Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics support for SimpliSafe."""
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 (
10  CONF_ADDRESS,
11  CONF_CODE,
12  CONF_LOCATION,
13  CONF_TOKEN,
14  CONF_UNIQUE_ID,
15  CONF_USERNAME,
16 )
17 from homeassistant.core import HomeAssistant
18 
19 from . import SimpliSafe
20 from .const import DOMAIN
21 
22 CONF_CREDIT_CARD = "creditCard"
23 CONF_EXPIRES = "expires"
24 CONF_LOCATION_NAME = "locationName"
25 CONF_PAYMENT_PROFILE_ID = "paymentProfileId"
26 CONF_SERIAL = "serial"
27 CONF_SID = "sid"
28 CONF_SYSTEM_ID = "system_id"
29 CONF_TITLE = "title"
30 CONF_UID = "uid"
31 CONF_WIFI_SSID = "wifi_ssid"
32 
33 TO_REDACT = {
34  CONF_ADDRESS,
35  CONF_CODE,
36  CONF_CREDIT_CARD,
37  CONF_EXPIRES,
38  CONF_LOCATION,
39  CONF_LOCATION_NAME,
40  CONF_PAYMENT_PROFILE_ID,
41  CONF_SERIAL,
42  CONF_SID,
43  CONF_SYSTEM_ID,
44  # Config entry title may contain sensitive data:
45  CONF_TITLE,
46  CONF_TOKEN,
47  CONF_UID,
48  # Config entry unique ID may contain sensitive data:
49  CONF_UNIQUE_ID,
50  CONF_USERNAME,
51  CONF_WIFI_SSID,
52 }
53 
54 
56  hass: HomeAssistant, entry: ConfigEntry
57 ) -> dict[str, Any]:
58  """Return diagnostics for a config entry."""
59  simplisafe: SimpliSafe = hass.data[DOMAIN][entry.entry_id]
60 
61  return async_redact_data(
62  {
63  "entry": entry.as_dict(),
64  "subscription_data": simplisafe.subscription_data,
65  "systems": [system.as_dict() for system in simplisafe.systems.values()],
66  },
67  TO_REDACT,
68  )
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:57