mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 02:07:54 +00:00
Make homekit TV media players aware of STATE_STANDBY (#35282)
This was previously added to non-TV media players.
This commit is contained in:
parent
70b29dc823
commit
497c01c651
@ -93,6 +93,13 @@ MODE_FRIENDLY_NAME = {
|
|||||||
FEATURE_TOGGLE_MUTE: "Mute",
|
FEATURE_TOGGLE_MUTE: "Mute",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MEDIA_PLAYER_OFF_STATES = (
|
||||||
|
STATE_OFF,
|
||||||
|
STATE_UNKNOWN,
|
||||||
|
STATE_STANDBY,
|
||||||
|
"None",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@TYPES.register("MediaPlayer")
|
@TYPES.register("MediaPlayer")
|
||||||
class MediaPlayer(HomeAccessory):
|
class MediaPlayer(HomeAccessory):
|
||||||
@ -187,12 +194,7 @@ class MediaPlayer(HomeAccessory):
|
|||||||
current_state = new_state.state
|
current_state = new_state.state
|
||||||
|
|
||||||
if self.chars[FEATURE_ON_OFF]:
|
if self.chars[FEATURE_ON_OFF]:
|
||||||
hk_state = current_state not in (
|
hk_state = current_state not in MEDIA_PLAYER_OFF_STATES
|
||||||
STATE_OFF,
|
|
||||||
STATE_UNKNOWN,
|
|
||||||
STATE_STANDBY,
|
|
||||||
"None",
|
|
||||||
)
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
'%s: Set current state for "on_off" to %s', self.entity_id, hk_state
|
'%s: Set current state for "on_off" to %s', self.entity_id, hk_state
|
||||||
)
|
)
|
||||||
@ -379,7 +381,7 @@ class TelevisionMediaPlayer(HomeAccessory):
|
|||||||
|
|
||||||
# Power state television
|
# Power state television
|
||||||
hk_state = 0
|
hk_state = 0
|
||||||
if current_state not in ("None", STATE_OFF, STATE_UNKNOWN):
|
if current_state not in MEDIA_PLAYER_OFF_STATES:
|
||||||
hk_state = 1
|
hk_state = 1
|
||||||
_LOGGER.debug("%s: Set current active state to %s", self.entity_id, hk_state)
|
_LOGGER.debug("%s: Set current active state to %s", self.entity_id, hk_state)
|
||||||
if self.char_active.value != hk_state:
|
if self.char_active.value != hk_state:
|
||||||
|
@ -219,6 +219,14 @@ async def test_media_player_television(hass, hk_driver, events, caplog):
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert acc.char_active.value == 0
|
assert acc.char_active.value == 0
|
||||||
|
|
||||||
|
hass.states.async_set(entity_id, STATE_ON)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
assert acc.char_active.value == 1
|
||||||
|
|
||||||
|
hass.states.async_set(entity_id, STATE_STANDBY)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
assert acc.char_active.value == 0
|
||||||
|
|
||||||
hass.states.async_set(entity_id, STATE_ON, {ATTR_INPUT_SOURCE: "HDMI 2"})
|
hass.states.async_set(entity_id, STATE_ON, {ATTR_INPUT_SOURCE: "HDMI 2"})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert acc.char_input_source.value == 1
|
assert acc.char_input_source.value == 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user