Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics support for NWS."""
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 . import NWSConfigEntry
12 from .const import CONF_STATION
13 
14 CONFIG_TO_REDACT = {CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_STATION}
15 OBSERVATION_TO_REDACT = {"station"}
16 
17 
19  hass: HomeAssistant,
20  config_entry: NWSConfigEntry,
21 ) -> dict[str, Any]:
22  """Return diagnostics for a config entry."""
23  nws_data = config_entry.runtime_data.api
24 
25  return {
26  "info": async_redact_data(config_entry.data, CONFIG_TO_REDACT),
27  "observation": async_redact_data(nws_data.observation, OBSERVATION_TO_REDACT),
28  "forecast": nws_data.forecast,
29  "forecast_hourly": nws_data.forecast_hourly,
30  }
dict async_redact_data(Mapping data, Iterable[Any] to_redact)
Definition: util.py:14
dict[str, Any] async_get_config_entry_diagnostics(HomeAssistant hass, NWSConfigEntry config_entry)
Definition: diagnostics.py:21