1 """Reproduce a Text entity state."""
3 from __future__
import annotations
6 from collections.abc
import Iterable
13 from .const
import ATTR_VALUE, DOMAIN, SERVICE_SET_VALUE
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)
31 if cur_state.state == state.state:
34 service = SERVICE_SET_VALUE
35 service_data = {ATTR_ENTITY_ID: state.entity_id, ATTR_VALUE: state.state}
37 await hass.services.async_call(
38 DOMAIN, service, service_data, context=context, blocking=
True
44 states: Iterable[State],
46 context: Context |
None =
None,
47 reproduce_options: dict[str, Any] |
None =
None,
49 """Reproduce multiple Text states."""
54 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)