Skip to content

Commit

Permalink
Redact cetain data in diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
bouwew committed Apr 28, 2024
1 parent c3aa238 commit e41ca20
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 87 deletions.
5 changes: 5 additions & 0 deletions homeassistant/components/plugwise/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@
LOGGER = logging.getLogger(__package__)

API: Final = "api"
AVAILABLE_SCHEDULES: Final = "available_schedules"
DEVICES: Final = "devices"
FLOW_SMILE: Final = "smile (Adam/Anna/P1)"
FLOW_STRETCH: Final = "stretch (Stretch)"
FLOW_TYPE: Final = "flow_type"
GATEWAY: Final = "gateway"
MAC_ADDRESS: Final = "mac_address"
PW_TYPE: Final = "plugwise_type"
SELECT_SCHEDULE: Final = "select_schedule"
SMILE: Final = "smile"
STRETCH: Final = "stretch"
STRETCH_USERNAME: Final = "stretch"
ZIGBEE_MAC_ADDRESS: Final = "zigbee_mac_address"

PLATFORMS: Final[list[str]] = [
Platform.BINARY_SENSOR,
Expand Down
27 changes: 22 additions & 5 deletions homeassistant/components/plugwise/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,35 @@
from typing import Any

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_NAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers.redact import async_redact_data

from .const import DOMAIN
from .const import (
AVAILABLE_SCHEDULES,
DEVICES,
DOMAIN,
GATEWAY,
MAC_ADDRESS,
SELECT_SCHEDULE,
ZIGBEE_MAC_ADDRESS,
)
from .coordinator import PlugwiseDataUpdateCoordinator

KEYS_TO_REDACT = {
ATTR_NAME,
AVAILABLE_SCHEDULES,
MAC_ADDRESS,
SELECT_SCHEDULE,
ZIGBEE_MAC_ADDRESS,
}


async def async_get_config_entry_diagnostics(
hass: HomeAssistant, entry: ConfigEntry
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
coordinator: PlugwiseDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
return {
"gateway": coordinator.data.gateway,
"devices": coordinator.data.devices,
}
data = async_redact_data(coordinator.data.devices, KEYS_TO_REDACT)

return {GATEWAY: coordinator.data.gateway, DEVICES: data}

0 comments on commit e41ca20

Please sign in to comment.