From a1ba77f8de5b0951af71aa9b919a6f6d7cccb9df Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Fri, 11 Oct 2013 07:06:19 +0000 Subject: [PATCH] play-sound-status --- play-sound-status.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/play-sound-status.py b/play-sound-status.py index 709507b..151ce52 100755 --- a/play-sound-status.py +++ b/play-sound-status.py @@ -13,8 +13,8 @@ import types import ConfigParser import traceback import random -import json import zmq +import zmq.utils.jsonapi as json logger = logging.getLogger() logger.setLevel(logging.INFO) @@ -332,7 +332,12 @@ while True: zmqctx = zmq.Context() zmqctx.linger = 0 zmqsub = zmqctx.socket(zmq.SUB) - zmqsub.setsockopt(zmq.SUBSCRIBE, "") + zmqsub.setsockopt(zmq.SUBSCRIBE, "DoorCommandEvent") + zmqsub.setsockopt(zmq.SUBSCRIBE, "PresenceUpdate") + zmqsub.setsockopt(zmq.SUBSCRIBE, "BoreDoomButtonPressEvent") +# zmqsub.setsockopt(zmq.SUBSCRIBE, "MovementSensorUpdate") + zmqsub.setsockopt(zmq.SUBSCRIBE, "DoorAjarUpdate") + zmqsub.setsockopt(zmq.SUBSCRIBE, "DoorProblemEvent") zmqsub.connect(uwscfg.broker_uri) last_status=None @@ -351,12 +356,14 @@ while True: unixts_last_presence=time.time() last_status=dictdata["Present"] unixts_panic_button=None - last_user=m.group(3) if ( time.time() - unixts_last_movement ) <= float(uwscfg.tracker_secs_movement_before_presence_to_launch_event): unixts_last_movement=0 if last_status: playThemeOf(user=last_user, fallback_default="DEFAULT") continue + elif structname == "DoorCommandEvent": + last_user = dictdata["Who"] + continue elif structname == "BoreDoomButtonPressEvent": playThemeOf(user="PANIC", fallback_default="nothing") continue @@ -379,4 +386,4 @@ while True: zmqctx.destroy() except: pass - time.sleep(5) \ No newline at end of file + time.sleep(5) -- 1.7.10.4