Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics support for IPMA."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
7 from homeassistant.config_entries import ConfigEntry
8 from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
9 from homeassistant.core import HomeAssistant
10 
11 from .const import DATA_API, DATA_LOCATION, DOMAIN
12 
13 
15  hass: HomeAssistant, entry: ConfigEntry
16 ) -> dict[str, Any]:
17  """Return diagnostics for a config entry."""
18 
19  location = hass.data[DOMAIN][entry.entry_id][DATA_LOCATION]
20  api = hass.data[DOMAIN][entry.entry_id][DATA_API]
21 
22  return {
23  "location_information": {
24  "latitude": round(float(entry.data[CONF_LATITUDE]), 3),
25  "longitude": round(float(entry.data[CONF_LONGITUDE]), 3),
26  "global_id_local": location.global_id_local,
27  "id_station": location.id_station,
28  "name": location.name,
29  "station": location.station,
30  },
31  "current_weather": await location.observation(api),
32  "weather_forecast": await location.forecast(api, 1),
33  }
dict[str, Any] async_get_config_entry_diagnostics(HomeAssistant hass, ConfigEntry entry)
Definition: diagnostics.py:16