From 2e8eaf40f728f9cbf75d3da5b2337da20a9099cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ron=20=C5=A0meral?= Date: Sat, 5 May 2018 17:06:32 +0200 Subject: [PATCH] Onkyo: SUPPORT_VOLUME_STEP (#14299) --- .../components/media_player/onkyo.py | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/media_player/onkyo.py b/homeassistant/components/media_player/onkyo.py index 245ab8bb54c..39c278ff95d 100644 --- a/homeassistant/components/media_player/onkyo.py +++ b/homeassistant/components/media_player/onkyo.py @@ -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: