Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add diagnostics support #23

Merged
merged 1 commit into from
Nov 10, 2024
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
5 changes: 5 additions & 0 deletions custom_components/playstation_network/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def __init__(self, hass: HomeAssistant, api, user, client) -> None:
"title_stats": {},
"username": "",
"recent_titles": [],
"country": "",
"language": "",
}

async def _async_update_data(self) -> dict[str, Any]:
Expand Down Expand Up @@ -78,6 +80,9 @@ async def _async_update_data(self) -> dict[str, Any]:
lambda: self.client.trophy_summary()
)

self.data["country"] = self.hass.config.country
self.data["language"] = self.hass.config.language

if (
self.data["available"] is True
and self.data["title_metadata"].get("npTitleId") is not None
Expand Down
22 changes: 22 additions & 0 deletions custom_components/playstation_network/diagnostics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Diagnostics support for Playstation Network."""

from __future__ import annotations

from typing import Any

from homeassistant.components.diagnostics.util import async_redact_data
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant

from .coordinator import PsnCoordinator
from .const import DOMAIN, PSN_COORDINATOR

TO_REDACT = {}


async def async_get_config_entry_diagnostics(
hass: HomeAssistant, entry: ConfigEntry
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
coordinator: PsnCoordinator = hass.data[DOMAIN][entry.entry_id][PSN_COORDINATOR]
return async_redact_data(coordinator.data, TO_REDACT)