Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect Bluetooth sources #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Binary file added bluetooth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion go_sonos_highres.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def should_sleep():
return getattr(sonos_settings, "sleep_on_linein", False)
if sonos_data.type == "TV":
return getattr(sonos_settings, "sleep_on_tv", False)
if sonos_data.type == "Bluetooth":
return getattr(sonos_settings, "sleep_on_bluetooth", False)

if should_sleep():
if display.is_showing:
Expand All @@ -109,7 +111,7 @@ def should_sleep():
display.show_album()

# slim down the album and track names
if sonos_settings.demaster and sonos_data.type not in ["line_in", "TV"]:
if sonos_settings.demaster and sonos_data.type not in ("line_in", "TV", "Bluetooth"):
offline = not getattr(
sonos_settings, "demaster_query_cloud", False)
sonos_data.trackname = await async_demaster.strip_name(sonos_data.trackname, session, offline)
Expand Down Expand Up @@ -197,6 +199,8 @@ def should_sleep():
pil_image = Image.open(sys.path[0] + "/line_in.png")
elif sonos_data.type == "TV":
pil_image = Image.open(sys.path[0] + "/tv.png")
elif sonos_data.type == "Bluetooth":
pil_image = Image.open(sys.path[0] + "/bluetooth.png")

if pil_image is None:
if show_spotify_code or show_spotify_albumart:
Expand Down
3 changes: 3 additions & 0 deletions sonos_settings.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ sleep_on_tv = False
# Turn off display (and backlight) when Sonos is playing from a Line-In source
sleep_on_linein = False

# Turn off display (and backlight) when Sonos is playing from a Bluetooth source
sleep_on_bluetooth = False


## e-ink only settings

Expand Down
7 changes: 5 additions & 2 deletions sonos_user_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,14 @@ async def refresh(self, payload=None):
self.type = obj['currentTrack']['type']
self.duration = obj['currentTrack']['duration']

if self.type == "line_in":
if "bluetooth:" in obj["currentTrack"]["uri"]:
self.type = track_id = "Bluetooth"

if self.type in ("line_in", "Bluetooth"):
uri = obj['currentTrack']['uri']
if uri.startswith('x-sonos-htastream:'):
self.type = track_id = "TV"
else:
elif self.type != "Bluetooth":
track_id = "Line-In"
self.image_uri = None
self.trackname = track_id
Expand Down