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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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()