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