Yamaha AVR Input Select (#1796)
* added select input for yamaha * set source_list to none on initpull/1824/head
parent
9d71a8c4b9
commit
f1d8667d7e
|
@ -61,6 +61,7 @@ ATTR_APP_ID = 'app_id'
|
|||
ATTR_APP_NAME = 'app_name'
|
||||
ATTR_SUPPORTED_MEDIA_COMMANDS = 'supported_media_commands'
|
||||
ATTR_INPUT_SOURCE = 'source'
|
||||
ATTR_INPUT_SOURCE_LIST = 'source_list'
|
||||
|
||||
MEDIA_TYPE_MUSIC = 'music'
|
||||
MEDIA_TYPE_TVSHOW = 'tvshow'
|
||||
|
@ -94,6 +95,7 @@ SERVICE_TO_METHOD = {
|
|||
SERVICE_MEDIA_PAUSE: 'media_pause',
|
||||
SERVICE_MEDIA_NEXT_TRACK: 'media_next_track',
|
||||
SERVICE_MEDIA_PREVIOUS_TRACK: 'media_previous_track',
|
||||
SERVICE_SELECT_SOURCE: 'select_source'
|
||||
}
|
||||
|
||||
ATTR_TO_PROPERTY = [
|
||||
|
@ -116,6 +118,7 @@ ATTR_TO_PROPERTY = [
|
|||
ATTR_APP_NAME,
|
||||
ATTR_SUPPORTED_MEDIA_COMMANDS,
|
||||
ATTR_INPUT_SOURCE,
|
||||
ATTR_INPUT_SOURCE_LIST,
|
||||
]
|
||||
|
||||
# Service call validation schemas
|
||||
|
@ -473,6 +476,11 @@ class MediaPlayerDevice(Entity):
|
|||
"""Name of the current input source."""
|
||||
return None
|
||||
|
||||
@property
|
||||
def source_list(self):
|
||||
"""List of available input sources."""
|
||||
return None
|
||||
|
||||
@property
|
||||
def supported_media_commands(self):
|
||||
"""Flag media commands that are supported."""
|
||||
|
|
|
@ -8,13 +8,15 @@ import logging
|
|||
|
||||
from homeassistant.components.media_player import (
|
||||
SUPPORT_TURN_OFF, SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET,
|
||||
MediaPlayerDevice)
|
||||
SUPPORT_SELECT_SOURCE, MediaPlayerDevice)
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
|
||||
REQUIREMENTS = ['rxv==0.1.11']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SUPPORT_YAMAHA = SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
|
||||
SUPPORT_TURN_ON | SUPPORT_TURN_OFF
|
||||
SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_SELECT_SOURCE
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
@ -34,6 +36,8 @@ class YamahaDevice(MediaPlayerDevice):
|
|||
self._muted = False
|
||||
self._volume = 0
|
||||
self._pwstate = STATE_OFF
|
||||
self._current_source = None
|
||||
self._source_list = None
|
||||
self.update()
|
||||
self._name = name
|
||||
|
||||
|
@ -45,6 +49,8 @@ class YamahaDevice(MediaPlayerDevice):
|
|||
self._pwstate = STATE_OFF
|
||||
self._muted = self._receiver.mute
|
||||
self._volume = (self._receiver.volume/100) + 1
|
||||
self._current_source = self._receiver.input
|
||||
self._source_list = list(self._receiver.inputs().keys())
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
@ -66,6 +72,16 @@ class YamahaDevice(MediaPlayerDevice):
|
|||
"""Boolean if volume is currently muted."""
|
||||
return self._muted
|
||||
|
||||
@property
|
||||
def source(self):
|
||||
"""Return the current input source."""
|
||||
return self._current_source
|
||||
|
||||
@property
|
||||
def source_list(self):
|
||||
"""List of available input sources."""
|
||||
return self._source_list
|
||||
|
||||
@property
|
||||
def supported_media_commands(self):
|
||||
"""Flag of media commands that are supported."""
|
||||
|
@ -89,3 +105,7 @@ class YamahaDevice(MediaPlayerDevice):
|
|||
"""Turn the media player on."""
|
||||
self._receiver.on = True
|
||||
self._volume = (self._receiver.volume/100) + 1
|
||||
|
||||
def select_source(self, source):
|
||||
"""Select input source."""
|
||||
self._receiver.input = source
|
||||
|
|
Loading…
Reference in New Issue