1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-08 17:49:37 +01:00
Files
core/homeassistant/components/forecast_solar/diagnostics.py
T
Artem Khvastunov b056723b98 Add multi-plane support for Forecast.Solar integration (#160058)
Co-authored-by: Junie <noreply@jb.gg>
Co-authored-by: Junie <junie@jetbrains.com>
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-01 17:42:17 +02:00

64 lines
2.2 KiB
Python

"""Diagnostics support for Forecast.Solar integration."""
from __future__ import annotations
from typing import Any
from homeassistant.components.diagnostics import async_redact_data
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import HomeAssistant
from . import ForecastSolarConfigEntry
TO_REDACT = {
CONF_API_KEY,
CONF_LATITUDE,
CONF_LONGITUDE,
}
async def async_get_config_entry_diagnostics(
hass: HomeAssistant, entry: ForecastSolarConfigEntry
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
coordinator = entry.runtime_data
return {
"entry": {
"title": entry.title,
"data": async_redact_data(entry.data, TO_REDACT),
"options": async_redact_data(entry.options, TO_REDACT),
"subentries": [
{
"data": dict(subentry.data),
"title": subentry.title,
}
for subentry in entry.subentries.values()
],
},
"data": {
"energy_production_today": coordinator.data.energy_production_today,
"energy_production_today_remaining": coordinator.data.energy_production_today_remaining,
"energy_production_tomorrow": coordinator.data.energy_production_tomorrow,
"energy_current_hour": coordinator.data.energy_current_hour,
"power_production_now": coordinator.data.power_production_now,
"watts": {
watt_datetime.isoformat(): watt_value
for watt_datetime, watt_value in coordinator.data.watts.items()
},
"wh_days": {
wh_datetime.isoformat(): wh_value
for wh_datetime, wh_value in coordinator.data.wh_days.items()
},
"wh_period": {
wh_datetime.isoformat(): wh_value
for wh_datetime, wh_value in coordinator.data.wh_period.items()
},
},
"account": {
"type": coordinator.data.account_type.value,
"rate_limit": coordinator.data.api_rate_limit,
"timezone": coordinator.data.timezone,
},
}