-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
/
Copy pathreproduce_state.py
37 lines (31 loc) · 1.04 KB
/
reproduce_state.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""Module that groups code required to handle state restore for component."""
from __future__ import annotations
from collections.abc import Iterable
from typing import Any
from homeassistant.core import Context, HomeAssistant, State
from homeassistant.helpers.state import async_reproduce_state
from . import get_entity_ids
async def async_reproduce_states(
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,
reproduce_options: dict[str, Any] | None = None,
) -> None:
"""Reproduce component states."""
states_copy = [
State(
member,
state.state,
state.attributes,
last_changed=state.last_changed,
last_reported=state.last_reported,
last_updated=state.last_updated,
context=state.context,
)
for state in states
for member in get_entity_ids(hass, state.entity_id)
]
await async_reproduce_state(
hass, states_copy, context=context, reproduce_options=reproduce_options
)