mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
Add available to sonos (#9243)
* Readd sonos available flag / fix polling state * cleanup
This commit is contained in:
parent
836b528bd3
commit
0af4f8903d
@ -322,6 +322,7 @@ class SonosDevice(MediaPlayerDevice):
|
|||||||
self._media_title = None
|
self._media_title = None
|
||||||
self._media_radio_show = None
|
self._media_radio_show = None
|
||||||
self._media_next_title = None
|
self._media_next_title = None
|
||||||
|
self._available = True
|
||||||
self._support_previous_track = False
|
self._support_previous_track = False
|
||||||
self._support_next_track = False
|
self._support_next_track = False
|
||||||
self._support_play = False
|
self._support_play = False
|
||||||
@ -386,6 +387,11 @@ class SonosDevice(MediaPlayerDevice):
|
|||||||
"""Return coordinator of this player."""
|
"""Return coordinator of this player."""
|
||||||
return self._coordinator
|
return self._coordinator
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self) -> bool:
|
||||||
|
"""Return True if entity is available."""
|
||||||
|
return self._available
|
||||||
|
|
||||||
def _is_available(self):
|
def _is_available(self):
|
||||||
try:
|
try:
|
||||||
sock = socket.create_connection(
|
sock = socket.create_connection(
|
||||||
@ -416,11 +422,11 @@ class SonosDevice(MediaPlayerDevice):
|
|||||||
self._player.get_sonos_favorites()['favorites']
|
self._player.get_sonos_favorites()['favorites']
|
||||||
|
|
||||||
if self._last_avtransport_event:
|
if self._last_avtransport_event:
|
||||||
is_available = True
|
self._available = True
|
||||||
else:
|
else:
|
||||||
is_available = self._is_available()
|
self._available = self._is_available()
|
||||||
|
|
||||||
if not is_available:
|
if not self._available:
|
||||||
self._player_volume = None
|
self._player_volume = None
|
||||||
self._player_volume_muted = None
|
self._player_volume_muted = None
|
||||||
self._status = 'OFF'
|
self._status = 'OFF'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user