Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions custom_components/smartcar/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async def async_get_config_entry_diagnostics(
entry: ConfigEntry,
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
meta_coordinator = entry.runtime_data.meta_coordinator
coordinators: dict[str, SmartcarVehicleCoordinator] = (
entry.runtime_data.coordinators
)
Expand All @@ -54,6 +55,7 @@ async def async_get_config_entry_diagnostics(
coordinator_name: coordinator.data
for coordinator_name, coordinator in coordinators.items()
},
"metadata": meta_coordinator.data,
},
TO_REDACT,
),
Expand Down
2 changes: 2 additions & 0 deletions custom_components/smartcar/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def update_meta_coordinator_data[F: Callable[..., Any], ReturnT](fn: F) -> F:
async def wrapper(*args, **kwargs) -> ReturnT: # noqa: ANN002, ANN003
response = await fn(*args, **kwargs)
config_entry = kwargs["config_entry"]
request = args[2]
status = response.status
data = response.text or (response.body and response.body.decode("utf-8"))
meta_coordinator = config_entry.runtime_data.meta_coordinator
Expand All @@ -57,6 +58,7 @@ async def wrapper(*args, **kwargs) -> ReturnT: # noqa: ANN002, ANN003
"status": status,
**({"data": data} if data else {}),
},
"last_webhook_request": await request.text(),
}
)
return cast("ReturnT", response)
Expand Down
4 changes: 4 additions & 0 deletions tests/snapshots/test_diagnostics.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
'unique_id': 'a1d50709-3502-4faa-ba43-a5c7565e6a09',
'version': 2,
}),
'metadata': dict({
}),
'webhook_url': None,
})
# ---
Expand Down Expand Up @@ -261,6 +263,8 @@
'unique_id': 'a1d50709-3502-4faa-ba43-a5c7565e6a09',
'version': 2,
}),
'metadata': dict({
}),
'webhook_url': None,
})
# ---
Loading