Skip to content

Commit

Permalink
Added fast forward and rewind support to the Alexa cloud/smart home c…
Browse files Browse the repository at this point in the history
…omponent. It simply invokes the next and previous track functions.
  • Loading branch information
iliketoprogram14 committed Jul 9, 2018
1 parent 02238b6 commit ce080bc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
18 changes: 18 additions & 0 deletions homeassistant/components/alexa/smart_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,24 @@ def async_api_previous(hass, config, request, entity):
return api_message(request)


@HANDLERS.register(('Alexa.PlaybackController', 'FastForward'))
@extract_entity
@asyncio.coroutine
def async_api_fastforward(hass, config, request, entity):
"""Process a fast forward request."""
# pylint: disable=no-value-for-parameter
return (yield from async_api_next(hass, config, request))


@HANDLERS.register(('Alexa.PlaybackController', 'Rewind'))
@extract_entity
@asyncio.coroutine
def async_api_rewind(hass, config, request, entity):
"""Process a rewind request."""
# pylint: disable=no-value-for-parameter
return (yield from async_api_previous(hass, config, request))


def api_error_temp_range(request, temp, min_temp, max_temp, unit):
"""Create temperature value out of range API error response.
Expand Down
10 changes: 10 additions & 0 deletions tests/components/alexa/test_smart_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,16 @@ def test_media_player(hass):
'media_player.media_previous_track',
hass)

yield from assert_request_calls_service(
'Alexa.PlaybackController', 'FastForward', 'media_player#test',
'media_player.media_next_track',
hass)

yield from assert_request_calls_service(
'Alexa.PlaybackController', 'Rewind', 'media_player#test',
'media_player.media_previous_track',
hass)

call, _ = yield from assert_request_calls_service(
'Alexa.Speaker', 'SetVolume', 'media_player#test',
'media_player.volume_set',
Expand Down

0 comments on commit ce080bc

Please sign in to comment.