mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Support playing, pausing states for media players when reproducing state
This allows the state helper to call the correct service call for media_players when attempting to resolve state.
This commit is contained in:
parent
62f016e7d2
commit
1674c8309a
@ -9,7 +9,8 @@ import logging
|
|||||||
from homeassistant.core import State
|
from homeassistant.core import State
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_ON, STATE_OFF, SERVICE_TURN_ON, SERVICE_TURN_OFF, ATTR_ENTITY_ID)
|
STATE_ON, STATE_OFF, SERVICE_TURN_ON, SERVICE_TURN_OFF,
|
||||||
|
STATE_PLAYING, STATE_PAUSED, ATTR_ENTITY_ID)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -55,14 +56,19 @@ def reproduce_state(hass, states, blocking=False):
|
|||||||
state.entity_id)
|
state.entity_id)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if state.state == STATE_ON:
|
if state.domain == 'media_player' and state == STATE_PAUSED:
|
||||||
service = SERVICE_TURN_ON
|
service = 'media_pause'
|
||||||
elif state.state == STATE_OFF:
|
elif state.domain == 'media_player' and state == STATE_PLAYING:
|
||||||
service = SERVICE_TURN_OFF
|
service = 'media_play'
|
||||||
else:
|
elif
|
||||||
_LOGGER.warning("reproduce_state: Unable to reproduce state %s",
|
if state.state == STATE_ON:
|
||||||
state)
|
service = SERVICE_TURN_ON
|
||||||
continue
|
elif state.state == STATE_OFF:
|
||||||
|
service = SERVICE_TURN_OFF
|
||||||
|
else:
|
||||||
|
_LOGGER.warning("reproduce_state: Unable to reproduce state %s",
|
||||||
|
state)
|
||||||
|
continue
|
||||||
|
|
||||||
service_data = dict(state.attributes)
|
service_data = dict(state.attributes)
|
||||||
service_data[ATTR_ENTITY_ID] = state.entity_id
|
service_data[ATTR_ENTITY_ID] = state.entity_id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user