1 """Reproduce an Input number state."""
3 from __future__
import annotations
6 from collections.abc
import Iterable
10 import voluptuous
as vol
15 from .
import ATTR_VALUE, DOMAIN, SERVICE_SET_VALUE
17 _LOGGER = logging.getLogger(__name__)
24 context: Context |
None =
None,
25 reproduce_options: dict[str, Any] |
None =
None,
27 """Reproduce a single state."""
28 if (cur_state := hass.states.get(state.entity_id))
is None:
29 _LOGGER.warning(
"Unable to find entity %s", state.entity_id)
36 "Invalid state specified for %s: %s", state.entity_id, state.state
41 if cur_state.state == state.state:
44 service = SERVICE_SET_VALUE
45 service_data = {ATTR_ENTITY_ID: state.entity_id, ATTR_VALUE: state.state}
48 await hass.services.async_call(
49 DOMAIN, service, service_data, context=context, blocking=
True
51 except vol.Invalid
as err:
53 _LOGGER.warning(
"Unable to reproduce state for %s: %s", state.entity_id, err)
58 states: Iterable[State],
60 context: Context |
None =
None,
61 reproduce_options: dict[str, Any] |
None =
None,
63 """Reproduce Input number states."""
68 hass, state, context=context, reproduce_options=reproduce_options