Fix Frontier Silicon player state (#32082)
The player would report itself as ‘off’ when in certain modes (e.g ‘Music player’ or ‘Spotify’) which meant HA would lose all control (it can’t change input or set volume etc. as it thinks it’s off). Now reports STATE_IDLE in these cases and only STATE_OFF if it is actually off. This fixes issue #20728.
This commit is contained in:
parent
bd00453cef
commit
a678c6fd0b
1 changed files with 12 additions and 8 deletions
|
@ -26,6 +26,7 @@ from homeassistant.const import (
|
|||
CONF_HOST,
|
||||
CONF_PASSWORD,
|
||||
CONF_PORT,
|
||||
STATE_IDLE,
|
||||
STATE_OFF,
|
||||
STATE_PAUSED,
|
||||
STATE_PLAYING,
|
||||
|
@ -186,14 +187,17 @@ class AFSAPIDevice(MediaPlayerDevice):
|
|||
if not self._source_list:
|
||||
self._source_list = await fs_device.get_mode_list()
|
||||
|
||||
status = await fs_device.get_play_status()
|
||||
self._state = {
|
||||
"playing": STATE_PLAYING,
|
||||
"paused": STATE_PAUSED,
|
||||
"stopped": STATE_OFF,
|
||||
"unknown": STATE_UNKNOWN,
|
||||
None: STATE_OFF,
|
||||
}.get(status, STATE_UNKNOWN)
|
||||
if await fs_device.get_power():
|
||||
status = await fs_device.get_play_status()
|
||||
self._state = {
|
||||
"playing": STATE_PLAYING,
|
||||
"paused": STATE_PAUSED,
|
||||
"stopped": STATE_IDLE,
|
||||
"unknown": STATE_UNKNOWN,
|
||||
None: STATE_IDLE,
|
||||
}.get(status, STATE_UNKNOWN)
|
||||
else:
|
||||
self._state = STATE_OFF
|
||||
|
||||
if self._state != STATE_OFF:
|
||||
info_name = await fs_device.get_play_name()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue