Onkyo: SUPPORT_VOLUME_STEP (#14299)

pull/14279/merge
Ron Šmeral 2018-05-05 17:06:32 +02:00 committed by Sebastian Muszynski
parent b9e893184a
commit 2e8eaf40f7
1 changed files with 20 additions and 2 deletions

View File

@ -13,7 +13,8 @@ import voluptuous as vol
from homeassistant.components.media_player import (
SUPPORT_TURN_OFF, SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET,
SUPPORT_SELECT_SOURCE, SUPPORT_PLAY, MediaPlayerDevice, PLATFORM_SCHEMA)
SUPPORT_VOLUME_STEP, SUPPORT_SELECT_SOURCE, SUPPORT_PLAY,
MediaPlayerDevice, PLATFORM_SCHEMA)
from homeassistant.const import (STATE_OFF, STATE_ON, CONF_HOST, CONF_NAME)
import homeassistant.helpers.config_validation as cv
@ -29,7 +30,8 @@ DEFAULT_NAME = 'Onkyo Receiver'
SUPPORTED_MAX_VOLUME = 80
SUPPORT_ONKYO = SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_SELECT_SOURCE | SUPPORT_PLAY
SUPPORT_VOLUME_STEP | SUPPORT_TURN_ON | SUPPORT_TURN_OFF | \
SUPPORT_SELECT_SOURCE | SUPPORT_PLAY
KNOWN_HOSTS = [] # type: List[str]
DEFAULT_SOURCES = {'tv': 'TV', 'bd': 'Bluray', 'game': 'Game', 'aux1': 'Aux1',
@ -199,6 +201,14 @@ class OnkyoDevice(MediaPlayerDevice):
"""
self.command('volume {}'.format(int(volume * self._max_volume)))
def volume_up(self):
"""Increase volume by 1 step."""
self.command('volume level-up')
def volume_down(self):
"""Decrease volume by 1 step."""
self.command('volume level-down')
def mute_volume(self, mute):
"""Mute (true) or unmute (false) media player."""
if mute:
@ -264,6 +274,14 @@ class OnkyoDeviceZone2(OnkyoDevice):
"""Set volume level, input is range 0..1. Onkyo ranges from 1-80."""
self.command('zone2.volume={}'.format(int(volume*80)))
def volume_up(self):
"""Increase volume by 1 step."""
self.command('zone2.volume=level-up')
def volume_down(self):
"""Decrease volume by 1 step."""
self.command('zone2.volume=level-down')
def mute_volume(self, mute):
"""Mute (true) or unmute (false) media player."""
if mute: