From 3bd955299cfe35f4ad35c340ac03cd68304492ac Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Fri, 2 Aug 2024 18:28:44 -0500 Subject: [PATCH] updated scene detect app --- apps/scene_detect.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/scene_detect.py b/apps/scene_detect.py index e7f3ccf..b96edea 100644 --- a/apps/scene_detect.py +++ b/apps/scene_detect.py @@ -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))