core/homeassistant/components/airnow/diagnostics.py

53 lines
1.2 KiB
Python
Raw Normal View History

2022-10-13 13:31:33 +00:00
"""Diagnostics support for AirNow."""
2022-10-13 13:31:33 +00:00
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,
CONF_UNIQUE_ID,
)
from homeassistant.core import HomeAssistant
2024-05-02 19:00:05 +00:00
from . import AirNowConfigEntry
2022-10-13 13:31:33 +00:00
ATTR_LATITUDE_CAP = "Latitude"
ATTR_LONGITUDE_CAP = "Longitude"
ATTR_REPORTING_AREA = "ReportingArea"
ATTR_STATE_CODE = "StateCode"
CONF_TITLE = "title"
TO_REDACT = {
ATTR_LATITUDE_CAP,
ATTR_LONGITUDE_CAP,
ATTR_REPORTING_AREA,
ATTR_STATE_CODE,
CONF_API_KEY,
CONF_LATITUDE,
CONF_LONGITUDE,
# The config entry title has latitude/longitude:
CONF_TITLE,
# The config entry unique ID has latitude/longitude:
CONF_UNIQUE_ID,
}
async def async_get_config_entry_diagnostics(
2024-05-02 19:00:05 +00:00
hass: HomeAssistant, entry: AirNowConfigEntry
2022-10-13 13:31:33 +00:00
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
2024-05-02 19:00:05 +00:00
coordinator = entry.runtime_data
2022-10-13 13:31:33 +00:00
return async_redact_data(
{
"entry": entry.as_dict(),
"data": coordinator.data,
},
TO_REDACT,
)