X-Git-Url: https://git.realraum.at/?p=svn42.git;a=blobdiff_plain;f=bridge-old-sensors-zmq.py;h=6f065d147c2a3fe830d98eefe7316d3de61d88a4;hp=66de9afee109109d857759a8c711f349ea8e9be6;hb=2c075d279f61bf548e22b2715d82d58fc1f16f76;hpb=123fe81b6402de719f54e1dff5c84485236e2a2d diff --git a/bridge-old-sensors-zmq.py b/bridge-old-sensors-zmq.py index 66de9af..6f065d1 100755 --- a/bridge-old-sensors-zmq.py +++ b/bridge-old-sensors-zmq.py @@ -142,7 +142,8 @@ def trackSensorStatus(uwscfg, zmqsocket): global sshp, tracksensor_running RE_TEMP = re.compile(r'temp(\d): (\d+\.\d+)') RE_PHOTO = re.compile(r'photo(\d): [^0-9]*?(\d+)',re.I) - RE_MOVEMENT = re.compile(r'movement|button\d?|PanicButton',re.I) + RE_MOVEMENT = re.compile(r'movement',re.I) + RE_BUTTON = re.compile(r'button\d?|PanicButton',re.I) RE_ERROR = re.compile(r'Error: (.+)',re.I) while tracksensor_running: uwscfg.checkConfigUpdates() @@ -170,6 +171,10 @@ def trackSensorStatus(uwscfg, zmqsocket): if len(line) < 1: raise Exception("EOF on Subprocess, daemon seems to have quit, returncode: %d",sshp.returncode) logging.debug("trackSensorStatus: Got Line: " + line) + m = RE_BUTTON.match(line) + if not m is None: + sendR3Message(zmqsocket, "BoreDoomButtonPressEvent", {"Ts":int(time.time())}) + continue m = RE_MOVEMENT.match(line) if not m is None: sendR3Message(zmqsocket, "MovementSensorUpdate", {"Sensorindex":0, "Ts":int(time.time())}) @@ -216,6 +221,11 @@ def exitHandler(signum, frame): except: pass time.sleep(0.1) + try: + zmqpub.close() + zmqctx.destroy() + except: + pass sys.exit(0) #signals proapbly don't work because of readline @@ -235,10 +245,12 @@ else: zmqctx = zmq.Context() zmqctx.linger = 0 zmqpub = zmqctx.socket(zmq.PUB) -zmqpub.connect("tcp://wuzzler.realraum.at:4243") +zmqpub.connect("tcp://torwaechter.realraum.at:4243") #listen for sensor data and forward them trackSensorStatus(uwscfg, zmqpub) +zmqpub.close() +zmqctx.destroy()