Extract instance ID helper from updater (#35043)
This commit is contained in:
parent
b3e637ca7a
commit
e54e9279e3
8 changed files with 72 additions and 37 deletions
|
@ -4,6 +4,7 @@ import functools
|
|||
from typing import Awaitable, Callable, TypeVar, cast
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.loader import bind_hass
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
@ -19,6 +20,7 @@ def singleton(data_key: str) -> Callable[[FUNC], FUNC]:
|
|||
def wrapper(func: FUNC) -> FUNC:
|
||||
"""Wrap a function with caching logic."""
|
||||
|
||||
@bind_hass
|
||||
@functools.wraps(func)
|
||||
async def wrapped(hass: HomeAssistant) -> T:
|
||||
obj_or_evt = hass.data.get(data_key)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue