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:
jezcooke
2020-02-23 04:33:42 +00:00
committed by GitHub
parent bd00453cef
commit a678c6fd0b

View File

@@ -26,6 +26,7 @@ from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_PASSWORD, CONF_PASSWORD,
CONF_PORT, CONF_PORT,
STATE_IDLE,
STATE_OFF, STATE_OFF,
STATE_PAUSED, STATE_PAUSED,
STATE_PLAYING, STATE_PLAYING,
@@ -186,14 +187,17 @@ class AFSAPIDevice(MediaPlayerDevice):
if not self._source_list: if not self._source_list:
self._source_list = await fs_device.get_mode_list() self._source_list = await fs_device.get_mode_list()
status = await fs_device.get_play_status() if await fs_device.get_power():
self._state = { status = await fs_device.get_play_status()
"playing": STATE_PLAYING, self._state = {
"paused": STATE_PAUSED, "playing": STATE_PLAYING,
"stopped": STATE_OFF, "paused": STATE_PAUSED,
"unknown": STATE_UNKNOWN, "stopped": STATE_IDLE,
None: STATE_OFF, "unknown": STATE_UNKNOWN,
}.get(status, STATE_UNKNOWN) None: STATE_IDLE,
}.get(status, STATE_UNKNOWN)
else:
self._state = STATE_OFF
if self._state != STATE_OFF: if self._state != STATE_OFF:
info_name = await fs_device.get_play_name() info_name = await fs_device.get_play_name()