mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
@@ -3,7 +3,6 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Awaitable, Callable, Iterable
|
||||
from contextvars import ContextVar
|
||||
import dataclasses
|
||||
from functools import partial, wraps
|
||||
import logging
|
||||
@@ -64,15 +63,6 @@ _LOGGER = logging.getLogger(__name__)
|
||||
SERVICE_DESCRIPTION_CACHE = "service_description_cache"
|
||||
|
||||
|
||||
_current_entity: ContextVar[str | None] = ContextVar("current_entity", default=None)
|
||||
|
||||
|
||||
@callback
|
||||
def async_get_current_entity() -> str | None:
|
||||
"""Get the current entity on which the service is called."""
|
||||
return _current_entity.get()
|
||||
|
||||
|
||||
class ServiceParams(TypedDict):
|
||||
"""Type for service call parameters."""
|
||||
|
||||
@@ -716,7 +706,6 @@ async def _handle_entity_call(
|
||||
) -> None:
|
||||
"""Handle calling service method."""
|
||||
entity.async_set_context(context)
|
||||
_current_entity.set(entity.entity_id)
|
||||
|
||||
if isinstance(func, str):
|
||||
result = hass.async_run_job(partial(getattr(entity, func), **data)) # type: ignore[arg-type]
|
||||
|
||||
Reference in New Issue
Block a user