Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics support for Reolink."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
7 from homeassistant.core import HomeAssistant
8 
9 from .util import ReolinkConfigEntry, ReolinkData
10 
11 
13  hass: HomeAssistant, config_entry: ReolinkConfigEntry
14 ) -> dict[str, Any]:
15  """Return diagnostics for a config entry."""
16  reolink_data: ReolinkData = config_entry.runtime_data
17  host = reolink_data.host
18  api = host.api
19 
20  IPC_cam: dict[int, dict[str, Any]] = {}
21  for ch in api.channels:
22  IPC_cam[ch] = {}
23  IPC_cam[ch]["model"] = api.camera_model(ch)
24  IPC_cam[ch]["hardware version"] = api.camera_hardware_version(ch)
25  IPC_cam[ch]["firmware version"] = api.camera_sw_version(ch)
26  IPC_cam[ch]["encoding main"] = await api.get_encoding(ch)
27 
28  return {
29  "model": api.model,
30  "hardware version": api.hardware_version,
31  "firmware version": api.sw_version,
32  "HTTPS": api.use_https,
33  "HTTP(S) port": api.port,
34  "WiFi connection": api.wifi_connection,
35  "WiFi signal": api.wifi_signal,
36  "RTMP enabled": api.rtmp_enabled,
37  "RTSP enabled": api.rtsp_enabled,
38  "ONVIF enabled": api.onvif_enabled,
39  "event connection": host.event_connection,
40  "stream protocol": api.protocol,
41  "channels": api.channels,
42  "stream channels": api.stream_channels,
43  "IPC cams": IPC_cam,
44  "capabilities": api.capabilities,
45  "cmd list": host.update_cmd,
46  "firmware ch list": host.firmware_ch_list,
47  "api versions": api.checked_api_versions,
48  "abilities": api.abilities,
49  }