1
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:
Chris Talkington 2020-03-06 06:55:32 -06:00 committed by GitHub
parent 5f6158f656
commit 3b75fdccfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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."""