updated scene detect app

This commit is contained in:
John Lancaster
2024-08-02 18:28:44 -05:00
parent a73153298a
commit 3bd955299c

View File

@@ -1,8 +1,7 @@
import asyncio import asyncio
import json
from appdaemon.plugins.hass.hassapi import Hass from appdaemon.plugins.hass.hassapi import Hass
from room_control import Motion from room_control import RoomController
class SceneDetector(Hass): class SceneDetector(Hass):
@@ -30,13 +29,18 @@ class SceneDetector(Hass):
class MotionCanceller(SceneDetector): class MotionCanceller(SceneDetector):
@property
def room(self) -> str:
return self.args['room']
async def scene_detected(self): async def scene_detected(self):
await super().scene_detected() await super().scene_detected()
app: Motion = await self.get_app(self.args['app']) callbacks = (await self.get_callback_entries())[self.room]
callbacks = (await self.get_callback_entries())[app.name]
app: RoomController = await self.get_app(self.room)
for handle, info in callbacks.items(): 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) await self.AD.state.cancel_state_callback(handle, app.name)
self.log(f'Cancelled motion callback for {app.name}') self.log(f'Cancelled motion callback for {app.name}')
# self.log(json.dumps(info, indent=4)) # self.log(json.dumps(info, indent=4))