Add play, pause, previous and next track to kef (#31373)

* KEF: add support for play, pause, next track, and previous track

* bump aiokef to 0.2.7

* run isort

* do not dynamically change the supported features
This commit is contained in:
Bas Nijholt 2020-02-01 17:38:36 +01:00 committed by GitHub
parent c67f53dc43
commit 3275987f17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 2 deletions

View File

@ -4,5 +4,5 @@
"documentation": "https://www.home-assistant.io/integrations/kef", "documentation": "https://www.home-assistant.io/integrations/kef",
"dependencies": [], "dependencies": [],
"codeowners": ["@basnijholt"], "codeowners": ["@basnijholt"],
"requirements": ["aiokef==0.2.6", "getmac==0.8.1"] "requirements": ["aiokef==0.2.7", "getmac==0.8.1"]
} }

View File

@ -11,6 +11,10 @@ import voluptuous as vol
from homeassistant.components.media_player import ( from homeassistant.components.media_player import (
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_NEXT_TRACK,
SUPPORT_PAUSE,
SUPPORT_PLAY,
SUPPORT_PREVIOUS_TRACK,
SUPPORT_SELECT_SOURCE, SUPPORT_SELECT_SOURCE,
SUPPORT_TURN_OFF, SUPPORT_TURN_OFF,
SUPPORT_TURN_ON, SUPPORT_TURN_ON,
@ -214,6 +218,10 @@ class KefMediaPlayer(MediaPlayerDevice):
| SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_MUTE
| SUPPORT_SELECT_SOURCE | SUPPORT_SELECT_SOURCE
| SUPPORT_TURN_OFF | SUPPORT_TURN_OFF
| SUPPORT_NEXT_TRACK # only in Bluetooth and Wifi
| SUPPORT_PAUSE # only in Bluetooth and Wifi
| SUPPORT_PLAY # only in Bluetooth and Wifi
| SUPPORT_PREVIOUS_TRACK # only in Bluetooth and Wifi
) )
if self._supports_on: if self._supports_on:
support_kef |= SUPPORT_TURN_ON support_kef |= SUPPORT_TURN_ON
@ -280,3 +288,19 @@ class KefMediaPlayer(MediaPlayerDevice):
await self._speaker.set_source(source) await self._speaker.set_source(source)
else: else:
raise ValueError(f"Unknown input source: {source}.") raise ValueError(f"Unknown input source: {source}.")
async def async_media_play(self):
"""Send play command."""
await self._speaker.play_pause()
async def async_media_pause(self):
"""Send pause command."""
await self._speaker.play_pause()
async def async_media_previous_track(self):
"""Send previous track command."""
await self._speaker.prev_track()
async def async_media_next_track(self):
"""Send next track command."""
await self._speaker.next_track()

View File

@ -172,7 +172,7 @@ aioimaplib==0.7.15
aiokafka==0.5.1 aiokafka==0.5.1
# homeassistant.components.kef # homeassistant.components.kef
aiokef==0.2.6 aiokef==0.2.7
# homeassistant.components.lifx # homeassistant.components.lifx
aiolifx==0.6.7 aiolifx==0.6.7