1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Use singleton helper for registries (#117027)

This commit is contained in:
J. Nick Koston
2024-05-07 14:04:01 -05:00
committed by GitHub
parent 6e024d54f1
commit 26cc1cd3db
7 changed files with 27 additions and 18 deletions

View File

@@ -18,6 +18,7 @@ from .normalized_name_base_registry import (
normalize_name,
)
from .registry import BaseRegistry
from .singleton import singleton
from .storage import Store
from .typing import UNDEFINED, UndefinedType
@@ -239,13 +240,13 @@ class FloorRegistry(BaseRegistry[FloorRegistryStoreData]):
@callback
@singleton(DATA_REGISTRY)
def async_get(hass: HomeAssistant) -> FloorRegistry:
"""Get floor registry."""
return hass.data[DATA_REGISTRY]
return FloorRegistry(hass)
async def async_load(hass: HomeAssistant) -> None:
"""Load floor registry."""
assert DATA_REGISTRY not in hass.data
hass.data[DATA_REGISTRY] = FloorRegistry(hass)
await hass.data[DATA_REGISTRY].async_load()
await async_get(hass).async_load()