From 9700e3505a0020b665a831058a6e24cdde6be14b Mon Sep 17 00:00:00 2001 From: jkerdreu <jkerdreu@b32b6428-25c9-4566-ad07-03861ab6144f> Date: Thu, 11 Jul 2019 11:42:04 +0000 Subject: [PATCH] Added demo Alarm git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@2249 b32b6428-25c9-4566-ad07-03861ab6144f --- scripts/btn_relay_labo.py | 47 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/scripts/btn_relay_labo.py b/scripts/btn_relay_labo.py index a0891c76..9f0fb23c 100644 --- a/scripts/btn_relay_labo.py +++ b/scripts/btn_relay_labo.py @@ -1,19 +1,25 @@ from xaal.lib import Engine from xaal.schemas import devices from xaal.monitor import Monitor -import platform +import platform,time PKG_NAME = 'btn_relay_labo' LAMPS=['ccc44227-d4fc-46eb-8578-159e2c47da03','ccc44227-d4fc-46eb-8578-159e2c47da04','ccc44227-d4fc-46eb-8578-159e2c47da05', 'ccc44227-d4fc-46eb-8578-159e2c47da06','ccc44227-d4fc-46eb-8578-159e2c47da07','ccc44227-d4fc-46eb-8578-159e2c47da08'] +SPOTS=['6265eb30-8c59-11e9-98b1-b827ebe99201',] + + # Edisio labo BTNS=['743034ca-c2f0-11e8-9485-a40074bcb601','743034ca-c2f0-11e8-9485-a40074bcb603','743034ca-c2f0-11e8-9485-a40074bcb605', '743034ca-c2f0-11e8-9485-a40074bcb607','743034ca-c2f0-11e8-9485-a40074bcb608'] # Aquara sw1 AQUARA=['1ec6bbd0-20b5-11e9-b352-a4badbf92500'] +SDB = ['fb1f8648-20ba-11e9-b352-a4badbf92500','fb1f8648-20ba-11e9-b352-a4badbf92501','fb1f8648-20ba-11e9-b352-a4badbf92502'] +SCEN = ['00796898-20bb-11e9-b352-a4badbf92500','00796898-20bb-11e9-b352-a4badbf92501','00796898-20bb-11e9-b352-a4badbf92502'] + # Edisio bureau #BTNS = ['c4b33536-c314-11e8-a5d6-000673742b01','c4b33536-c314-11e8-a5d6-000673742b03','c4b33536-c314-11e8-a5d6-000673742b05', @@ -21,6 +27,8 @@ AQUARA=['1ec6bbd0-20b5-11e9-b352-a4badbf92500'] SHUTERS=['e4b05165-be5d-46d5-acd0-4da7be1158ed','2fe70f46-3ece-44d1-af34-2d82e10fb854'] +SIRENS =['980a639c-20b1-11e9-8d70-a4badbf92501',] + LAMPS_A = [LAMPS[0], LAMPS[2], LAMPS[5]] LAMPS_B = [LAMPS[1], LAMPS[3], LAMPS[4]] @@ -75,12 +83,45 @@ def handle_msg(msg): #send([SHUTERS[1],],'down') pass + if msg.source == SDB[0]: + send([LAMPS[3],],'toggle') + + if msg.source == SCEN[0]: + "soirée TV" + send([SHUTERS[0]],'down') + send(LAMPS,'off') + send(SPOTS,'on') + send([SHUTERS[1]],'down') + + if msg.source == SCEN[1]: + "Début journée" + send([SHUTERS[0]],'up') + send([LAMPS[3],],'on') + send(SPOTS,'off') + send([SHUTERS[1]],'up') + + if msg.source == SCEN[2]: + "stop" + send([SHUTERS[0]],'stop') + send([SHUTERS[1]],'stop') + send(SIRENS,'stop') + if msg.action == 'double_click': if msg.source in AQUARA: send([SHUTERS[0],],'stop') send([SHUTERS[1],],'stop') + send(SIRENS,'stop') + + if msg.action == 'attributesChange': + #print(msg) + if msg.source == 'd9993018-20b1-11e9-a250-a4badbf92500': + pres = msg.body.get('presence') + light = mon.devices.get_with_addr(LAMPS[3]).attributes.get('light') + print("pres & light %s/%s" % (pres,light)) + if pres == False and light == True: + send(SIRENS,'play') + print('Alarme..') - def main(): global dev global mon @@ -94,6 +135,6 @@ def main(): if __name__ == '__main__': try: - main() + eng = main() except KeyboardInterrupt: print('Bye bye') -- GitLab