Skip to content

Commit

Permalink
fix: add source callback hdlr
Browse files Browse the repository at this point in the history
  • Loading branch information
noahhusby committed Aug 4, 2024
1 parent 4f4e1ec commit 6f7c99c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion aiorussound/rio.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(self, loop: AbstractEventLoop, host: str, port=DEFAULT_PORT):
self._callbacks = {}
self._connection_started = False
self._watched_devices = {}
self._controllers = {}
self.rio_version = None

def _retrieve_cached_variable(self, device_str: str, key: str):
Expand Down Expand Up @@ -63,6 +64,14 @@ def _store_cached_variable(self, device_str: str, key: str, value: str):
# Handle callbacks
for callback in self._callbacks.get(device_str, []):
callback(device_str, key, value)
# Handle source callback
if device_str[0] is 'S':
for controller in self._controllers.values():
for zone in controller.zones.values():
source = zone.fetch_current_source()
if source and source.device_str() is device_str:
for callback in self._callbacks.get(zone.device_str(), []):
callback(device_str, key, value)

def _process_response(self, res: bytes):
s = str(res, "utf-8").strip()
Expand Down Expand Up @@ -254,7 +263,7 @@ async def enumerate_controllers(self):
controllers[controller_id] = controller
except CommandException:
continue

self._controllers = controllers
return controllers

@property
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='aiorussound',
version='2.2.0',
version='2.2.1',
packages=['aiorussound'],
license='MIT',
author='Noah Husby',
Expand Down

0 comments on commit 6f7c99c

Please sign in to comment.