Skip to content

Commit

Permalink
Add availability to roku media player entities (home-assistant#32484)
Browse files Browse the repository at this point in the history
* track if roku is available based on update errors.

* Update media_player.py

* Update media_player.py
  • Loading branch information
ctalkington authored Mar 6, 2020
1 parent 5f6158f commit 3b75fdc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions homeassistant/components/roku/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(self, host):
self.ip_address = host
self.channels = []
self.current_app = None
self._available = False
self._device_info = {}
self._power_state = "Unknown"

Expand All @@ -74,7 +75,10 @@ def update(self):
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):
Expand Down Expand Up @@ -116,6 +120,11 @@ def supported_features(self):
"""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."""
Expand Down

0 comments on commit 3b75fdc

Please sign in to comment.