1 """Reproduce an Lock state."""
3 from __future__
import annotations
6 from collections.abc
import Iterable
18 from .
import DOMAIN, LockState
20 _LOGGER = logging.getLogger(__name__)
36 context: Context |
None =
None,
37 reproduce_options: dict[str, Any] |
None =
None,
39 """Reproduce a single state."""
40 if (cur_state := hass.states.get(state.entity_id))
is None:
41 _LOGGER.warning(
"Unable to find entity %s", state.entity_id)
44 if state.state
not in VALID_STATES:
46 "Invalid state specified for %s: %s", state.entity_id, state.state
51 if cur_state.state == state.state:
54 service_data = {ATTR_ENTITY_ID: state.entity_id}
56 if state.state
in {LockState.LOCKED, LockState.LOCKING}:
57 service = SERVICE_LOCK
58 elif state.state
in {LockState.UNLOCKED, LockState.UNLOCKING}:
59 service = SERVICE_UNLOCK
60 elif state.state
in {LockState.OPEN, LockState.OPENING}:
61 service = SERVICE_OPEN
63 await hass.services.async_call(
64 DOMAIN, service, service_data, context=context, blocking=
True
70 states: Iterable[State],
72 context: Context |
None =
None,
73 reproduce_options: dict[str, Any] |
None =
None,
75 """Reproduce Lock states."""
79 hass, state, context=context, reproduce_options=reproduce_options
None async_reproduce_states(HomeAssistant hass, Iterable[State] states, *Context|None context=None, dict[str, Any]|None reproduce_options=None)
None _async_reproduce_state(HomeAssistant hass, State state, *Context|None context=None, dict[str, Any]|None reproduce_options=None)