diff --git a/homeassistant/components/ps4/manifest.json b/homeassistant/components/ps4/manifest.json index 4cc86f109f84a2309ec43ef16ce4f9518ee88391..3527a05e5b338039d05730711577ace9f6886eef 100644 --- a/homeassistant/components/ps4/manifest.json +++ b/homeassistant/components/ps4/manifest.json @@ -3,6 +3,6 @@ "name": "Sony PlayStation 4", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/ps4", - "requirements": ["pyps4-2ndscreen==1.1.0"], + "requirements": ["pyps4-2ndscreen==1.1.1"], "codeowners": ["@ktnrg45"] } diff --git a/homeassistant/components/ps4/media_player.py b/homeassistant/components/ps4/media_player.py index 9bd4ddbefbe5274442684cded92f1633605c33a3..3ecd268f92bf15ba27629e7a9de1df80cf540791 100644 --- a/homeassistant/components/ps4/media_player.py +++ b/homeassistant/components/ps4/media_player.py @@ -453,6 +453,10 @@ class PS4Device(MediaPlayerEntity): """Turn on the media player.""" self._ps4.wakeup() + async def async_toggle(self): + """Toggle media player.""" + await self._ps4.toggle() + async def async_media_pause(self): """Send keypress ps to return to menu.""" await self.async_send_remote_control("ps") diff --git a/requirements_all.txt b/requirements_all.txt index f2e063c4ea8088e8d5673347d16a0b73b0d6d491..1fd0d49fcea0723f3dc71e95682e1d68a7914044 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1546,7 +1546,7 @@ pypjlink2==1.2.1 pypoint==1.1.2 # homeassistant.components.ps4 -pyps4-2ndscreen==1.1.0 +pyps4-2ndscreen==1.1.1 # homeassistant.components.qvr_pro pyqvrpro==0.52 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index ece27c3e2bc298d244c1577fcfcb555df4a8a2a2..9bb3527ac11e51cdcab7d93d6bb521493da418f0 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -708,7 +708,7 @@ pyotp==2.3.0 pypoint==1.1.2 # homeassistant.components.ps4 -pyps4-2ndscreen==1.1.0 +pyps4-2ndscreen==1.1.1 # homeassistant.components.qwikswitch pyqwikswitch==0.93 diff --git a/tests/components/ps4/test_media_player.py b/tests/components/ps4/test_media_player.py index 8ff8dea71ce20801e1877facceb57804eab2a5f5..4e22591d3b0ab5a00e50c2f74b810e9549984ed8 100644 --- a/tests/components/ps4/test_media_player.py +++ b/tests/components/ps4/test_media_player.py @@ -379,6 +379,22 @@ async def test_turn_off(hass): assert len(mock_call.mock_calls) == 1 +async def test_toggle(hass): + """Test that toggle service calls function.""" + mock_entity_id = await setup_mock_component(hass) + mock_func = "{}{}".format( + "homeassistant.components.ps4.media_player.", "pyps4.Ps4Async.toggle" + ) + + with patch(mock_func) as mock_call: + await hass.services.async_call( + "media_player", "toggle", {ATTR_ENTITY_ID: mock_entity_id} + ) + await hass.async_block_till_done() + + assert len(mock_call.mock_calls) == 1 + + async def test_media_pause(hass): """Test that media pause service calls function.""" mock_entity_id = await setup_mock_component(hass)