Change channel with play_media instead of select_source (#18474)
* Use service play_media instead of select_source Use service play_media instead of select_source to change the channel as play_media is the right service for that. * Log error on invalid media type Log an error instead of raising a NotImplementedError if an invalid media type is provided. * Changed so that success is not in else statement Updated so that if media_type is channel that it is not in the else of an if. * Update directv.py Removed SELECT_SOURCE as supported feature. * Rebased Re-based with dev
This commit is contained in:
parent
d9c7f777c5
commit
377730a37c
1 changed files with 15 additions and 10 deletions
|
@ -9,9 +9,9 @@ import requests
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import (
|
||||
MEDIA_TYPE_MOVIE, MEDIA_TYPE_TVSHOW, PLATFORM_SCHEMA, SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE, SUPPORT_PLAY, SUPPORT_PLAY_MEDIA, SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_SELECT_SOURCE, SUPPORT_STOP, SUPPORT_TURN_OFF, SUPPORT_TURN_ON,
|
||||
MEDIA_TYPE_CHANNEL, MEDIA_TYPE_MOVIE, MEDIA_TYPE_TVSHOW, PLATFORM_SCHEMA,
|
||||
SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PLAY, SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PREVIOUS_TRACK, SUPPORT_STOP, SUPPORT_TURN_OFF, SUPPORT_TURN_ON,
|
||||
MediaPlayerDevice)
|
||||
from homeassistant.const import (
|
||||
CONF_DEVICE, CONF_HOST, CONF_NAME, CONF_PORT, STATE_OFF, STATE_PAUSED,
|
||||
|
@ -33,12 +33,12 @@ DEFAULT_NAME = "DirecTV Receiver"
|
|||
DEFAULT_PORT = 8080
|
||||
|
||||
SUPPORT_DTV = SUPPORT_PAUSE | SUPPORT_TURN_ON | SUPPORT_TURN_OFF | \
|
||||
SUPPORT_PLAY_MEDIA | SUPPORT_SELECT_SOURCE | SUPPORT_STOP | \
|
||||
SUPPORT_NEXT_TRACK | SUPPORT_PREVIOUS_TRACK | SUPPORT_PLAY
|
||||
SUPPORT_PLAY_MEDIA | SUPPORT_STOP | SUPPORT_NEXT_TRACK | \
|
||||
SUPPORT_PREVIOUS_TRACK | SUPPORT_PLAY
|
||||
|
||||
SUPPORT_DTV_CLIENT = SUPPORT_PAUSE | \
|
||||
SUPPORT_PLAY_MEDIA | SUPPORT_SELECT_SOURCE | SUPPORT_STOP | \
|
||||
SUPPORT_NEXT_TRACK | SUPPORT_PREVIOUS_TRACK | SUPPORT_PLAY
|
||||
SUPPORT_PLAY_MEDIA | SUPPORT_STOP | SUPPORT_NEXT_TRACK | \
|
||||
SUPPORT_PREVIOUS_TRACK | SUPPORT_PLAY
|
||||
|
||||
DATA_DIRECTV = 'data_directv'
|
||||
|
||||
|
@ -375,7 +375,12 @@ class DirecTvDevice(MediaPlayerDevice):
|
|||
_LOGGER.debug("Fast forward on %s", self._name)
|
||||
self.dtv.key_press('ffwd')
|
||||
|
||||
def select_source(self, source):
|
||||
def play_media(self, media_type, media_id, **kwargs):
|
||||
"""Select input source."""
|
||||
_LOGGER.debug("Changing channel on %s to %s", self._name, source)
|
||||
self.dtv.tune_channel(source)
|
||||
if media_type != MEDIA_TYPE_CHANNEL:
|
||||
_LOGGER.error("Invalid media type %s. Only %s is supported",
|
||||
media_type, MEDIA_TYPE_CHANNEL)
|
||||
return
|
||||
|
||||
_LOGGER.debug("Changing channel on %s to %s", self._name, media_id)
|
||||
self.dtv.tune_channel(media_id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue