mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
Set unavailable when unreachable (#19012)
* Turn GPMDP Off When Unavailable * Update requirements_all.txt * Specified Exception Type * Update gpmdp.py
This commit is contained in:
parent
b97f0c0261
commit
f95bd9c78f
@ -20,7 +20,7 @@ from homeassistant.const import (
|
|||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.util.json import load_json, save_json
|
from homeassistant.util.json import load_json, save_json
|
||||||
|
|
||||||
REQUIREMENTS = ['websocket-client==0.37.0']
|
REQUIREMENTS = ['websocket-client==0.54.0']
|
||||||
|
|
||||||
_CONFIGURING = {}
|
_CONFIGURING = {}
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -155,6 +155,7 @@ class GPMDP(MediaPlayerDevice):
|
|||||||
self._duration = None
|
self._duration = None
|
||||||
self._volume = None
|
self._volume = None
|
||||||
self._request_id = 0
|
self._request_id = 0
|
||||||
|
self._available = True
|
||||||
|
|
||||||
def get_ws(self):
|
def get_ws(self):
|
||||||
"""Check if the websocket is setup and connected."""
|
"""Check if the websocket is setup and connected."""
|
||||||
@ -200,6 +201,8 @@ class GPMDP(MediaPlayerDevice):
|
|||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest details from the player."""
|
"""Get the latest details from the player."""
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
try:
|
||||||
|
self._available = True
|
||||||
playstate = self.send_gpmdp_msg('playback', 'getPlaybackState')
|
playstate = self.send_gpmdp_msg('playback', 'getPlaybackState')
|
||||||
if playstate is None:
|
if playstate is None:
|
||||||
return
|
return
|
||||||
@ -216,6 +219,13 @@ class GPMDP(MediaPlayerDevice):
|
|||||||
volume_data = self.send_gpmdp_msg('volume', 'getVolume')
|
volume_data = self.send_gpmdp_msg('volume', 'getVolume')
|
||||||
if volume_data is not None:
|
if volume_data is not None:
|
||||||
self._volume = volume_data['value'] / 100
|
self._volume = volume_data['value'] / 100
|
||||||
|
except OSError:
|
||||||
|
self._available = False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self):
|
||||||
|
"""Return if media player is available."""
|
||||||
|
return self._available
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_content_type(self):
|
def media_content_type(self):
|
||||||
|
@ -1627,7 +1627,7 @@ watchdog==0.8.3
|
|||||||
waterfurnace==1.0.0
|
waterfurnace==1.0.0
|
||||||
|
|
||||||
# homeassistant.components.media_player.gpmdp
|
# homeassistant.components.media_player.gpmdp
|
||||||
websocket-client==0.37.0
|
websocket-client==0.54.0
|
||||||
|
|
||||||
# homeassistant.components.media_player.webostv
|
# homeassistant.components.media_player.webostv
|
||||||
websockets==6.0
|
websockets==6.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user