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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user