Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics support for 1-Wire."""
2 
3 from __future__ import annotations
4 
5 from dataclasses import asdict
6 from typing import Any
7 
8 from homeassistant.components.diagnostics import async_redact_data
9 from homeassistant.const import CONF_HOST
10 from homeassistant.core import HomeAssistant
11 
12 from . import OneWireConfigEntry
13 
14 TO_REDACT = {CONF_HOST}
15 
16 
18  hass: HomeAssistant, entry: OneWireConfigEntry
19 ) -> dict[str, Any]:
20  """Return diagnostics for a config entry."""
21  onewire_hub = entry.runtime_data
22 
23  return {
24  "entry": {
25  "title": entry.title,
26  "data": async_redact_data(entry.data, TO_REDACT),
27  "options": {**entry.options},
28  },
29  "devices": [asdict(device_details) for device_details in onewire_hub.devices]
30  if onewire_hub.devices
31  else [],
32  }
dict async_redact_data(Mapping data, Iterable[Any] to_redact)
Definition: util.py:14
dict[str, Any] async_get_config_entry_diagnostics(HomeAssistant hass, OneWireConfigEntry entry)
Definition: diagnostics.py:19