Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions jackcast/speakers/sonos.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,17 @@ def __init__(self, server_port=80):
self.coordinator = None

# Init an active speaker
devices = soco.discover()
devices = []
discovered_devices = soco.discover()
if discovered_devices is not None:
devices.extend(discovered_devices)

for device in devices:
info = device.get_current_transport_info()
# TODO (wfk) check if there are more than one then find the
# coordinator
if info['current_transport_state'] == 'PLAYING':
self.coordinator = device
info = device.get_current_transport_info()
# TODO (wfk) check if there are more than one then find the
# coordinator
if info['current_transport_state'] == 'PLAYING':
self.coordinator = device

def get_ip_addr(self):
# TODO (wfk) do the devices use mDNS? If so we can just use our hostname.
Expand All @@ -95,16 +99,22 @@ def speakers(self):
connection"""

speakers = []
for device in soco.discover():
info = device.get_current_transport_info()
if info['current_transport_state'] == 'PLAYING':
status = Speaker.STATUS_PLAYING
else:
status = Speaker.STATUS_STOPPED
speaker = Speaker(device.player_name, device.volume, status)
speakers.append(speaker)

self._log_device(device)
# Init an active speaker
devices = []
discovered_devices = soco.discover()
if discovered_devices is not None:
devices.extend(discovered_devices)

for device in devices:
info = device.get_current_transport_info()
if info['current_transport_state'] == 'PLAYING':
status = Speaker.STATUS_PLAYING
else:
status = Speaker.STATUS_STOPPED
speaker = Speaker(device.player_name, device.volume, status)
speakers.append(speaker)

self._log_device(device)

return speakers

Expand Down