diff --git a/homeassistant/components/playstation_network/config_flow.py b/homeassistant/components/playstation_network/config_flow.py index 882cc5efde1..036c9bdd2cb 100644 --- a/homeassistant/components/playstation_network/config_flow.py +++ b/homeassistant/components/playstation_network/config_flow.py @@ -27,8 +27,8 @@ class PlaystationNetworkConfigFlow(ConfigFlow, domain=DOMAIN): errors: dict[str, str] = {} if user_input is not None: npsso = PlaystationNetwork.parse_npsso_token(user_input[CONF_NPSSO]) + psn = PlaystationNetwork(npsso) try: - psn = PlaystationNetwork(npsso) user: User = await self.hass.async_add_executor_job(psn.get_user) except PSNAWPAuthenticationError: errors["base"] = "invalid_auth" diff --git a/homeassistant/components/playstation_network/media_player.py b/homeassistant/components/playstation_network/media_player.py index 3b30d8ec4df..5e3e35bb14a 100644 --- a/homeassistant/components/playstation_network/media_player.py +++ b/homeassistant/components/playstation_network/media_player.py @@ -142,11 +142,3 @@ class PsnMediaPlayerEntity( if title.get("format", "") == PlatformType.PS4: return title.get("npTitleIconUrl") return None - - @property - def is_on(self) -> bool: - """Is user available on the Playstation Network.""" - return ( - self.coordinator.data.available is True - and self.key == self.coordinator.data.platform.get("platform", "") - ) diff --git a/homeassistant/components/playstation_network/quality_scale.yaml b/homeassistant/components/playstation_network/quality_scale.yaml index e6eed0111df..36c28f19145 100644 --- a/homeassistant/components/playstation_network/quality_scale.yaml +++ b/homeassistant/components/playstation_network/quality_scale.yaml @@ -24,10 +24,9 @@ rules: runtime-data: done test-before-configure: done test-before-setup: done - unique-config-entry: - done + unique-config-entry: done - # Silver + # Silver action-exceptions: status: exempt comment: Integration has no actions @@ -49,9 +48,7 @@ rules: discovery-update-info: status: exempt comment: Discovery flow is not applicable for this integration - discovery: - status: exempt - comment: Discovery flow is not applicable for this integration + discovery: todo docs-data-update: done docs-examples: todo docs-known-limitations: done diff --git a/homeassistant/components/playstation_network/strings.json b/homeassistant/components/playstation_network/strings.json index c728fa6f700..01fc551d929 100644 --- a/homeassistant/components/playstation_network/strings.json +++ b/homeassistant/components/playstation_network/strings.json @@ -6,7 +6,7 @@ "npsso": "NPSSO token" }, "data_description": { - "npsso": "Please supply the NPSSO token generated during successful login of your PlayStation Network account" + "npsso": "The NPSSO token is generated during successful login of your PlayStation Network account and is used to authenticate your requests from with Home Assistant." }, "description": "To obtain your NPSSO token, log in to your [PlayStation account]({psn_link}) first. Then [click here]({npsso_link}) to retrieve the token." } @@ -18,7 +18,7 @@ "unknown": "[%key:common::config_flow::error::unknown%]" }, "abort": { - "already_configured": "[%key:common::config_flow::abort::already_configured_device%]" + "already_configured": "[%key:common::config_flow::abort::already_configured_account%]" } }, "exceptions": { diff --git a/tests/components/playstation_network/test_config_flow.py b/tests/components/playstation_network/test_config_flow.py index f673fce4829..f5931d44976 100644 --- a/tests/components/playstation_network/test_config_flow.py +++ b/tests/components/playstation_network/test_config_flow.py @@ -35,12 +35,12 @@ class mockUser: ('{"npsso": "TEST_NPSSO_TOKEN"}'), ], ) -async def test_form_success(hass: HomeAssistant, npsso) -> None: - """Test we get the form.""" +async def test_manual_config(hass: HomeAssistant, npsso) -> None: + """Test creating via manual configuration.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == FlowResultType.FORM + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with patch( @@ -51,9 +51,9 @@ async def test_form_success(hass: HomeAssistant, npsso) -> None: result["flow_id"], {CONF_NPSSO: npsso}, ) - await hass.async_block_till_done() assert result["type"] == FlowResultType.CREATE_ENTRY + assert result["result"].unique_id == "my-psn-id" assert result["data"] == { CONF_NPSSO: "TEST_NPSSO_TOKEN", } @@ -82,7 +82,6 @@ async def test_form_already_configured( result["flow_id"], {CONF_NPSSO: NPSSO_TOKEN}, ) - await hass.async_block_till_done() assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" @@ -116,7 +115,6 @@ async def test_form_failures(hass: HomeAssistant, raise_error, text_error) -> No context={"source": config_entries.SOURCE_USER}, data={CONF_NPSSO: NPSSO_TOKEN}, ) - await hass.async_block_till_done() assert result["errors"] == {"base": text_error} @@ -134,7 +132,6 @@ async def test_form_failures(hass: HomeAssistant, raise_error, text_error) -> No result["flow_id"], {CONF_NPSSO: NPSSO_TOKEN}, ) - await hass.async_block_till_done() assert result["type"] == FlowResultType.CREATE_ENTRY assert result["data"] == {