INSTAR Deutschland GmbHINSTAR Deutschland GmbH

MQTT Alarmserver als Lichtschalter



Q: Ich möchte den PIR-Sensor der Kamera nutzen, um den Bewegungserkennungsbereich 1 einzuschalten und den Bereich mit dem PIR-Sensor zu koppeln. Nun möchte ich nur, wenn beide - der PIR und Bereich1 - ausgelöst werden, ein Außenlicht vor meinem Haus einschalten.

A: Hier ist ein Beispiel, wie dieses Problem in Node-RED mit dem MQTT Alarmserver gelöst werden kann.

INSTAR MQTT Alarmserver as Lightswitch

Das PIR wird ausgelöst, indem es das MQTT-Topic alarm/triggered mit einem Payload-Wert von 5 aktualisiert. Ich verwende nun diesen Auslöser, um den Bereich1 alarm/area1/enable einzuschalten und ihn mit dem PIR alarm/actions/linkareas zu verknüpfen. Beides wird wieder deaktiviert, sobald der Alarmserver mit einem Payload-Wert von 0 in den Leerlauf zurückfällt - dies geschieht nach 5 Sekunden, was für Ihren Anwendungsfall vielleicht ein bisschen zu schnell ist. Sie können dies durch einen eigenen Timer ersetzen.

Sobald Bereich1 aktiv und verknüpft ist, wird der nächste Alarmauslöser den Wert 7 haben (PIR + Bereich1 ausgelöst). Dieser Auslöser wird dann verwendet, um ein Licht einzuschalten, das ebenfalls mit Node-RED verbunden ist - diese Implementierung ist nicht Teil des Beispiel Flows.

Node-RED Flow Export

[{"id":"52d8de5c.878f4","type":"tab","label":"INSTAR Alarmserver","disabled":false,"info":""},{"id":"a071baf8.e4db18","type":"mqtt in","z":"52d8de5c.878f4","name":"status/alarm/triggered","topic":"cameras/117/status/alarm/triggered","qos":"1","datatype":"auto","broker":"7553a41d.22b8bc","x":107,"y":76,"wires":[["27e5d697.4c750a","a076e8c3.98bbd8"]]},{"id":"a076e8c3.98bbd8","type":"debug","z":"52d8de5c.878f4","name":"Alarmserver","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":297,"y":25,"wires":[]},{"id":"27e5d697.4c750a","type":"switch","z":"52d8de5c.878f4","name":"0 / 5 / 7","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"{\"val\":\"0\"}","vt":"str"},{"t":"eq","v":"{\"val\":\"5\"}","vt":"str"},{"t":"eq","v":"{\"val\":\"7\"}","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":287,"y":76,"wires":[["472c5b6d.4e03d4","a4e93b6b.595ed8"],["d1f7562c.1d9bf8","7bddd11d.f8ee2"],["b09b8001.82bf7"]]},{"id":"a4e93b6b.595ed8","type":"change","z":"52d8de5c.878f4","name":"0","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"val\":\"0\"}","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":462,"y":81,"wires":[["3778f880.f4f898"]]},{"id":"b635569a.0f6418","type":"mqtt out","z":"52d8de5c.878f4","name":"alarm/actions/linkareas","topic":"cameras/117/alarm/actions/linkareas","qos":"1","retain":"false","broker":"7553a41d.22b8bc","x":669,"y":68,"wires":[]},{"id":"472c5b6d.4e03d4","type":"change","z":"52d8de5c.878f4","name":"off","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"val\":\"off\"}","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":462,"y":43,"wires":[["b635569a.0f6418"]]},{"id":"b09b8001.82bf7","type":"change","z":"52d8de5c.878f4","name":"fiat lux","rules":[{"t":"set","p":"payload","pt":"msg","to":"fiat lux","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":459,"y":198,"wires":[["eb589db.cc37e6"]]},{"id":"eb589db.cc37e6","type":"debug","z":"52d8de5c.878f4","name":"Light Switch","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":599,"y":198,"wires":[]},{"id":"7bddd11d.f8ee2","type":"change","z":"52d8de5c.878f4","name":"1","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"val\":\"1\"}","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":462,"y":156,"wires":[["3778f880.f4f898"]]},{"id":"d1f7562c.1d9bf8","type":"change","z":"52d8de5c.878f4","name":"on","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"val\":\"on\"}","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":462,"y":118,"wires":[["b635569a.0f6418"]]},{"id":"3778f880.f4f898","type":"mqtt out","z":"52d8de5c.878f4","name":"alarm/area1/enable","topic":"cameras/117/alarm/area1/enable","qos":"1","retain":"false","broker":"7553a41d.22b8bc","x":650,"y":115,"wires":[]},{"id":"7553a41d.22b8bc","type":"mqtt-broker","name":"192.168.2.117","broker":"192.168.2.117","port":"8883","tls":"c411fab7.e16228","clientid":"","usetls":true,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"c411fab7.e16228","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"mqtt_client-new.crt","keyname":"","caname":"","servername":"","verifyservercert":false}]