core/homeassistant/components/netatmo/diagnostics.py

42 lines
1.0 KiB
Python
Raw Normal View History

"""Diagnostics support for Netatmo."""
from __future__ import annotations
2022-01-20 22:02:47 +00:00
from homeassistant.components.diagnostics import async_redact_data
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from .const import DATA_HANDLER, DOMAIN
from .data_handler import NetatmoDataHandler
2022-01-20 22:02:47 +00:00
TO_REDACT = {
"access_token",
"refresh_token",
"restricted_access_token",
"restricted_refresh_token",
"webhook_id",
"lat_ne",
"lat_sw",
"lon_ne",
"lon_sw",
}
async def async_get_config_entry_diagnostics(
hass: HomeAssistant, config_entry: ConfigEntry
) -> dict:
"""Return diagnostics for a config entry."""
data_handler: NetatmoDataHandler = hass.data[DOMAIN][config_entry.entry_id][
DATA_HANDLER
]
2022-01-20 22:02:47 +00:00
return {
"info": async_redact_data(
{
**config_entry.as_dict(),
"webhook_registered": data_handler.webhook,
},
TO_REDACT,
),
"data": async_redact_data(data_handler.data, TO_REDACT),
}