1 """Reproduce a Select entity state."""
3 from __future__
import annotations
6 from collections.abc
import Iterable
13 from .const
import ATTR_OPTION, ATTR_OPTIONS, DOMAIN, SERVICE_SELECT_OPTION
15 _LOGGER = logging.getLogger(__name__)
22 context: Context |
None =
None,
23 reproduce_options: dict[str, Any] |
None =
None,
25 """Reproduce a single state."""
26 if (cur_state := hass.states.get(state.entity_id))
is None:
27 _LOGGER.warning(
"Unable to find entity %s", state.entity_id)
30 if state.state
not in cur_state.attributes.get(ATTR_OPTIONS, []):
32 "Invalid state specified for %s: %s", state.entity_id, state.state
37 if cur_state.state == state.state:
40 await hass.services.async_call(
42 SERVICE_SELECT_OPTION,
43 {ATTR_ENTITY_ID: state.entity_id, ATTR_OPTION: state.state},
51 states: Iterable[State],
53 context: Context |
None =
None,
54 reproduce_options: dict[str, Any] |
None =
None,
56 """Reproduce multiple select states."""
60 hass, state, context=context, reproduce_options=reproduce_options
None _async_reproduce_state(HomeAssistant hass, State state, *Context|None context=None, dict[str, Any]|None reproduce_options=None)
None async_reproduce_states(HomeAssistant hass, Iterable[State] states, *Context|None context=None, dict[str, Any]|None reproduce_options=None)