Skip to content

Commit

Permalink
Improve diagnostics in Teslemetry (home-assistant#117613)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bre77 authored May 18, 2024
1 parent b39028a commit 1b0c91f
Show file tree
Hide file tree
Showing 2 changed files with 397 additions and 286 deletions.
24 changes: 18 additions & 6 deletions homeassistant/components/teslemetry/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,32 @@
"drive_state_native_longitude",
]

ENERGY_REDACT = ["vin"]
ENERGY_LIVE_REDACT = ["vin"]
ENERGY_INFO_REDACT = ["installation_date"]


async def async_get_config_entry_diagnostics(
hass: HomeAssistant, config_entry: ConfigEntry
hass: HomeAssistant, entry: ConfigEntry
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
vehicles = [x.coordinator.data for x in config_entry.runtime_data.vehicles]
vehicles = [
{
"data": async_redact_data(x.coordinator.data, VEHICLE_REDACT),
# Stream diag will go here when implemented
}
for x in entry.runtime_data.vehicles
]
energysites = [
x.live_coordinator.data for x in config_entry.runtime_data.energysites
{
"live": async_redact_data(x.live_coordinator.data, ENERGY_LIVE_REDACT),
"info": async_redact_data(x.info_coordinator.data, ENERGY_INFO_REDACT),
}
for x in entry.runtime_data.energysites
]

# Return only the relevant children
return {
"vehicles": async_redact_data(vehicles, VEHICLE_REDACT),
"energysites": async_redact_data(energysites, ENERGY_REDACT),
"vehicles": vehicles,
"energysites": energysites,
"scopes": entry.runtime_data.scopes,
}
Loading

0 comments on commit 1b0c91f

Please sign in to comment.