Use entry.as_dict() in IQVIA diagnostics (#80113)

This commit is contained in:
Aaron Bach 2022-10-11 10:13:58 -06:00 committed by GitHub
parent 0f002e7044
commit c05390e09b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 69 additions and 39 deletions

View file

@ -3,11 +3,32 @@ from __future__ import annotations
from typing import Any
from homeassistant.components.diagnostics import async_redact_data
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_UNIQUE_ID
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from .const import DOMAIN
from .const import CONF_ZIP_CODE, DOMAIN
CONF_CITY = "City"
CONF_DISPLAY_LOCATION = "DisplayLocation"
CONF_MARKET = "Market"
CONF_TITLE = "title"
CONF_ZIP_CAP = "ZIP"
CONF_STATE_CAP = "State"
TO_REDACT = {
CONF_CITY,
CONF_DISPLAY_LOCATION,
CONF_MARKET,
CONF_STATE_CAP,
# Config entry title and unique ID may contain sensitive data:
CONF_TITLE,
CONF_UNIQUE_ID,
CONF_ZIP_CAP,
CONF_ZIP_CODE,
}
async def async_get_config_entry_diagnostics(
@ -17,12 +38,12 @@ async def async_get_config_entry_diagnostics(
coordinators: dict[str, DataUpdateCoordinator] = hass.data[DOMAIN][entry.entry_id]
return {
"entry": {
"title": entry.title,
"data": dict(entry.data),
},
"data": {
data_type: coordinator.data
for data_type, coordinator in coordinators.items()
},
"entry": async_redact_data(entry.as_dict(), TO_REDACT),
"data": async_redact_data(
{
data_type: coordinator.data
for data_type, coordinator in coordinators.items()
},
TO_REDACT,
),
}