mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 06:17:07 +00:00
Set volume_step in monoprice media_player (#105670)
This commit is contained in:
parent
4da04a358a
commit
cffb51ebec
@ -127,6 +127,7 @@ class MonopriceZone(MediaPlayerEntity):
|
|||||||
)
|
)
|
||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
|
_attr_volume_step = 1 / MAX_VOLUME
|
||||||
|
|
||||||
def __init__(self, monoprice, sources, namespace, zone_id):
|
def __init__(self, monoprice, sources, namespace, zone_id):
|
||||||
"""Initialize new zone."""
|
"""Initialize new zone."""
|
||||||
@ -210,17 +211,3 @@ class MonopriceZone(MediaPlayerEntity):
|
|||||||
def set_volume_level(self, volume: float) -> None:
|
def set_volume_level(self, volume: float) -> None:
|
||||||
"""Set volume level, range 0..1."""
|
"""Set volume level, range 0..1."""
|
||||||
self._monoprice.set_volume(self._zone_id, round(volume * MAX_VOLUME))
|
self._monoprice.set_volume(self._zone_id, round(volume * MAX_VOLUME))
|
||||||
|
|
||||||
def volume_up(self) -> None:
|
|
||||||
"""Volume up the media player."""
|
|
||||||
if self.volume_level is None:
|
|
||||||
return
|
|
||||||
volume = round(self.volume_level * MAX_VOLUME)
|
|
||||||
self._monoprice.set_volume(self._zone_id, min(volume + 1, MAX_VOLUME))
|
|
||||||
|
|
||||||
def volume_down(self) -> None:
|
|
||||||
"""Volume down media player."""
|
|
||||||
if self.volume_level is None:
|
|
||||||
return
|
|
||||||
volume = round(self.volume_level * MAX_VOLUME)
|
|
||||||
self._monoprice.set_volume(self._zone_id, max(volume - 1, 0))
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user