Home Assistant Unofficial Reference 2024.12.1
reproduce_state.py
Go to the documentation of this file.
1 """Module that groups code required to handle state restore for component."""
2 
3 from __future__ import annotations
4 
5 from collections.abc import Iterable
6 from typing import Any
7 
8 from homeassistant.core import Context, HomeAssistant, State
9 from homeassistant.helpers.state import async_reproduce_state
10 
11 from . import get_entity_ids
12 
13 
15  hass: HomeAssistant,
16  states: Iterable[State],
17  *,
18  context: Context | None = None,
19  reproduce_options: dict[str, Any] | None = None,
20 ) -> None:
21  """Reproduce component states."""
22  states_copy = [
23  State(
24  member,
25  state.state,
26  state.attributes,
27  last_changed=state.last_changed,
28  last_reported=state.last_reported,
29  last_updated=state.last_updated,
30  context=state.context,
31  )
32  for state in states
33  for member in get_entity_ids(hass, state.entity_id)
34  ]
36  hass, states_copy, context=context, reproduce_options=reproduce_options
37  )
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|Iterable[State] states, *Context|None context=None, dict[str, Any]|None reproduce_options=None)
Definition: state.py:36