Fix imports for micropython

This commit is contained in:
2026-08-23 12:50:50 +02:00
parent c860afc609
commit 178457e199
+7 -3
View File
@@ -1,6 +1,10 @@
import time import time
import asyncio try:
import inspect import asyncio
import inspect
ASYNCIO = True
except ImportError:
ASYNCIO = False
class AlertManager: class AlertManager:
def __init__(self): def __init__(self):
@@ -12,7 +16,7 @@ class AlertManager:
def call_on_alert_callback(self, alert): def call_on_alert_callback(self, alert):
if self.on_alert_callback: if self.on_alert_callback:
if inspect.iscoroutinefunction(self.on_alert_callback): if ASYNCIO and inspect.iscoroutinefunction(self.on_alert_callback):
# Schedule coroutine on the running loop without blocking # Schedule coroutine on the running loop without blocking
try: try:
loop = asyncio.get_running_loop() loop = asyncio.get_running_loop()