mirror of
https://github.com/home-assistant/core
synced 2024-07-18 12:02:20 +02:00
Add availability to roku media player entities (#32484)
* track if roku is available based on update errors. * Update media_player.py * Update media_player.py
This commit is contained in:
parent
5f6158f656
commit
3b75fdccfd
@ -59,6 +59,7 @@ class RokuDevice(MediaPlayerDevice):
|
||||
self.ip_address = host
|
||||
self.channels = []
|
||||
self.current_app = None
|
||||
self._available = False
|
||||
self._device_info = {}
|
||||
self._power_state = "Unknown"
|
||||
|
||||
@ -74,7 +75,10 @@ class RokuDevice(MediaPlayerDevice):
|
||||
self.current_app = self.roku.current_app
|
||||
else:
|
||||
self.current_app = None
|
||||
|
||||
self._available = True
|
||||
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout):
|
||||
self._available = False
|
||||
pass
|
||||
|
||||
def get_source_list(self):
|
||||
@ -116,6 +120,11 @@ class RokuDevice(MediaPlayerDevice):
|
||||
"""Flag media player features that are supported."""
|
||||
return SUPPORT_ROKU
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
"""Return if able to retrieve information from device or not."""
|
||||
return self._available
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return a unique, Home Assistant friendly identifier for this entity."""
|
||||
|
Loading…
Reference in New Issue
Block a user