Software

Home Automation

Logitech Harmony with Node-RED

Fakeroku auf Node-RED installieren

Öffnen Sie das Node-RED Menü in der oberen rechten Ecke und klicken Sie auf Palette verwalten. Wechseln Sie dort auf den Reiter Install und suchen Sie nach fakeroku und installieren Sie node-red-contrib-fakeroku:

Logitech Harmony MQTT Control with Node-RED

Fügen Sie nun einen Fakeroku-Knoten zu Ihrem Flow hinzu und passen Sie ihn wie folgt an:

Logitech Harmony MQTT Control with Node-RED

Die IP-Adresse muss auf die LAN-IP Ihrer Node-RED-Installation eingestellt werden - in meinem Fall 192.168.2.111.Sie können den Standardport und die Multicast-IP beibehalten und auf das Symbol + klicken, um eine UUID für Ihr Gerät zu generieren.

Sie können jetzt wieder zum allgemeinen Tutorial zum Hinzufügen des virtuellen Geräts zu Ihrem Logitech Harmony Hub wechseln.

INSTAR MQTT Setup

Das virtuelle Fakeroku Gerät gibt Ihnen nun Zugriff auf die folgenden Tasten Ihrer Harmony-Fernbedienung:

Logitech Harmony MQTT Control with Node-RED

Zum Beispiel sendet Button 1 die Payload-Zeichenkette Rev an Node-RED, wenn Sie sie drücken. Im Folgenden möchte ich dies mit einem Node-RED-Flow verbinden, der es mir erlaubt, die ersten 4 voreingestellten Positionen meiner Schwenk- und Neigekamera zu durchlaufen. Hier ist die vollständige Liste der Aktionen, die der komplette Ablauf hinzufügen wird:

  1. Rev - Zur letzten Preset Position gehen
  2. Play - Starte eine x Sekunden Videoaufnahme
  3. Fwd - Zur nächsten Preset Position gehen
  4. Home - Deaktiviere den Alarm
  5. Up - Bewege die Kamera einen Schritt nach oben
  6. Right - Bewege die Kamera einen Schritt nach rechts
  7. Down - Bewege die Kamera einen Schritt nach unten
  8. Left - Bewege die Kamera einen Schritt nach links
  9. Select - Stoppe die Bewegung der Kamera
  10. Back - Aktiviere den Alarm
  11. Info - Auslöser aktivierte Alarm-Aktionen

Der für diese Aktionen benötigte Flow sieht wie folgt aus und kann über den unten eingefügten JSON-Export heruntergeladen und in Node-RED importiert werden:

Logitech Harmony MQTT Control with Node-RED

Node-RED Flow Download

[{"id":"a7f685cf.720f58","type":"fakeroku-device","z":"1dfd915c.6102cf","confignode":"5699281e.1bbbc8","x":80,"y":180,"wires":[["f5aa6aa6.abeb78","3befcb89.667824","625b1ba9.24a254","62de79f2.f75328","1a8d0caa.b38743"]]},{"id":"f5aa6aa6.abeb78","type":"switch","z":"1dfd915c.6102cf","name":"PTZ","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Up","vt":"str"},{"t":"eq","v":"Down","vt":"str"},{"t":"eq","v":"Left","vt":"str"},{"t":"eq","v":"Right","vt":"str"},{"t":"eq","v":"Select","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":286,"y":332,"wires":[["709a2dd0.a05e24"],["2b4c510.d949db"],["c4363ae8.54ee58"],["edf366d8.120318"],["ce60b71c.910af8"]]},{"id":"686b53b1.dee5fc","type":"mqtt out","z":"1dfd915c.6102cf","name":"features/ptz/movestep","topic":"instar/local/features/ptz/movestep/raw","qos":"1","retain":"","broker":"fbc900bc.b83bb","x":627,"y":332,"wires":[]},{"id":"709a2dd0.a05e24","type":"change","z":"1dfd915c.6102cf","name":"up","rules":[{"t":"set","p":"payload","pt":"msg","to":"up","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":415,"y":252,"wires":[["686b53b1.dee5fc"]]},{"id":"2b4c510.d949db","type":"change","z":"1dfd915c.6102cf","name":"down","rules":[{"t":"set","p":"payload","pt":"msg","to":"down","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":415,"y":292,"wires":[["686b53b1.dee5fc"]]},{"id":"c4363ae8.54ee58","type":"change","z":"1dfd915c.6102cf","name":"left","rules":[{"t":"set","p":"payload","pt":"msg","to":"left","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":415,"y":332,"wires":[["686b53b1.dee5fc"]]},{"id":"edf366d8.120318","type":"change","z":"1dfd915c.6102cf","name":"right","rules":[{"t":"set","p":"payload","pt":"msg","to":"right","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":415,"y":372,"wires":[["686b53b1.dee5fc"]]},{"id":"edd8e86c.1a00e8","type":"inject","z":"1dfd915c.6102cf","name":"Activate","topic":"","payload":"","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":605,"y":231,"wires":[["48e05d12.6b8d84"]]},{"id":"48e05d12.6b8d84","type":"change","z":"1dfd915c.6102cf","name":"Initialize","rules":[{"t":"set","p":"counter","pt":"flow","to":"-1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":745,"y":231,"wires":[[]]},{"id":"ac59a9a4.a61318","type":"function","z":"1dfd915c.6102cf","name":"Counter","func":"var status = msg.payload;\n\nvar counter = flow.get(\"counter\") || 0;\n\nif (status == \"Fwd\")\n    {\n        \n        if (counter < 3)\n        {\n            counter = counter + 1;\n            flow.set(\"counter\",counter);\n            return msg;\n        }\n        else\n        {\n            counter = 0;\n            flow.set(\"counter\",counter);\n            return msg;\n            \n        }\n    }\n    \nelse {\n        \n    if (counter > 0)\n    {\n        counter = counter - 1;\n        flow.set(\"counter\",counter);\n        return msg;\n    }\n    else\n    {\n        counter = 3;\n        flow.set(\"counter\",counter);\n        return msg;\n    }\n}\n\n ","outputs":1,"noerr":0,"x":412,"y":182,"wires":[["e4ae5134.3976c"]]},{"id":"3befcb89.667824","type":"switch","z":"1dfd915c.6102cf","name":"FWD/REV","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Fwd","vt":"str"},{"t":"eq","v":"Rev","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":272,"y":180,"wires":[["ac59a9a4.a61318"],["ac59a9a4.a61318"]]},{"id":"7f883c84.232894","type":"mqtt out","z":"1dfd915c.6102cf","name":"features/ptz/preset","topic":"instar/local/features/ptz/preset/raw","qos":"1","retain":"","broker":"fbc900bc.b83bb","x":718,"y":182,"wires":[]},{"id":"e4ae5134.3976c","type":"function","z":"1dfd915c.6102cf","name":"Position","func":"msg.payload = flow.get(\"counter\") || 0;\n\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":182,"wires":[["7f883c84.232894"]]},{"id":"625b1ba9.24a254","type":"switch","z":"1dfd915c.6102cf","name":"Home/Back","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Home","vt":"str"},{"t":"eq","v":"Back","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":277,"y":478,"wires":[["c3149921.424398"],["ecee0588.bb37f8"]]},{"id":"c3149921.424398","type":"change","z":"1dfd915c.6102cf","name":"1","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":416,"y":460,"wires":[["d25c7f9e.b86d9","e28db00c.de5f7","32defe83.1910e2","5514217a.15a4","e5a74104.f5b2d"]]},{"id":"ecee0588.bb37f8","type":"change","z":"1dfd915c.6102cf","name":"0","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":416,"y":500,"wires":[["e5a74104.f5b2d","5514217a.15a4","32defe83.1910e2","e28db00c.de5f7","d25c7f9e.b86d9"]]},{"id":"e28db00c.de5f7","type":"mqtt out","z":"1dfd915c.6102cf","name":"alarm/area1/enable","topic":"instar/local/alarm/area1/enable/raw","qos":"","retain":"","broker":"fbc900bc.b83bb","x":632,"y":447,"wires":[]},{"id":"32defe83.1910e2","type":"mqtt out","z":"1dfd915c.6102cf","name":"alarm/area2/enable","topic":"instar/local/alarm/area2/enable/raw","qos":"","retain":"","broker":"fbc900bc.b83bb","x":632,"y":493,"wires":[]},{"id":"5514217a.15a4","type":"mqtt out","z":"1dfd915c.6102cf","name":"alarm/area3/enable","topic":"instar/local/alarm/area3/enable/raw","qos":"","retain":"","broker":"fbc900bc.b83bb","x":632,"y":539,"wires":[]},{"id":"e5a74104.f5b2d","type":"mqtt out","z":"1dfd915c.6102cf","name":"alarm/area4/enable","topic":"instar/local/alarm/area4/enable/raw","qos":"","retain":"","broker":"fbc900bc.b83bb","x":632,"y":585,"wires":[]},{"id":"d25c7f9e.b86d9","type":"mqtt out","z":"1dfd915c.6102cf","name":"features/ptz/preset","topic":"instar/local/features/ptz/preset/raw","qos":"1","retain":"","broker":"fbc900bc.b83bb","x":633,"y":400,"wires":[]},{"id":"62de79f2.f75328","type":"switch","z":"1dfd915c.6102cf","name":"Play","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Play","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":253,"y":644,"wires":[["bbdd25c2.7ca7e8","cc56f3e2.29cfb"]]},{"id":"782bc830.959dc8","type":"mqtt out","z":"1dfd915c.6102cf","name":"features/manualrec/start","topic":"instar/local/features/manualrec/start/raw","qos":"1","retain":"","broker":"fbc900bc.b83bb","x":612,"y":644,"wires":[]},{"id":"bbdd25c2.7ca7e8","type":"change","z":"1dfd915c.6102cf","name":"{\"val\":\"60\"}","rules":[{"t":"set","p":"payload","pt":"msg","to":"60","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":412,"y":644,"wires":[["782bc830.959dc8"]]},{"id":"cc56f3e2.29cfb","type":"delay","z":"1dfd915c.6102cf","name":"30s","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":248,"y":690,"wires":[["9a762fde.748ff"]]},{"id":"21d78cf6.3df984","type":"mqtt out","z":"1dfd915c.6102cf","name":"features/manualrec/stop","topic":"instar/local/features/manualrec/stop/raw","qos":"1","retain":"","broker":"fbc900bc.b83bb","x":612,"y":690,"wires":[]},{"id":"9a762fde.748ff","type":"change","z":"1dfd915c.6102cf","name":"{\"val\":\"off\"}","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":408,"y":690,"wires":[["21d78cf6.3df984"]]},{"id":"ce60b71c.910af8","type":"change","z":"1dfd915c.6102cf","name":"right","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":415,"y":411,"wires":[["686b53b1.dee5fc"]]},{"id":"1a8d0caa.b38743","type":"switch","z":"1dfd915c.6102cf","name":"Info","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Info","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":231,"y":764,"wires":[["d6fd272a.1b92f8"]]},{"id":"94d84f16.62437","type":"mqtt out","z":"1dfd915c.6102cf","name":"alarm/pushalarm","topic":"instar/local/alarm/pushalarm/raw","qos":"1","retain":"","broker":"fbc900bc.b83bb","x":627,"y":764,"wires":[]},{"id":"d6fd272a.1b92f8","type":"change","z":"1dfd915c.6102cf","name":"1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":379,"y":764,"wires":[["94d84f16.62437"]]},{"id":"5699281e.1bbbc8","type":"fakeroku-config","z":"","ip":"192.168.2.111","multicast":"239.255.255.250","uuid":"68580784e7ec5daf8d50f26874628384","port":"8086"},{"id":"fbc900bc.b83bb","type":"mqtt-broker","z":"","name":"192.168.2.117 (PrivCert)","broker":"192.168.2.117","port":"8883","tls":"d525c1aa.03cac","clientid":"nodered","usetls":true,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"d525c1aa.03cac","type":"tls-config","z":"","name":"192.168.2.117 (PrivCert)","cert":"","key":"","ca":"","certname":"client.pem","keyname":"","caname":"","servername":"","verifyservercert":false}]

* sehen Sie auch INSTAR MQTT & Node-RED

Durchschalten der voreingestellte Positionen

Logitech Harmony MQTT Control with Node-RED

Diese Sequenz hört auf die Tasten Fwd und Rev auf Ihrer Fernbedienung und verwendet die folgenden Skripte, um die ersten 4 voreingestellten Positionen Ihrer Pan&Tilt Kamera zu durchlaufen. Der erste Teil zählt einfach von 0 bis 3 (Beachten Sie, dass wir hier einen Initialisierungsschritt benötigen, um diesen Zähler jedes Mal auf 0 zu setzen, wenn wir Node-RED neu starten):

var status = msg.payload;

var counter = flow.get("counter") || 0;

if (status == "Fwd")
    {
        if (counter < 3)
        {
            counter = counter + 1;
            flow.set("counter",counter);
            return msg;
        }
        else
        {
            counter = 0;
            flow.set("counter",counter);
            return msg;
        }
    }
else {
      if (counter > 0)
    {
        counter = counter - 1;
        flow.set("counter",counter);
        return msg;
    }
    else
    {
        counter = 3;
        flow.set("counter",counter);
        return msg;
    }
}

Und das zweite Skript setzt das Ergebnis dieser Berechnung einfach auf msg.payload:

msg.payload = flow.get("counter") || 0;

return msg;

Diese wird dann in einen MQTT-Knoten eingespeist, um das "Gehe auf Position" MQTT-Topic zu aktualisieren.

Schwenken und Neigen der Kamera

Diese Sequenz hört auf die Schaltflächen oben, rechts, unten und links und aktualisiert das entsprechenden Pan&Tilt MQTT-Topic) auf Ihrer Kamera:

Logitech Harmony MQTT Control with Node-RED

Schalten Sie Ihren Alarm scharf, bevor Sie Ihr Haus verlassen

Diese Sequenz aktiviert/deaktiviert den Alarm auf Ihrer Kamera. Wenn sie scharf gestellt ist, behält Ihre Kamera Ihr Wohnzimmer im Auge. Wenn der Alarm deaktiviert wird, dreht sich die Kamera zur Seite und deaktiviert alle Bewegungserkennungsbereiche. Hinweis: Wenn Sie den kamerainternen PIR-Bewegungssensor in Kombination mit diesen Erfassungsbereichen verwenden, müssen Sie den Sensor ebenfalls deaktivieren, damit dies funktioniert:

Logitech Harmony MQTT Control with Node-RED

Starten Sie eine manuelle Videoaufzeichnung

Diese Sequenz ermöglicht es Ihnen, eine manuelle Videoaufnahme zu starten, wenn Sie die Play-Taste auf Ihrer Fernbedienung drücken. Beachten Sie, dass der Verzögerungsknoten derzeit auf 30 Sekunden eingestellt ist. Sie können die Länge der Aufnahme durch Ändern dieses Wertes anpassen:

Logitech Harmony MQTT Control with Node-RED

Einen Alarm auslösen

Und nun zur einfachsten Sequenz dieses Flows. Durch Drücken der Taste Info wird ein Alarm auf Ihrer Kamera ausgelöst. Dieses Ereignis löst alle aktiven Alarmaktionen auf Ihrer Kamera aus - wie z.B. die Videoaufzeichnungen, E-Mail-Benachrichtigungen, FTP/Cloud-Uploads usw.:

Logitech Harmony MQTT Control with Node-RED

Schlussfolgerung

Dies ist nur ein kleiner Überblick aller verfügbaren MQTT-Topics auf Ihrer Kamera. Alle diese Topics können mit einem Tastendruck auf Ihrer Logitech Harmony-Fernbedienung kombiniert und gesendet werden. Weitere Informationen zur Verwendung der INSTAR MQTT-Schnittstelle mit Node-RED finden Sie in unserem vollständigen Tutorial.

Troubleshooting (Firewall Homematic CCU3)

Stellen Sie immer sicher, dass Ihre Fakeroku-Instanz auf Ihrer tatsächlichen Netzwerkschnittstelle lauscht, z. B. 192.168.2.111 anstelle von allen Schnittstellen 0.0.0.0. Wenn Sie eine Firewall auf Ihrem Node-RED-Host-System verwenden, stellen Sie außerdem sicher, dass Sie den HTTP-Port speziell für diese Schnittstelle öffnen. Im folgenden Beispiel zeigen wir die Firewall-Konfiguration für die Homematic CCU3-Firewall:

Logitech Harmony MQTT Control with Node-RED

INSTAR Forum

Diskutieren Sie diesen Artikel im INSTAR Forum !