Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics support for Acaia."""
2 
3 from __future__ import annotations
4 
5 from dataclasses import asdict
6 from typing import Any
7 
8 from homeassistant.core import HomeAssistant
9 
10 from . import AcaiaConfigEntry
11 
12 
14  hass: HomeAssistant,
15  entry: AcaiaConfigEntry,
16 ) -> dict[str, Any]:
17  """Return diagnostics for a config entry."""
18  coordinator = entry.runtime_data
19  scale = coordinator.scale
20 
21  # collect all data sources
22  return {
23  "model": scale.model,
24  "device_state": (
25  asdict(scale.device_state) if scale.device_state is not None else ""
26  ),
27  "mac": scale.mac,
28  "last_disconnect_time": scale.last_disconnect_time,
29  "timer": scale.timer,
30  "weight": scale.weight,
31  }
dict[str, Any] async_get_config_entry_diagnostics(HomeAssistant hass, AcaiaConfigEntry entry)
Definition: diagnostics.py:16