88from sqlalchemy .orm .session import Session
99
1010from homeassistant .core import HomeAssistant , State
11- from homeassistant .helpers .recorder import get_instance
1211
1312from ..filters import Filters
1413from .const import NEED_ATTRIBUTE_DOMAINS , SIGNIFICANT_DOMAINS
@@ -44,15 +43,7 @@ def get_full_significant_states_with_session(
4443 no_attributes : bool = False ,
4544) -> dict [str , list [State ]]:
4645 """Return a dict of significant states during a time period."""
47- if not get_instance (hass ).states_meta_manager .active :
48- from .legacy import ( # noqa: PLC0415
49- get_full_significant_states_with_session as _legacy_get_full_significant_states_with_session ,
50- )
51-
52- _target = _legacy_get_full_significant_states_with_session
53- else :
54- _target = _modern_get_full_significant_states_with_session
55- return _target (
46+ return _modern_get_full_significant_states_with_session (
5647 hass ,
5748 session ,
5849 start_time ,
@@ -69,15 +60,7 @@ def get_last_state_changes(
6960 hass : HomeAssistant , number_of_states : int , entity_id : str
7061) -> dict [str , list [State ]]:
7162 """Return the last number_of_states."""
72- if not get_instance (hass ).states_meta_manager .active :
73- from .legacy import ( # noqa: PLC0415
74- get_last_state_changes as _legacy_get_last_state_changes ,
75- )
76-
77- _target = _legacy_get_last_state_changes
78- else :
79- _target = _modern_get_last_state_changes
80- return _target (hass , number_of_states , entity_id )
63+ return _modern_get_last_state_changes (hass , number_of_states , entity_id )
8164
8265
8366def get_significant_states (
@@ -93,15 +76,7 @@ def get_significant_states(
9376 compressed_state_format : bool = False ,
9477) -> dict [str , list [State | dict [str , Any ]]]:
9578 """Return a dict of significant states during a time period."""
96- if not get_instance (hass ).states_meta_manager .active :
97- from .legacy import ( # noqa: PLC0415
98- get_significant_states as _legacy_get_significant_states ,
99- )
100-
101- _target = _legacy_get_significant_states
102- else :
103- _target = _modern_get_significant_states
104- return _target (
79+ return _modern_get_significant_states (
10580 hass ,
10681 start_time ,
10782 end_time ,
@@ -129,15 +104,7 @@ def get_significant_states_with_session(
129104 compressed_state_format : bool = False ,
130105) -> dict [str , list [State | dict [str , Any ]]]:
131106 """Return a dict of significant states during a time period."""
132- if not get_instance (hass ).states_meta_manager .active :
133- from .legacy import ( # noqa: PLC0415
134- get_significant_states_with_session as _legacy_get_significant_states_with_session ,
135- )
136-
137- _target = _legacy_get_significant_states_with_session
138- else :
139- _target = _modern_get_significant_states_with_session
140- return _target (
107+ return _modern_get_significant_states_with_session (
141108 hass ,
142109 session ,
143110 start_time ,
@@ -163,15 +130,7 @@ def state_changes_during_period(
163130 include_start_time_state : bool = True ,
164131) -> dict [str , list [State ]]:
165132 """Return a list of states that changed during a time period."""
166- if not get_instance (hass ).states_meta_manager .active :
167- from .legacy import ( # noqa: PLC0415
168- state_changes_during_period as _legacy_state_changes_during_period ,
169- )
170-
171- _target = _legacy_state_changes_during_period
172- else :
173- _target = _modern_state_changes_during_period
174- return _target (
133+ return _modern_state_changes_during_period (
175134 hass ,
176135 start_time ,
177136 end_time ,
0 commit comments