Add transition support to scenes, cleanup blocking parameter (#34434)
This commit is contained in:
1 parent
19be31d13a
commit
bc5a2da7b7
66 files changed
+547
-229
No files matched your search
@@ -1,7 +1,7 @@
|
||||
"""Reproduce an NEW_NAME state."""
|
||||
import asyncio
|
||||
import logging
|
||||
from typing import Iterable, Optional
|
||||
from typing import Any, Dict, Iterable, Optional
|
||||
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
@@ -22,7 +22,11 @@ VALID_STATES = {STATE_ON, STATE_OFF}
|
||||
|
||||
|
||||
async def _async_reproduce_state(
|
||||
hass: HomeAssistantType, state: State, context: Optional[Context] = None
|
||||
hass: HomeAssistantType,
|
||||
state: State,
|
||||
*,
|
||||
context: Optional[Context] = None,
|
||||
reproduce_options: Optional[Dict[str, Any]] = None,
|
||||
) -> None:
|
||||
"""Reproduce a single state."""
|
||||
cur_state = hass.states.get(state.entity_id)
|
||||
@@ -63,16 +67,25 @@ async def _async_reproduce_state(
|
||||
|
||||
|
||||
async def async_reproduce_states(
|
||||
hass: HomeAssistantType, states: Iterable[State], context: Optional[Context] = None
|
||||
hass: HomeAssistantType,
|
||||
states: Iterable[State],
|
||||
*,
|
||||
context: Optional[Context] = None,
|
||||
reproduce_options: Optional[Dict[str, Any]] = None,
|
||||
) -> None:
|
||||
"""Reproduce NEW_NAME states."""
|
||||
# TODO pick one and remove other one
|
||||
|
||||
# Reproduce states in parallel.
|
||||
await asyncio.gather(
|
||||
*(_async_reproduce_state(hass, state, context) for state in states)
|
||||
*(
|
||||
_async_reproduce_state(
|
||||
hass, state, context=context, reproduce_options=reproduce_options
|
||||
)
|
||||
for state in states
|
||||
)
|
||||
)
|
||||
|
||||
# Alternative: Reproduce states in sequence
|
||||
# for state in states:
|
||||
# await _async_reproduce_state(hass, state, context)
|
||||
# await _async_reproduce_state(hass, state, context=context, reproduce_options=reproduce_options)
|
||||
Reference in new issue
Block a user