tweaks
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import asyncio
|
||||
import json
|
||||
import re
|
||||
|
||||
from appdaemon.plugins.hass.hassapi import Hass
|
||||
from room_control import Motion
|
||||
@@ -17,7 +17,7 @@ class SceneDetector(Hass):
|
||||
self.listen_event(
|
||||
self.event_callback, event='call_service', domain='scene', service='turn_on'
|
||||
)
|
||||
self.log(f'Waiting for {self.scene_entity.friendly_name} to activate')
|
||||
self.log(f"Waiting for scene '{self.scene_entity.friendly_name}' to activate")
|
||||
|
||||
async def event_callback(self, event_name, data, cb_args):
|
||||
entity_id = data['service_data']['entity_id']
|
||||
@@ -26,19 +26,19 @@ class SceneDetector(Hass):
|
||||
|
||||
async def scene_detected(self):
|
||||
self.log(f'Detected scene activation: {self.scene_entity.friendly_name}')
|
||||
await asyncio.sleep(1.0)
|
||||
|
||||
|
||||
class MotionCanceller(SceneDetector):
|
||||
async def scene_detected(self):
|
||||
await super().scene_detected()
|
||||
app: Motion = await self.get_app(self.args['app'])
|
||||
all_callbacks = await self.get_callback_entries()
|
||||
app_callbacks = all_callbacks[app.name]
|
||||
callbacks = await self.get_callback_entries()[app.name]
|
||||
|
||||
for handle, info in app_callbacks.items():
|
||||
for handle, info in callbacks.items():
|
||||
if info['entity'] == app.sensor.entity_id and 'new=off' in info['kwargs']:
|
||||
self.log(f'Cancelling motion callback for {app.name}')
|
||||
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))
|
||||
break
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user