From 239060591aeddde79f2b8058d7cf5622c7f28b34 Mon Sep 17 00:00:00 2001 From: Marcel Schreiner <40523792+marcelschreiner@users.noreply.github.com> Date: Sun, 11 Feb 2024 17:02:02 +0100 Subject: [PATCH] Create sonosmusic2lox.py --- sonosmusic2lox.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 sonosmusic2lox.py diff --git a/sonosmusic2lox.py b/sonosmusic2lox.py new file mode 100644 index 0000000..4177aad --- /dev/null +++ b/sonosmusic2lox.py @@ -0,0 +1,25 @@ +import time +from soco import discover +import requests + +while True: + for zone in discover(): + # Check if this zone is part of a group and not the coordinator + if zone.group.coordinator.player_name != zone.player_name: + # Get track info from the coordinator + track_info = zone.group.coordinator.get_current_track_info() + else: + # Get track info from this zone + track_info = zone.get_current_track_info() + + # Check if the track_info is not empty -> music is playing + if track_info["title"] != "": + music_info = f"{zone.volume}% | {track_info['title']} | {track_info['artist']}" + else: + music_info = f"{zone.volume}% | Idle" + + print(f"{zone.player_name}: {music_info}") + # Send the music info to the Loxone Miniserver + r = requests.get(f"http://USER:PASSWORT@IPADDRESS/dev/sps/io/Sonos {zone.player_name}/{music_info}") + + time.sleep(10)