mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 22:07:10 +00:00
Improve roon volume translation logic (#84916)
Improve roon volume translation logic.
This commit is contained in:
parent
0ae55fb58b
commit
f79ffb2981
@ -3,7 +3,7 @@
|
|||||||
"name": "RoonLabs music player",
|
"name": "RoonLabs music player",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/roon",
|
"documentation": "https://www.home-assistant.io/integrations/roon",
|
||||||
"requirements": ["roonapi==0.1.2"],
|
"requirements": ["roonapi==0.1.3"],
|
||||||
"codeowners": ["@pavoni"],
|
"codeowners": ["@pavoni"],
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"loggers": ["roonapi"]
|
"loggers": ["roonapi"]
|
||||||
|
@ -180,13 +180,16 @@ class RoonDevice(MediaPlayerEntity):
|
|||||||
volume_data = player_data["volume"]
|
volume_data = player_data["volume"]
|
||||||
volume_muted = volume_data["is_muted"]
|
volume_muted = volume_data["is_muted"]
|
||||||
volume_step = convert(volume_data["step"], int, 0)
|
volume_step = convert(volume_data["step"], int, 0)
|
||||||
|
volume_max = volume_data["max"]
|
||||||
|
volume_min = volume_data["min"]
|
||||||
|
raw_level = convert(volume_data["value"], float, 0)
|
||||||
|
|
||||||
if volume_data["type"] == "db":
|
volume_range = volume_max - volume_min
|
||||||
level = convert(volume_data["value"], float, 0.0) / 80 * 100 + 100
|
volume_percentage_factor = volume_range / 100
|
||||||
else:
|
|
||||||
level = convert(volume_data["value"], float, 0.0)
|
|
||||||
|
|
||||||
|
level = (raw_level - volume_min) / volume_percentage_factor
|
||||||
volume_level = convert(level, int, 0) / 100
|
volume_level = convert(level, int, 0) / 100
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# catch KeyError
|
# catch KeyError
|
||||||
pass
|
pass
|
||||||
@ -329,7 +332,7 @@ class RoonDevice(MediaPlayerEntity):
|
|||||||
def set_volume_level(self, volume: float) -> None:
|
def set_volume_level(self, volume: float) -> None:
|
||||||
"""Send new volume_level to device."""
|
"""Send new volume_level to device."""
|
||||||
volume = int(volume * 100)
|
volume = int(volume * 100)
|
||||||
self._server.roonapi.change_volume(self.output_id, volume)
|
self._server.roonapi.set_volume_percent(self.output_id, volume)
|
||||||
|
|
||||||
def mute_volume(self, mute=True):
|
def mute_volume(self, mute=True):
|
||||||
"""Send mute/unmute to device."""
|
"""Send mute/unmute to device."""
|
||||||
@ -337,11 +340,11 @@ class RoonDevice(MediaPlayerEntity):
|
|||||||
|
|
||||||
def volume_up(self) -> None:
|
def volume_up(self) -> None:
|
||||||
"""Send new volume_level to device."""
|
"""Send new volume_level to device."""
|
||||||
self._server.roonapi.change_volume(self.output_id, 3, "relative")
|
self._server.roonapi.change_volume_percent(self.output_id, 3)
|
||||||
|
|
||||||
def volume_down(self) -> None:
|
def volume_down(self) -> None:
|
||||||
"""Send new volume_level to device."""
|
"""Send new volume_level to device."""
|
||||||
self._server.roonapi.change_volume(self.output_id, -3, "relative")
|
self._server.roonapi.change_volume_percent(self.output_id, -3)
|
||||||
|
|
||||||
def turn_on(self) -> None:
|
def turn_on(self) -> None:
|
||||||
"""Turn on device (if supported)."""
|
"""Turn on device (if supported)."""
|
||||||
|
@ -2220,7 +2220,7 @@ rokuecp==0.17.0
|
|||||||
roombapy==1.6.5
|
roombapy==1.6.5
|
||||||
|
|
||||||
# homeassistant.components.roon
|
# homeassistant.components.roon
|
||||||
roonapi==0.1.2
|
roonapi==0.1.3
|
||||||
|
|
||||||
# homeassistant.components.rova
|
# homeassistant.components.rova
|
||||||
rova==0.3.0
|
rova==0.3.0
|
||||||
|
@ -1547,7 +1547,7 @@ rokuecp==0.17.0
|
|||||||
roombapy==1.6.5
|
roombapy==1.6.5
|
||||||
|
|
||||||
# homeassistant.components.roon
|
# homeassistant.components.roon
|
||||||
roonapi==0.1.2
|
roonapi==0.1.3
|
||||||
|
|
||||||
# homeassistant.components.rpi_power
|
# homeassistant.components.rpi_power
|
||||||
rpi-bad-power==0.1.0
|
rpi-bad-power==0.1.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user