MQTT Sensor Video Overlay
Q: Ich verwende einen MQTT/Zigbee/Z-Wave-Sensor und möchte dessen Messwerte als Overlay über dem Videobild meiner Kamera anzeigen. Ist es möglich, einen Datenstrom zum Videobild meiner Kamera hinzuzufügen?
A: Hier ist ein Beispiel, wie dieses Problem in Node-RED über die INSTAR MQTT Schnittstelle und dem Bild-Overlay gelöst werden kann.
Aktivieren des Overlays
Im obigen Beispiel habe ich eine Option zum Aktivieren und Deaktivieren des Sensor-Overlays über das multimedia/overlay/showname
MQTT-Topic hinzugefügt. Sie können die Inject Nodes durch eingehende Trigger ersetzen - zum Beispiel, wenn die Sensorauslesung einen sicheren Wert überschreitet:
Node-RED Flow Export
[{"id":"fe5510d0.fada1","type":"mqtt out","z":"9c94ad40.eea84","name":"multimedia/overlay/showname","topic":"cameras/117/multimedia/overlay/showname","qos":"1","retain":"false","broker":"7553a41d.22b8bc","x":319,"y":58,"wires":[]},{"id":"e3f4cbf0.f0d0d8","type":"inject","z":"9c94ad40.eea84","name":"OFF","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"val\":\"0\"}","payloadType":"json","x":110,"y":80,"wires":[["fe5510d0.fada1"]]},{"id":"46aa340.db0f0cc","type":"inject","z":"9c94ad40.eea84","name":"ON","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"val\":\"1\"}","payloadType":"json","x":110,"y":40,"wires":[["fe5510d0.fada1"]]},{"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}]
Hinzufügen des Datenstroms
Ich verwende einen Zufallszahlengenerator, um die Sensorauslesung zu simulieren. Die Auslesung wird dann als Payload an einen MQTT Out Knoten für das MQTT-Topic multimedia/overlay/cameraname
gesendet - wodurch der Kameraname im Kamerabild durch die Sensorauslesung ersetzt wird.
Node-RED Flow Export
[{"id":"ad54e87a.837728","type":"mqtt out","z":"9c94ad40.eea84","name":"multimedia/overlay/cameraname","topic":"cameras/117/multimedia/overlay/cameraname","qos":"1","retain":"false","broker":"7553a41d.22b8bc","x":471,"y":122,"wires":[]},{"id":"a4fdb5a5.dd1ee8","type":"function","z":"9c94ad40.eea84","name":"Sensor","func":"random=Math.round(Math.log(Math.floor(Math.random() * 100) + 1) * 1000) / 1000;\nmsg.payload='{\"val\":\"Rad%3A%20'+ random + '%20Bq\"}'\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":253,"y":122,"wires":[["ad54e87a.837728"]]},{"id":"7c6c476.68d89b8","type":"inject","z":"9c94ad40.eea84","name":"Intervall","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":110,"y":122,"wires":[["a4fdb5a5.dd1ee8"]]},{"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}]
Overlay Position
Wenn Sie das Overlay am unteren Rand des Bildes positionieren müssen, können Sie dazu den folgenden CGI SET-Befehl verwenden:
/param.cgi?cmd=setoverlayattr&-region=1&-show=1&-name=Rad%3A%204.563%20Bq&-place=1
/param.cgi?cmd=setoverlayattr&-region=1&-show=1&-name=Rad%3A%204.563%20Bq&-place=0
Der Parameter place platziert das Overlay entweder oben oder unten am linken Rand des Videobildes. Um die aktuelle Einstellung auszulesen, können Sie den folgenden GET-Befehl verwenden:
/param.cgi?cmd=getoverlayattr&-region=1