mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Add stepped volume to demo (#23759)
* Add stepped volume to demo * Simplify somewhat to avoid extra check
This commit is contained in:
parent
45adb5c9c7
commit
c7a78ed522
@ -5,7 +5,8 @@ from homeassistant.components.media_player.const import (
|
||||
SUPPORT_CLEAR_PLAYLIST, SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PLAY,
|
||||
SUPPORT_PLAY_MEDIA, SUPPORT_PREVIOUS_TRACK, SUPPORT_SEEK,
|
||||
SUPPORT_SELECT_SOUND_MODE, SUPPORT_SELECT_SOURCE, SUPPORT_SHUFFLE_SET,
|
||||
SUPPORT_TURN_OFF, SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET)
|
||||
SUPPORT_TURN_OFF, SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET,
|
||||
SUPPORT_VOLUME_STEP)
|
||||
from homeassistant.const import STATE_OFF, STATE_PAUSED, STATE_PLAYING
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
@ -35,7 +36,7 @@ YOUTUBE_PLAYER_SUPPORT = \
|
||||
MUSIC_PLAYER_SUPPORT = \
|
||||
SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
|
||||
SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_CLEAR_PLAYLIST | \
|
||||
SUPPORT_PLAY | SUPPORT_SHUFFLE_SET | \
|
||||
SUPPORT_PLAY | SUPPORT_SHUFFLE_SET | SUPPORT_VOLUME_STEP | \
|
||||
SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK | \
|
||||
SUPPORT_SELECT_SOUND_MODE
|
||||
|
||||
@ -122,6 +123,16 @@ class AbstractDemoPlayer(MediaPlayerDevice):
|
||||
self._volume_muted = mute
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def volume_up(self):
|
||||
"""Increase volume."""
|
||||
self._volume_level = min(1.0, self._volume_level + 0.1)
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def volume_down(self):
|
||||
"""Decrease volume."""
|
||||
self._volume_level = max(0.0, self._volume_level - 0.1)
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def set_volume_level(self, volume):
|
||||
"""Set the volume level, range 0..1."""
|
||||
self._volume_level = volume
|
||||
|
Loading…
x
Reference in New Issue
Block a user