Skip to content

Commit

Permalink
Create sonosmusic2lox.py
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelschreiner authored Feb 11, 2024
1 parent b34fbda commit 2390605
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions sonosmusic2lox.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 2390605

Please sign in to comment.