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

KeyError when meta stream gets property update #74

Open
mill1000 opened this issue Oct 10, 2024 · 0 comments
Open

KeyError when meta stream gets property update #74

mill1000 opened this issue Oct 10, 2024 · 0 comments

Comments

@mill1000
Copy link
Contributor

mill1000 commented Oct 10, 2024

In my Snapcast setup I have multiple input-only streams that get grouped within a meta stream. This meta stream also get grouped into another meta stream.

Some of the input-only streams have a control script to provide stream properties & metadata. When a properties update is received a KeyError is thrown from _on_stream_properties.

Here's a simplified setup

# Input only streams
source = pipe:///streams/gmrender-resurrect-all-rooms?name=upnp-all-rooms&codec=null&controlscript=/usr/local/bin/snapcast-upnp
source = airplay:////usr/local/bin/shairport-sync?name=airplay-all-rooms&devicename=Snapcast - All Rooms&port=5000&codec=null
source = librespot:///bin/librespot?name=spotify-all-rooms&devicename=Snapcast - All Rooms&codec=null

# Input only meta source for all rooms
source = meta:///upnp-all-rooms/airplay-all-rooms/spotify-all-rooms?name=all-rooms&codec=null

# Meta sources for individual rooms
source = meta:///upnp-bedroom/airplay-bedroom/spotify-bedroom/all-rooms?name=Bedroom
source = meta:///upnp-living-room/airplay-living-room/spotify-living-room/all-rooms?name=Living Room

Pretty much it's Input-only stream w/ script -> Input-only meta stream -> Meta stream

And here's the error

ERROR: Fatal error: protocol.data_received() call failed.
protocol: <snapcast.control.protocol.SnapcastProtocol object at 0x7f57e6fa0e50>
transport: <_SelectorSocketTransport fd=6 read=polling write=<idle, bufsize=0>>
Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 1009, in _read_ready__data_received
    self._protocol.data_received(data)
  File "/home/wyse/.local/lib/python3.11/site-packages/snapcast/control/protocol.py", line 54, in data_received
    self.handle_data(item)
  File "/home/wyse/.local/lib/python3.11/site-packages/snapcast/control/protocol.py", line 61, in handle_data
    self.handle_notification(data)
  File "/home/wyse/.local/lib/python3.11/site-packages/snapcast/control/protocol.py", line 73, in handle_notification
    self._callbacks.get(data.get('method'))(data.get('params'))
  File "/home/wyse/.local/lib/python3.11/site-packages/snapcast/control/server.py", line 420, in _on_stream_properties
    stream = self._streams[data.get('id')]
             ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'all-rooms'

I dumped the contents of self._streams and the incoming data. It appears Snapcast is generating a properties update for the 2nd meta stream which the library is not tracking.

Contents of self._streams

{'Bedroom': Snapstream (Bedroom), 'Living Room': Snapstream (Living Room)}

Incoming data

{'id': 'all-rooms', 'properties': {'canControl': False, 'canGoNext': False, 'canGoPrevious': False, 'canPause': False, 'canPlay': False, 'canSeek': False, 'loopStatus': 'none', 'mute': False, 'playbackStatus': 'playing', 'position': 0.0, 'rate': 1.0, 'shuffle': False, 'volume': 100}}

I don't know if Snapcast shouldn't be generating the update for this meta stream, but at least this library can add a check for the ID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant