Skip to content

Commit

Permalink
Fix roku play/pause support (#35991)
Browse files Browse the repository at this point in the history
  • Loading branch information
ctalkington authored and frenck committed May 24, 2020
1 parent fb3394f commit ab74153
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
10 changes: 10 additions & 0 deletions homeassistant/components/roku/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
MEDIA_TYPE_APP,
MEDIA_TYPE_CHANNEL,
SUPPORT_NEXT_TRACK,
SUPPORT_PAUSE,
SUPPORT_PLAY,
SUPPORT_PLAY_MEDIA,
SUPPORT_PREVIOUS_TRACK,
Expand All @@ -29,6 +30,7 @@
| SUPPORT_VOLUME_STEP
| SUPPORT_VOLUME_MUTE
| SUPPORT_SELECT_SOURCE
| SUPPORT_PAUSE
| SUPPORT_PLAY
| SUPPORT_PLAY_MEDIA
| SUPPORT_TURN_ON
Expand Down Expand Up @@ -167,6 +169,14 @@ async def async_turn_off(self) -> None:
"""Turn off the Roku."""
await self.coordinator.roku.remote("poweroff")

async def async_media_pause(self) -> None:
"""Send pause command."""
await self.coordinator.roku.remote("play")

async def async_media_play(self) -> None:
"""Send play command."""
await self.coordinator.roku.remote("play")

async def async_media_play_pause(self) -> None:
"""Send play/pause command."""
await self.coordinator.roku.remote("play")
Expand Down
25 changes: 25 additions & 0 deletions tests/components/roku/test_media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
SERVICE_PLAY_MEDIA,
SERVICE_SELECT_SOURCE,
SUPPORT_NEXT_TRACK,
SUPPORT_PAUSE,
SUPPORT_PLAY,
SUPPORT_PLAY_MEDIA,
SUPPORT_PREVIOUS_TRACK,
Expand All @@ -30,6 +31,8 @@
from homeassistant.const import (
ATTR_ENTITY_ID,
SERVICE_MEDIA_NEXT_TRACK,
SERVICE_MEDIA_PAUSE,
SERVICE_MEDIA_PLAY,
SERVICE_MEDIA_PLAY_PAUSE,
SERVICE_MEDIA_PREVIOUS_TRACK,
SERVICE_TURN_OFF,
Expand Down Expand Up @@ -142,6 +145,7 @@ async def test_supported_features(
| SUPPORT_VOLUME_STEP
| SUPPORT_VOLUME_MUTE
| SUPPORT_SELECT_SOURCE
| SUPPORT_PAUSE
| SUPPORT_PLAY
| SUPPORT_PLAY_MEDIA
| SUPPORT_TURN_ON
Expand Down Expand Up @@ -170,6 +174,7 @@ async def test_tv_supported_features(
| SUPPORT_VOLUME_STEP
| SUPPORT_VOLUME_MUTE
| SUPPORT_SELECT_SOURCE
| SUPPORT_PAUSE
| SUPPORT_PLAY
| SUPPORT_PLAY_MEDIA
| SUPPORT_TURN_ON
Expand Down Expand Up @@ -267,6 +272,26 @@ async def test_services(

remote_mock.assert_called_once_with("poweron")

with patch("homeassistant.components.roku.Roku.remote") as remote_mock:
await hass.services.async_call(
MP_DOMAIN,
SERVICE_MEDIA_PAUSE,
{ATTR_ENTITY_ID: MAIN_ENTITY_ID},
blocking=True,
)

remote_mock.assert_called_once_with("play")

with patch("homeassistant.components.roku.Roku.remote") as remote_mock:
await hass.services.async_call(
MP_DOMAIN,
SERVICE_MEDIA_PLAY,
{ATTR_ENTITY_ID: MAIN_ENTITY_ID},
blocking=True,
)

remote_mock.assert_called_once_with("play")

with patch("homeassistant.components.roku.Roku.remote") as remote_mock:
await hass.services.async_call(
MP_DOMAIN,
Expand Down

0 comments on commit ab74153

Please sign in to comment.