Install Fakeroku on Node-RED
Open the Node-RED Menu in the top right corner and click on Manage Palette. There switch to the Install tab and search for fakeroku
and install the node-red-contrib-fakeroku:
Now add a Fakeroku node to your flow and configure it as follows:
The IP address has to be set to the LAN IP of your Node-RED installation - in my case 192.168.2.111
, you can keep the default port and multicast IP and click the + icon to generate a UUID for your device.
You can now switch back to the general tutorial to add the virtual device to your Logitech Harmony Hub.
INSTAR MQTT Setup
The Fakeroku virtual device will now give you access to the following buttons on your Harmony Remote:
For example Button 1 will send the payload string Rev to Node-RED when you press it. In the following I want to connect it to a Node-RED flow that allows me to cycle through the first 4 preset positions of my Pan&Tilt camera. Here is the complete list of actions that the complete flow will add:
Rev
- Go to last Preset PositionPlay
- Start ax
Second Video RecordingFwd
- Go to next Preset PositionHome
- Deactivate the AlarmUp
- Move Camera Up by one StepRight
- Move Camera Right by one StepDown
- Move Camera Down by one StepLeft
- Move Camera Left by one StepSelect
- Stop Camera MovementBack
- Activate the AlarmInfo
- Trigger enabled Alarm Actions
The flow needed for those actions looks like this and can be downloaded and imported to Node-RED from the JSON export pasted in below:
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}]
* see also INSTAR MQTT & Node-RED
Cycling through Preset Positions
This sequence listens to the Fwd and Rev button on your remote and uses the following scripts to cycle through your first 4 preset positions of your Pan&Tilt camera. The first part just counts from 0
to 3
(Note that we need an initialization step here to set this count to 0
every time we restart Node-RED):
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;
}
}
And the second script just sets the result of this calculation to msg.payload
:
msg.payload = flow.get("counter") || 0;
return msg;
This is then fed into an MQTT node to be send to your camera's MQTT broker to update the "Go to Preset" MQTT Topic.
Pan & Tilt your Camera
This sequence listens to the Up, Right, Down and Left button and updates the according "One-Step" MQTT Topics on your camera:
Arm your Alarm before your leave your Home
This sequence defines an armed and disarmed state for your camera. When armed your camera will keep an eye on your living room. When disarmed your camera will turn away and deactivates all motion detection areas. Note that if you are using the camera's internal PIR motion sensor in combination with those detection areas, you will have to deactivate the sensor as well for this to work:
Start a Manual Video Recording
This sequence enables you to start a manual video recording when pressing the Play button on your remote. Note that the delay node is currently set to 30s - you can adjust the length of your according by changing this value:
Trigger an Alarm
And now to the simplest sequence of this flow. Pressing the Info button will trigger an alarm on your camera. This event will trigger all active alarm actions on your camera - like vide recordings, email notifications, FTP uploads, etc.:
Conclusion
This is just a small overview over all the available MQTT Topics on your camera. All of them can be send and combined with a press of a button on your Logitech Harmony Remote. More information for using the INSTAR MQTT interface with Node-RED can be found in our full tutorial.