From 72308145d2164953182340e07348ceb52f8464c8 Mon Sep 17 00:00:00 2001 From: Henrik Widlund <4659350+henrikwidlund@users.noreply.github.com> Date: Sun, 22 Dec 2024 18:21:14 +0100 Subject: [PATCH] Fix incorrectly reported volume when using .5 as volume step Fixes the volume displayed on the remote so that it isn't constantly .5 too high --- intg-denonavr/avr.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/intg-denonavr/avr.py b/intg-denonavr/avr.py index 7123ae1..3cecb97 100644 --- a/intg-denonavr/avr.py +++ b/intg-denonavr/avr.py @@ -8,6 +8,7 @@ import asyncio import logging import time +import math from asyncio import AbstractEventLoop, Lock from enum import IntEnum from functools import wraps @@ -591,6 +592,12 @@ async def _telnet_callback(self, zone: str, event: str, parameter: str) -> None: level = self.volume_level if level is None: level = int(parameter) + + # remote only displays integers, round down to the nearest integer + # so that the remote doesn't round up to a higher integer + if self._volume_step == 0.5: + level = math.floor(level) + self.events.emit(Events.UPDATE, self.id, {MediaAttr.VOLUME: level}) elif event == "MU": # Muted self._set_expected_state(States.ON)