Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics support for Hue."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
7 from homeassistant.components.diagnostics import REDACTED, async_redact_data
8 from homeassistant.config_entries import ConfigEntry
9 from homeassistant.const import CONF_API_KEY
10 from homeassistant.core import HomeAssistant
11 from homeassistant.helpers.typing import ConfigType
12 
13 from .const import CONF_SECURE_DEVICES_PIN, CONF_SERVICE_ACCOUNT, DATA_CONFIG, DOMAIN
14 from .http import GoogleConfig
15 from .smart_home import (
16  async_devices_query_response,
17  async_devices_sync_response,
18  create_sync_response,
19 )
20 
21 TO_REDACT = [
22  "uuid",
23  "baseUrl",
24  "webhookId",
25  CONF_SERVICE_ACCOUNT,
26  CONF_SECURE_DEVICES_PIN,
27  CONF_API_KEY,
28 ]
29 
30 
32  hass: HomeAssistant, entry: ConfigEntry
33 ) -> dict[str, Any]:
34  """Return diagnostic information."""
35  data = hass.data[DOMAIN]
36  config: GoogleConfig = data[entry.entry_id]
37  yaml_config: ConfigType = data[DATA_CONFIG]
38  devices = await async_devices_sync_response(hass, config, REDACTED)
39  sync = create_sync_response(REDACTED, devices)
40  query = await async_devices_query_response(hass, config, devices)
41 
42  return {
43  "config_entry": async_redact_data(entry.as_dict(), TO_REDACT),
44  "yaml_config": async_redact_data(yaml_config, TO_REDACT),
45  "sync": async_redact_data(sync, TO_REDACT),
46  "query": async_redact_data(query, TO_REDACT),
47  }
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:33
def async_devices_sync_response(hass, config, agent_user_id)
Definition: smart_home.py:106
def create_sync_response(str agent_user_id, list devices)
Definition: smart_home.py:359
def async_devices_query_response(hass, config, payload_devices)
Definition: smart_home.py:168