removed obsolete
This commit is contained in:
19
motion.py
19
motion.py
@@ -1,29 +1,12 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from datetime import timedelta
|
|
||||||
import re
|
import re
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
from appdaemon.entity import Entity
|
from appdaemon.entity import Entity
|
||||||
from appdaemon.plugins.hass.hassapi import Hass
|
from appdaemon.plugins.hass.hassapi import Hass
|
||||||
from room_control import RoomController
|
from room_control import RoomController
|
||||||
|
|
||||||
|
|
||||||
class CustomEventLoopPolicy(asyncio.DefaultEventLoopPolicy):
|
|
||||||
def get_event_loop(self):
|
|
||||||
try:
|
|
||||||
# Try to get the current event loop
|
|
||||||
loop = super().get_event_loop()
|
|
||||||
except RuntimeError as ex:
|
|
||||||
if "There is no current event loop" in str(ex):
|
|
||||||
# If there's no current loop, create a new one and set it
|
|
||||||
loop = self.new_event_loop()
|
|
||||||
self.set_event_loop(loop)
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
return loop
|
|
||||||
|
|
||||||
# Set the custom event loop policy
|
|
||||||
asyncio.set_event_loop_policy(CustomEventLoopPolicy())
|
|
||||||
|
|
||||||
class Motion(Hass):
|
class Motion(Hass):
|
||||||
@property
|
@property
|
||||||
def sensor(self) -> Entity:
|
def sensor(self) -> Entity:
|
||||||
|
|||||||
Reference in New Issue
Block a user