mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Reset states when connection to MPC-HC is lost (#27541)
* Reset states when connection to MPC-HC is lost * Add the available property of mpchc
This commit is contained in:
parent
ac4d8ee07f
commit
2e1d05560f
@ -69,6 +69,7 @@ class MpcHcDevice(MediaPlayerDevice):
|
|||||||
self._name = name
|
self._name = name
|
||||||
self._url = url
|
self._url = url
|
||||||
self._player_variables = dict()
|
self._player_variables = dict()
|
||||||
|
self._available = False
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest details."""
|
"""Get the latest details."""
|
||||||
@ -79,8 +80,11 @@ class MpcHcDevice(MediaPlayerDevice):
|
|||||||
|
|
||||||
for var in mpchc_variables:
|
for var in mpchc_variables:
|
||||||
self._player_variables[var[0]] = var[1].lower()
|
self._player_variables[var[0]] = var[1].lower()
|
||||||
|
self._available = True
|
||||||
except requests.exceptions.RequestException:
|
except requests.exceptions.RequestException:
|
||||||
_LOGGER.error("Could not connect to MPC-HC at: %s", self._url)
|
_LOGGER.error("Could not connect to MPC-HC at: %s", self._url)
|
||||||
|
self._player_variables = dict()
|
||||||
|
self._available = False
|
||||||
|
|
||||||
def _send_command(self, command_id):
|
def _send_command(self, command_id):
|
||||||
"""Send a command to MPC-HC via its window message ID."""
|
"""Send a command to MPC-HC via its window message ID."""
|
||||||
@ -111,6 +115,11 @@ class MpcHcDevice(MediaPlayerDevice):
|
|||||||
|
|
||||||
return STATE_IDLE
|
return STATE_IDLE
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self):
|
||||||
|
"""Return True if entity is available."""
|
||||||
|
return self._available
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_title(self):
|
def media_title(self):
|
||||||
"""Return the title of current playing media."""
|
"""Return the title of current playing media."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user