1 """Reproduce an Alert state."""
3 from __future__
import annotations
6 from collections.abc
import Iterable
18 from .const
import DOMAIN, LOGGER
20 VALID_STATES = {STATE_ON, STATE_OFF}
27 context: Context |
None =
None,
28 reproduce_options: dict[str, Any] |
None =
None,
30 """Reproduce a single state."""
31 if (cur_state := hass.states.get(state.entity_id))
is None:
32 LOGGER.warning(
"Unable to find entity %s", state.entity_id)
35 if state.state
not in VALID_STATES:
37 "Invalid state specified for %s: %s", state.entity_id, state.state
42 if cur_state.state == state.state:
45 service_data = {ATTR_ENTITY_ID: state.entity_id}
47 if state.state == STATE_ON:
48 service = SERVICE_TURN_ON
50 elif state.state == STATE_OFF:
51 service = SERVICE_TURN_OFF
53 await hass.services.async_call(
54 DOMAIN, service, service_data, context=context, blocking=
True
60 states: Iterable[State],
62 context: Context |
None =
None,
63 reproduce_options: dict[str, Any] |
None =
None,
65 """Reproduce Alert states."""
70 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)