Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics support for LG webOS Smart TV."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
7 from aiowebostv import WebOsClient
8 
9 from homeassistant.components.diagnostics import async_redact_data
10 from homeassistant.config_entries import ConfigEntry
11 from homeassistant.const import CONF_CLIENT_SECRET, CONF_HOST, CONF_UNIQUE_ID
12 from homeassistant.core import HomeAssistant
13 
14 from .const import DATA_CONFIG_ENTRY, DOMAIN
15 
16 TO_REDACT = {
17  CONF_CLIENT_SECRET,
18  CONF_UNIQUE_ID,
19  CONF_HOST,
20  "device_id",
21  "deviceUUID",
22  "icon",
23  "largeIcon",
24 }
25 
26 
28  hass: HomeAssistant, entry: ConfigEntry
29 ) -> dict[str, Any]:
30  """Return diagnostics for a config entry."""
31  client: WebOsClient = hass.data[DOMAIN][DATA_CONFIG_ENTRY][entry.entry_id]
32 
33  client_data = {
34  "is_registered": client.is_registered(),
35  "is_connected": client.is_connected(),
36  "current_app_id": client.current_app_id,
37  "current_channel": client.current_channel,
38  "apps": client.apps,
39  "inputs": client.inputs,
40  "system_info": client.system_info,
41  "software_info": client.software_info,
42  "hello_info": client.hello_info,
43  "sound_output": client.sound_output,
44  "is_on": client.is_on,
45  }
46 
47  return async_redact_data(
48  {
49  "entry": entry.as_dict(),
50  "client": client_data,
51  },
52  TO_REDACT,
53  )
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:29