Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics support for Sensor.Community."""
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.config_entries import ConfigEntry
9 from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
10 from homeassistant.core import HomeAssistant
11 from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
12 
13 from .const import CONF_SENSOR_ID, DOMAIN
14 
15 TO_REDACT = {
16  CONF_LATITUDE,
17  CONF_LONGITUDE,
18  CONF_SENSOR_ID,
19 }
20 
21 
23  hass: HomeAssistant, entry: ConfigEntry
24 ) -> dict[str, Any]:
25  """Return diagnostics for a config entry."""
26  coordinator: DataUpdateCoordinator[dict[str, Any]] = hass.data[DOMAIN][
27  entry.entry_id
28  ]
29  return async_redact_data(coordinator.data, TO_REDACT)
dict async_redact_data(Mapping data, Iterable[Any] to_redact)
Definition: util.py:14
dict[str, Any] async_get_config_entry_diagnostics(HomeAssistant hass, ConfigEntry entry)
Definition: diagnostics.py:24