From e23d32f7079f59c1f1853eb68f653d52715778d6 Mon Sep 17 00:00:00 2001 From: paoloavezzano <795633+paoloavezzano@users.noreply.github.com> Date: Thu, 24 Sep 2026 14:24:12 +0200 Subject: [PATCH] Replace deprecated asyncio.iscoroutinefunction usage --- custom_components/adaptive_lighting/hass_utils.py | 4 ++-- custom_components/adaptive_lighting/switch.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/custom_components/adaptive_lighting/hass_utils.py b/custom_components/adaptive_lighting/hass_utils.py index 822e2e29..3bb85ad1 100644 --- a/custom_components/adaptive_lighting/hass_utils.py +++ b/custom_components/adaptive_lighting/hass_utils.py @@ -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) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index db1c2d0b..63e7dd53 100644 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -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()