Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose mute and volume status and fix volume status parsing #76

Merged
merged 3 commits into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions pycec/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,16 @@ def __init__(self, logical_address: int, network=None,
self._menu_language = str()
self._osd_name = str()
self._audio_mode_status = int()
self._volume_status = int()
self._mute_status = False
self._deck_status = int()
self._tuner_status = int()
self._menu_status = int()
self._record_status = int()
self._timer_cleared_status = int()
self._timer_status = int()
self._network = network
self._updates = dict()
self._updates = {cmd: False for cmd in UPDATEABLE}
self._stop = False
self._update_period = update_period
self._type = int()
Expand Down Expand Up @@ -197,6 +199,14 @@ def type_name(self):
DEVICE_TYPE_NAMES[self.type] if self.type in range(6) else
DEVICE_TYPE_NAMES[2])

@property
def mute_status(self) -> bool:
return self._mute_status

@property
def volume_status(self) -> int:
return self._volume_status

def update_callback(self, command: CecCommand):
result = False
for prop in filter(lambda x: x[1] == command.cmd, UPDATEABLE):
Expand Down Expand Up @@ -227,8 +237,13 @@ def _update_physical_address(self, command):

def _update_audio_status(self, command):
self._mute_status = bool(command.att[0] & 0x80)
self._mute_value = command.att[0] & 0x7f
pass
raw_volume_status = command.att[0] & 0x7f
if raw_volume_status == 0x7f:
# Volume is unknown
self._updates[CMD_AUDIO_STATUS[0]] = False
else:
# Valid volumes cover a range of 0-100, just clamp invalid values
self._volume_status = min(raw_volume_status, 100)

@property
def task(self):
Expand Down
Loading