mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-10-28 14:17:07 +01:00
Merge e23d32f707 into b2ca188df3
This commit is contained in:
commit
7e57a50b74
2 changed files with 4 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
"""Utility functions for HA core."""
|
||||
|
||||
import inspect
|
||||
import logging
|
||||
from collections.abc import Awaitable, Callable
|
||||
|
||||
|
|
@ -80,10 +81,9 @@ def setup_service_call_interceptor(
|
|||
call.data,
|
||||
)
|
||||
# Call original service handler with processed data
|
||||
import asyncio
|
||||
|
||||
target = existing_service.job.target
|
||||
if asyncio.iscoroutinefunction(target):
|
||||
if inspect.iscoroutinefunction(target):
|
||||
await target(call)
|
||||
else:
|
||||
target(call)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from __future__ import annotations
|
|||
import asyncio
|
||||
import datetime
|
||||
import hashlib
|
||||
import inspect
|
||||
import logging
|
||||
import zoneinfo
|
||||
from copy import deepcopy
|
||||
|
|
@ -3329,7 +3330,7 @@ class _AsyncSingleShotTimer:
|
|||
"""Run the timer. Don't call this directly, use start() instead."""
|
||||
await asyncio.sleep(self.delay)
|
||||
if self.callback:
|
||||
if asyncio.iscoroutinefunction(self.callback):
|
||||
if inspect.iscoroutinefunction(self.callback):
|
||||
await self.callback()
|
||||
else:
|
||||
self.callback()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue