1 """Reproduce an input boolean state."""
3 from __future__
import annotations
6 from collections.abc
import Iterable
21 _LOGGER = logging.getLogger(__name__)
28 context: Context |
None =
None,
29 reproduce_options: dict[str, Any] |
None =
None,
31 """Reproduce input boolean states."""
32 if (cur_state := hass.states.get(state.entity_id))
is None:
33 _LOGGER.warning(
"Unable to find entity %s", state.entity_id)
36 if state.state
not in (STATE_ON, STATE_OFF):
38 "Invalid state specified for %s: %s", state.entity_id, state.state
42 if cur_state.state == state.state:
45 service = SERVICE_TURN_ON
if state.state == STATE_ON
else SERVICE_TURN_OFF
47 await hass.services.async_call(
50 {ATTR_ENTITY_ID: state.entity_id},
58 states: Iterable[State],
60 context: Context |
None =
None,
61 reproduce_options: dict[str, Any] |
None =
None,
63 """Reproduce component states."""
67 hass, state, context=context, reproduce_options=reproduce_options