started async stuff
This commit is contained in:
Submodule apps/room_control updated: c9cc841d58...4513437bf4
@@ -1,5 +1,6 @@
|
|||||||
from appdaemon.plugins.hass.hassapi import Hass
|
from appdaemon.plugins.hass.hassapi import Hass
|
||||||
|
|
||||||
|
|
||||||
class SceneDetector(Hass):
|
class SceneDetector(Hass):
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
self.scene_entity = self.args['scene'] if self.args['scene'].startswith('scene.') else f'scene.{self.args["scene"]}'
|
self.scene_entity = self.args['scene'] if self.args['scene'].startswith('scene.') else f'scene.{self.args["scene"]}'
|
||||||
@@ -8,17 +9,17 @@ class SceneDetector(Hass):
|
|||||||
self.listen_event(self.event_callback, event='call_service', domain='scene', service='turn_on')
|
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 {self.scene_entity.friendly_name} to activate')
|
||||||
|
|
||||||
def event_callback(self, event_name, data, cb_args):
|
async def event_callback(self, event_name, data, cb_args):
|
||||||
entity_id = data['service_data']['entity_id']
|
entity_id = data['service_data']['entity_id']
|
||||||
if entity_id == self.scene_entity.entity_id:
|
if entity_id == self.scene_entity.entity_id:
|
||||||
self.scene_detected()
|
await self.scene_detected()
|
||||||
|
|
||||||
def scene_detected(self):
|
async def scene_detected(self):
|
||||||
self.log(f'Detected scene activation: {self.scene_entity.friendly_name}')
|
self.log(f'Detected scene activation: {self.scene_entity.friendly_name}')
|
||||||
|
|
||||||
|
|
||||||
class MotionCanceller(SceneDetector):
|
class MotionCanceller(SceneDetector):
|
||||||
def scene_detected(self):
|
async def scene_detected(self):
|
||||||
super().scene_detected()
|
await super().scene_detected()
|
||||||
app = self.get_app(self.args['app'])
|
app = await self.get_app(self.args['app'])
|
||||||
app.cancel_motion_callback(new='off')
|
app.cancel_motion_callback(new='off')
|
||||||
Reference in New Issue
Block a user