diff --git a/bluetooth.png b/bluetooth.png new file mode 100644 index 0000000..8db6666 Binary files /dev/null and b/bluetooth.png differ diff --git a/go_sonos_highres.py b/go_sonos_highres.py index c498731..912211f 100644 --- a/go_sonos_highres.py +++ b/go_sonos_highres.py @@ -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: @@ -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) @@ -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: diff --git a/sonos_settings.py.example b/sonos_settings.py.example index 28c61f8..8371880 100644 --- a/sonos_settings.py.example +++ b/sonos_settings.py.example @@ -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 diff --git a/sonos_user_data.py b/sonos_user_data.py index b438206..2a865df 100644 --- a/sonos_user_data.py +++ b/sonos_user_data.py @@ -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