mirror of
https://github.com/home-assistant/core.git
synced 2025-08-01 17:48:26 +00:00
Fix KeyError
in friends coordinator (#149684)
This commit is contained in:
parent
a76af50c10
commit
8d27ca1e21
@ -6,7 +6,7 @@ from abc import abstractmethod
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
from psnawp_api.core.psnawp_exceptions import (
|
from psnawp_api.core.psnawp_exceptions import (
|
||||||
PSNAWPAuthenticationError,
|
PSNAWPAuthenticationError,
|
||||||
@ -29,7 +29,7 @@ from homeassistant.exceptions import (
|
|||||||
)
|
)
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
|
||||||
from .const import CONF_ACCOUNT_ID, DOMAIN
|
from .const import DOMAIN
|
||||||
from .helpers import PlaystationNetwork, PlaystationNetworkData
|
from .helpers import PlaystationNetwork, PlaystationNetworkData
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -176,7 +176,9 @@ class PlaystationNetworkFriendDataCoordinator(
|
|||||||
|
|
||||||
def _setup(self) -> None:
|
def _setup(self) -> None:
|
||||||
"""Set up the coordinator."""
|
"""Set up the coordinator."""
|
||||||
self.user = self.psn.psn.user(account_id=self.subentry.data[CONF_ACCOUNT_ID])
|
if TYPE_CHECKING:
|
||||||
|
assert self.subentry.unique_id
|
||||||
|
self.user = self.psn.psn.user(account_id=self.subentry.unique_id)
|
||||||
self.profile = self.user.profile()
|
self.profile = self.user.profile()
|
||||||
|
|
||||||
async def _async_setup(self) -> None:
|
async def _async_setup(self) -> None:
|
||||||
|
@ -14,11 +14,7 @@ from psnawp_api.models.trophies import (
|
|||||||
)
|
)
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.playstation_network.const import (
|
from homeassistant.components.playstation_network.const import CONF_NPSSO, DOMAIN
|
||||||
CONF_ACCOUNT_ID,
|
|
||||||
CONF_NPSSO,
|
|
||||||
DOMAIN,
|
|
||||||
)
|
|
||||||
from homeassistant.config_entries import ConfigSubentryData
|
from homeassistant.config_entries import ConfigSubentryData
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
@ -40,7 +36,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
unique_id=PSN_ID,
|
unique_id=PSN_ID,
|
||||||
subentries_data=[
|
subentries_data=[
|
||||||
ConfigSubentryData(
|
ConfigSubentryData(
|
||||||
data={CONF_ACCOUNT_ID: "fren-psn-id"},
|
data={},
|
||||||
subentry_id="ABCDEF",
|
subentry_id="ABCDEF",
|
||||||
subentry_type="friend",
|
subentry_type="friend",
|
||||||
title="PublicUniversalFriend",
|
title="PublicUniversalFriend",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user