Optimize reading of Sonos source mode (#43541)

pull/43560/head
Anders Melchiorsen 2020-11-23 10:20:06 +01:00 committed by GitHub
parent 8ab15f6867
commit 47ff04d9ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 7 deletions

View File

@ -3,7 +3,7 @@
"name": "Sonos",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/sonos",
"requirements": ["pysonos==0.0.36"],
"requirements": ["pysonos==0.0.37"],
"ssdp": [
{
"st": "urn:schemas-upnp-org:device:ZonePlayer:1"

View File

@ -9,7 +9,13 @@ import urllib.parse
import async_timeout
import pysonos
from pysonos import alarms
from pysonos.core import PLAY_MODE_BY_MEANING, PLAY_MODES
from pysonos.core import (
PLAY_MODE_BY_MEANING,
PLAY_MODES,
PLAYING_LINE_IN,
PLAYING_RADIO,
PLAYING_TV,
)
from pysonos.exceptions import SoCoException, SoCoUPnPException
import pysonos.music_library
import pysonos.snapshot
@ -750,9 +756,12 @@ class SonosEntity(MediaPlayerEntity):
update_position = new_status != self._status
self._status = new_status
if self.soco.is_playing_tv:
track_uri = variables["current_track_uri"] if variables else None
whats_playing = self.soco.whats_playing(track_uri)
if whats_playing == PLAYING_TV:
self.update_media_linein(SOURCE_TV)
elif self.soco.is_playing_line_in:
elif whats_playing == PLAYING_LINE_IN:
self.update_media_linein(SOURCE_LINEIN)
else:
track_info = self.soco.get_current_track_info()
@ -764,7 +773,7 @@ class SonosEntity(MediaPlayerEntity):
self._media_album_name = track_info.get("album")
self._media_title = track_info.get("title")
if self.soco.is_radio_uri(track_info["uri"]):
if whats_playing == PLAYING_RADIO:
self.update_media_radio(variables, track_info)
else:
self.update_media_music(update_position, track_info)

View File

@ -1695,7 +1695,7 @@ pysnmp==4.4.12
pysoma==0.0.10
# homeassistant.components.sonos
pysonos==0.0.36
pysonos==0.0.37
# homeassistant.components.spc
pyspcwebgw==0.4.0

View File

@ -845,7 +845,7 @@ pysmartthings==0.7.6
pysoma==0.0.10
# homeassistant.components.sonos
pysonos==0.0.36
pysonos==0.0.37
# homeassistant.components.spc
pyspcwebgw==0.4.0