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

Revert "Add service entity context (#71558)" (#72610)

This commit is contained in:
Paulus Schoutsen
2022-05-27 10:30:40 -07:00
committed by GitHub
parent 2a1405c4bd
commit d59258bd25
2 changed files with 1 additions and 26 deletions

View File

@@ -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]