Skip to content

Commit f9bd9f4

Browse files
authored
Add diagnostics in Google Weather (#166105)
1 parent e4620a2 commit f9bd9f4

File tree

4 files changed

+457
-1
lines changed

4 files changed

+457
-1
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""Diagnostics support for Google Weather."""
2+
3+
from __future__ import annotations
4+
5+
from typing import Any
6+
7+
from homeassistant.components.diagnostics import async_redact_data
8+
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE
9+
from homeassistant.core import HomeAssistant
10+
11+
from .const import CONF_REFERRER
12+
from .coordinator import GoogleWeatherConfigEntry
13+
14+
TO_REDACT = {
15+
CONF_API_KEY,
16+
CONF_REFERRER,
17+
CONF_LATITUDE,
18+
CONF_LONGITUDE,
19+
}
20+
21+
22+
async def async_get_config_entry_diagnostics(
23+
hass: HomeAssistant, entry: GoogleWeatherConfigEntry
24+
) -> dict[str, Any]:
25+
"""Return diagnostics for a config entry."""
26+
diag_data: dict[str, Any] = {
27+
"entry": entry.as_dict(),
28+
"subentries": {},
29+
}
30+
31+
for subentry_id, subentry_rt in entry.runtime_data.subentries_runtime_data.items():
32+
diag_data["subentries"][subentry_id] = {
33+
"observation_data": subentry_rt.coordinator_observation.data.to_dict()
34+
if subentry_rt.coordinator_observation.data
35+
else None,
36+
"daily_forecast_data": subentry_rt.coordinator_daily_forecast.data.to_dict()
37+
if subentry_rt.coordinator_daily_forecast.data
38+
else None,
39+
"hourly_forecast_data": subentry_rt.coordinator_hourly_forecast.data.to_dict()
40+
if subentry_rt.coordinator_hourly_forecast.data
41+
else None,
42+
}
43+
44+
return async_redact_data(diag_data, TO_REDACT)

homeassistant/components/google_weather/quality_scale.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ rules:
4343

4444
# Gold
4545
devices: done
46-
diagnostics: todo
46+
diagnostics: done
4747
discovery-update-info:
4848
status: exempt
4949
comment: No discovery.

0 commit comments

Comments
 (0)