Migrate recorder instance to use HassKey (#118673)

This commit is contained in:
J. Nick Koston
2024-06-03 11:19:00 -05:00
committed by GitHub
parent 5d594a509c
commit 099ad77078
3 changed files with 15 additions and 9 deletions

View File

@ -739,8 +739,7 @@ def async_migration_in_progress(hass: HomeAssistant) -> bool:
"""
if DATA_INSTANCE not in hass.data:
return False
instance = get_instance(hass)
return instance.migration_in_progress
return hass.data[DATA_INSTANCE].migration_in_progress
def async_migration_is_live(hass: HomeAssistant) -> bool:
@ -751,8 +750,7 @@ def async_migration_is_live(hass: HomeAssistant) -> bool:
"""
if DATA_INSTANCE not in hass.data:
return False
instance: Recorder = hass.data[DATA_INSTANCE]
return instance.migration_is_live
return hass.data[DATA_INSTANCE].migration_is_live
def second_sunday(year: int, month: int) -> date:
@ -771,10 +769,10 @@ def is_second_sunday(date_time: datetime) -> bool:
return bool(second_sunday(date_time.year, date_time.month).day == date_time.day)
@functools.lru_cache(maxsize=1)
def get_instance(hass: HomeAssistant) -> Recorder:
"""Get the recorder instance."""
instance: Recorder = hass.data[DATA_INSTANCE]
return instance
return hass.data[DATA_INSTANCE]
PERIOD_SCHEMA = vol.Schema(