Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics support for Tibber."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
7 import tibber
8 
9 from homeassistant.config_entries import ConfigEntry
10 from homeassistant.core import HomeAssistant
11 
12 from .const import DOMAIN
13 
14 
16  hass: HomeAssistant, config_entry: ConfigEntry
17 ) -> dict[str, Any]:
18  """Return diagnostics for a config entry."""
19  tibber_connection: tibber.Tibber = hass.data[DOMAIN]
20 
21  return {
22  "homes": [
23  {
24  "last_data_timestamp": home.last_data_timestamp,
25  "has_active_subscription": home.has_active_subscription,
26  "has_real_time_consumption": home.has_real_time_consumption,
27  "last_cons_data_timestamp": home.last_cons_data_timestamp,
28  "country": home.country,
29  }
30  for home in tibber_connection.get_homes(only_active=False)
31  ]
32  }
dict[str, Any] async_get_config_entry_diagnostics(HomeAssistant hass, ConfigEntry config_entry)
Definition: diagnostics.py:17