1
mirror of https://github.com/home-assistant/core synced 2024-09-03 08:14:07 +02:00
ha-core/homeassistant/components/tibber/diagnostics.py
Daniel Hjelseth Høyer 549afff307
Tibber diagnostics (#64472)
Co-authored-by: Philip Allgaier <mail@spacegaier.de>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-01-20 15:03:14 +01:00

32 lines
957 B
Python

"""Diagnostics support for Tibber."""
from __future__ import annotations
import tibber
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from .const import DOMAIN
async def async_get_config_entry_diagnostics(
hass: HomeAssistant, config_entry: ConfigEntry
) -> dict:
"""Return diagnostics for a config entry."""
tibber_connection: tibber.Tibber = hass.data[DOMAIN]
diagnostics_data = {}
homes = {}
for home in tibber_connection.get_homes(only_active=False):
homes[home.home_id] = {
"last_data_timestamp": home.last_data_timestamp,
"has_active_subscription": home.has_active_subscription,
"has_real_time_consumption": home.has_real_time_consumption,
"last_cons_data_timestamp": home.last_cons_data_timestamp,
"country": home.country,
}
diagnostics_data["homes"] = homes
return diagnostics_data