Avoid useless Sonos state updates (#24135)

pull/24059/head^2
Anders Melchiorsen 2019-05-26 21:49:26 +02:00 committed by Paulus Schoutsen
parent 179fb0f3b5
commit 97b671171b
1 changed files with 6 additions and 4 deletions

View File

@ -433,6 +433,9 @@ class SonosEntity(MediaPlayerDevice):
self._shuffle = self.soco.shuffle
update_position = (new_status != self._status)
self._status = new_status
if self.soco.is_playing_tv:
self.update_media_linein(SOURCE_TV)
elif self.soco.is_playing_line_in:
@ -444,11 +447,8 @@ class SonosEntity(MediaPlayerDevice):
variables = event and event.variables
self.update_media_radio(variables, track_info)
else:
update_position = (new_status != self._status)
self.update_media_music(update_position, track_info)
self._status = new_status
self.schedule_update_ha_state()
# Also update slaves
@ -550,7 +550,9 @@ class SonosEntity(MediaPlayerDevice):
self._media_position is None
# position jumped?
if rel_time is not None and self._media_position is not None:
if (self.state == STATE_PLAYING
and rel_time is not None
and self._media_position is not None):
time_diff = utcnow() - self._media_position_updated_at
time_diff = time_diff.total_seconds()