updated scene detect app
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import asyncio
|
||||
import json
|
||||
|
||||
from appdaemon.plugins.hass.hassapi import Hass
|
||||
from room_control import Motion
|
||||
from room_control import RoomController
|
||||
|
||||
|
||||
class SceneDetector(Hass):
|
||||
@@ -30,13 +29,18 @@ class SceneDetector(Hass):
|
||||
|
||||
|
||||
class MotionCanceller(SceneDetector):
|
||||
@property
|
||||
def room(self) -> str:
|
||||
return self.args['room']
|
||||
|
||||
async def scene_detected(self):
|
||||
await super().scene_detected()
|
||||
app: Motion = await self.get_app(self.args['app'])
|
||||
callbacks = (await self.get_callback_entries())[app.name]
|
||||
callbacks = (await self.get_callback_entries())[self.room]
|
||||
|
||||
app: RoomController = await self.get_app(self.room)
|
||||
|
||||
for handle, info in callbacks.items():
|
||||
if info['entity'] == app.sensor.entity_id and 'new=off' in info['kwargs']:
|
||||
if info['entity'] == app.motion.sensor_entity_id and 'new=off' in info['kwargs']:
|
||||
await self.AD.state.cancel_state_callback(handle, app.name)
|
||||
self.log(f'Cancelled motion callback for {app.name}')
|
||||
# self.log(json.dumps(info, indent=4))
|
||||
|
||||
Reference in New Issue
Block a user