Skip to content

Commit

Permalink
Fix incorrectly reported volume when using .5 as volume step
Browse files Browse the repository at this point in the history
Fixes the volume displayed on the remote so that it isn't constantly .5 too high
  • Loading branch information
henrikwidlund committed Dec 22, 2024
1 parent ad08e61 commit 8be812d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions intg-denonavr/avr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -591,6 +592,14 @@ 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, subtract .5 if volume step is 0.5 so that the displayed volume
# remains within the same integer when pressing once
# 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)
Expand Down

0 comments on commit 8be812d

Please sign in to comment.