redact tracking and order number from diagnostics
"""Provide diagnostics for Mail and Packages."""
from __future__ import annotations
+import logging
+
from typing import Any
from homeassistant.components.diagnostics import async_redact_data
from homeassistant.config_entries import ConfigEntry
-from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
+from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, CONF_RESOURCES
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntry
@@ -14,6 +16,7 @@ from .const import (
DOMAIN,
)
+_LOGGER = logging.getLogger(__name__)
REDACT_KEYS = {CONF_PASSWORD, CONF_USERNAME}
@@ -33,4 +36,13 @@ async def async_get_device_diagnostics(
) -> dict[str, Any]:
"""Return diagnostics for a device."""
coordinator = hass.data[DOMAIN][config_entry.entry_id][COORDINATOR]
- return coordinator.data
+
+ for variable in coordinator.data:
+ if "tracking" in variable or "order" in variable:
+ _LOGGER.debug("Atempting to add: %s for redaction.", variable)
+ REDACT_KEYS.add(variable)
+
+ _LOGGER.debug("Redacted keys: %s", REDACT_KEYS)
+
+ return async_redact_data(coordinator.data, REDACT_KEYS)
+
