-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b34fbda
commit 2390605
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |