Make homekit aware of STATE_STANDBY (#33679)

This commit is contained in:
J. Nick Koston 2020-04-05 08:47:44 -05:00 committed by GitHub
parent de317fb2f6
commit b855177fe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -33,6 +33,7 @@ from homeassistant.const import (
STATE_OFF,
STATE_PAUSED,
STATE_PLAYING,
STATE_STANDBY,
STATE_UNKNOWN,
)
@ -190,7 +191,12 @@ class MediaPlayer(HomeAccessory):
current_state = new_state.state
if self.chars[FEATURE_ON_OFF]:
hk_state = current_state not in (STATE_OFF, STATE_UNKNOWN, "None")
hk_state = current_state not in (
STATE_OFF,
STATE_UNKNOWN,
STATE_STANDBY,
"None",
)
if not self._flag[FEATURE_ON_OFF]:
_LOGGER.debug(
'%s: Set current state for "on_off" to %s', self.entity_id, hk_state

View File

@ -30,6 +30,7 @@ from homeassistant.const import (
STATE_ON,
STATE_PAUSED,
STATE_PLAYING,
STATE_STANDBY,
)
from homeassistant.core import CoreState
from homeassistant.helpers import entity_registry
@ -75,6 +76,14 @@ async def test_media_player_set_state(hass, hk_driver, events):
await hass.async_block_till_done()
assert acc.chars[FEATURE_ON_OFF].value is False
hass.states.async_set(entity_id, STATE_ON)
await hass.async_block_till_done()
assert acc.chars[FEATURE_ON_OFF].value is True
hass.states.async_set(entity_id, STATE_STANDBY)
await hass.async_block_till_done()
assert acc.chars[FEATURE_ON_OFF].value is False
hass.states.async_set(entity_id, STATE_PLAYING)
await hass.async_block_till_done()
assert acc.chars[FEATURE_PLAY_PAUSE].value is True