Skip to content

Commit 4cfeb14

Browse files
Remove rebase artifacts
1 parent 3b9ab34 commit 4cfeb14

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

streams/spotify_volume_handler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ class SpotifyWatcher(StreamWatcher):
2121
"""A class that watches and tracks changes to spotify-side volume"""
2222

2323
def __init__(self, api_port: int):
24-
self.api_port: int = api_port
2524
super().__init__()
25+
self.api_port: int = api_port
26+
"""What port is go-librespot running on? Typically set to 3678 + vsrc."""
2627

2728
async def watch_vol(self):
2829
"""Watch the go-librespot websocket endpoint for volume change events and update AmpliPi volume info accordingly"""
@@ -37,13 +38,13 @@ async def watch_vol(self):
3738
event = Event.from_json(json.loads(msg))
3839
if event.event_type == "volume":
3940
last_volume = float(self.volume) if self.volume is not None else None
40-
self.volume = event.data.value / 100 # AmpliPi volume is between 0 and 1, Spotify is between 0 and 100. Dividing by 100 is more accurate than multiplying by 100 due to floating point errors.
41+
self.volume = event.data.value / 100 # Translate spotify volume (0 - 100) to amplipi volume (0 - 1)
4142

4243
self.logger.debug(f"Spotify volume changed from {last_volume} to {self.volume}")
4344
if last_volume is not None and self.volume != last_volume:
44-
self.callback("stream_volume_changed")
45+
self.schedule_event(VolEvents.CHANGE_AMPLIPI)
4546
elif event.event_type == "will_play" and self.volume is None:
46-
self.callback("amplipi_volume_changed") # Intercept the event that occurs when a song starts playing and use that as a trigger for the initial state sync
47+
self.schedule_event(VolEvents.CHANGE_STREAM) # Intercept the event that occurs when a song starts playing and use that as a trigger for the initial state sync
4748

4849
except Exception as e:
4950
self.logger.exception(f"Error: {e}")
@@ -76,7 +77,6 @@ def set_vol(self, new_vol: float, vol_set_point: float) -> float:
7677
parser = argparse.ArgumentParser(description="Read metadata from a given URL and write it to a file.")
7778

7879
parser.add_argument("port", help="port that go-librespot is running on", type=int)
79-
parser.add_argument("stream_id", help="The stream's amplipi side stream_id", type=int)
8080
parser.add_argument("config_dir", help="The directory of the vsrc config", type=str)
8181
parser.add_argument("--debug", action="store_true", help="Change log level from WARNING to DEBUG")
8282

0 commit comments

Comments
 (0)