INSTAR Deutschland GmbH

Homematic CCU3 Hub and RedMatic

Add sensors to the control panel

In order to be able to control your INSTAR IP camera with Homematic sensors both have to be integrated via the Homematic WebUI. To do this, proceed as follows:

  1. Start the WebUI user interface inside your web browser.
  2. Click on the "Teach in devices" button in the upper right area of the browser window.

Homematic CCU3


  1. Activate the appropriate teach-in mode for the device that you want to add. More information can be found in the respective operating manual.

Homematic CCU3


  1. Wait for the teach-in process to complete. To confirm the successful teach-in process, the LED of the device lights up green. If the LED is red, try again.
  2. After a short while, the newly trained device appears in the inbox of your WebUI.

Homematic CCU3


Creating system variables and programs

In order to communicate with our sensors - in order to install the Homematic Funk-Bewegungsmelder, außen and trigger a system alert on motion, we need to create a system variable:


Homematic CCU3


Click on New below to create a new variable:


Homematic CCU3


Enter the following here to create a system variable named PIR Sensor, then click on Ok and in the following list click on Programs:


Homematic CCU3

Homematic CCU3


In the following window click on New again - here we can now configure and confirm the following program:


Homematic CCU3


If we now trigger a motion detection, we will receive an alarm message:


Homematic CCU3


Installing Node-RED

We have already worked with Node-RED and in conjunction with the MQTT protocol automated our IP Camera. Node-RED is very easy to install on the Homematic control panel using the RedMatic addon.

RedMatic combines several software components into one CCU add-on, a software package that can be conveniently installed on a Homematic CCU3 as additional software via the WebUI.

The Node-RED version installed comes with the CCU nodes for Node-RED, making it possible to implement rules, automation's, scripts and connections of external services and systems for a homematic system in a simple, visual way - and this largely without any programming knowledge.

The visualization and control includes RedMatic WebApp and Node-RED Dashboard. RedMatic WebApp is a user interface that can be used immediately without further configuration.

  1. First, we need to download the latest version from Github. You need the file redmatic-<version>.tar.gz:

Homematic CCU3


  1. In the Homematic WebUI, go to Control Panel Add-on Software:

Homematic CCU3

Homematic CCU3


  1. Select and install the downloaded file (can take up to 10min):

Homematic CCU3

Homematic CCU3


  1. Then wait until the CCU restarts - patience is required. The installation of RedMatic takes some time. Node-RED will be reachable under http://<ccu-adresse>/addons/red. And the Node-RED Dashboard under http://<ccu-adresse>/addons/red/ui:

Homematic CCU3

Homematic CCU3


The default login is Admin (with a capital A) and the admin password on your CCU3!

You can also manually set the password under Control Panel / Additional Software - change the authentication from ReGaHSS to Credentials:


Homematic CCU3

Homematic CCU3


Installation of an MQTT server

MQTT is a communication protocol developed specifically for IoT devices offering some benefits over regular _HTTP__ communication. However, it is a bit complicated to set up under Windows or a Raspberry Pi, as it requires an extra MQTT server. Fortunately, this is just as easy with the homematic center as the installation of Node-RED.

Nevertheless, the use of the MQTT protocol is purely optional. For the examples we will give below it is not needed (you can also replace the used MQTT nodes with link nodes and get the same result!). MQTT becomes important the moment you have another home automation systems, e.g. OpenHAB or ioBroker or want to use thirdparty sensors, which can not be integrated directly into Homematic. MQTT, in conjunction with Node-RED, can be the link that brings together all the building blocks of your automation.

In order to use the MQTT protocol with the Homematic, we have to use the Mosquitto server addon for the Homematic CCU3. Go to the Release page on Github and download the latest mosquitto- <version> .tar.gz file there. You can then install it under System Control / Additional Software in the WebUI of the CCU3:


Homematic CCU3


Enabling SSH Access (Optional)

By default Mosquitto listens on the ports 1883/mqtt and 1884/ws. If a certificate is available on the CCU, TLS listener will also be automatically opened (8883/mqtts and 8884/wss).

In addition to the broker, the addon also installs the command line tools mosquitto\pub_ and mosquitto\sub_ and links them to them /usr/local/bin/.

To enable SSH access, go to System Control / Security, activate the service and enter a password. Afterwards the CCU3 has to be restarted:


Homematic CCU3

Homematic CCU3


After rebooting, you can open your terminal - under Windows the free Terminus can be used - to log in to the IP address of your CCU with the user name root and the above set password:


Homematic CCU3


The Mosquitto configuration can be found under /usr/local/addons/mosquitto/etc/conf.d/*.conf. To restart type /etc/config/rc.d/mosquitto restart.

When calling mosquitto\pub_ via CUxD Exec, the call must be preceded by the setting of the lib path, e.g.: LD_LIBRARY_PATH=/usr/local/lib /usr/local/bin/mosquitto_pub -t 'test' -m 'test'


Homematic CCU3


Testing the MQTT server

The SSH access (above) allows the MQTT server to be tested directly on the operating system of the CCU3. In this section we want to connect to the server from a Windows computer. To do this we can use the tool MQTT.fx on Windows 10.

In the user interface, click the gear to add the configuration for the MQTT server to the Homematic CCU:


Homematic CCU3


Enter the IP address of your Homematic control center as Broker Address and keep the port. If you changed the port via SSH or added user authentication in the previous step, you must consider this here:


Homematic CCU3


Confirm the entries and click Connect next to the gear from the previous step. After that, switch to the Subscribe tab underneath, enter a # in the lines next to the Subscribe button and then click the button to subscribe to all MQTT messages that our server receives.


Homematic CCU3


Then go to the Publish tab and enter MQTT Topic - e.g. /test/ - one and below a value - {"val":"1"} - which you want to publish under the topic:


Homematic CCU3


Once you clicked the Publish button go back to the Subscribe Tab, the message should be received from our MQTT server and sent back to MQTT.fx, as we indicated we wanted to be notified about all messages:


Homematic CCU3


If you see this message, the server has been setup correctly and is active on your network.

Remark:

We did not set up a user authentication on the MQTT server. Every device that is connected with your local network can send & receive messages via the server MQTT.

Under no circumstances should you forward the port 1883 inside your router to make the MQTT server accessible over the internet!

If other people besides you have access to the network, you should use the SSH access to your Homematic CCU to add a user authentication to the configuration files of the MQTT server (see above).

Homematic -> INSTAR IP Camera

Now we have made all the preparations to integrate our INSTAR IP camera into the Homematic system. And this can now happen completely over Node-RED, which is much more flexible than the software the Homematic CCU provides. For this we can use the following tutorials, in which we had already carried out this integration:

  1. Node-RED and MQTT Projects
  2. Projekte for the Raspberry Pi
  3. Node-RED under Debian

We can actually recycle them completely with a small supplement, we will use the already pre-installed CCU nodes to query the status of our sensors at the Homematic central. However, the following Node RED flows use a special node named node-red-contrib-string that is not preinstalled in Node-RED. You can install it via the Palette menu.

Homematic Sensors (Motion Detector)

  1. We start by dragging a CCU Value Node onto the workspace and double-clicking on it to open the configuration page.
  2. Select BidCos-RF as an interface to embed your Homematic PIR motion detector.
  3. If you click in the Channel field, you will see all RF devices connected to your Homematic center. When we trained our motion detector to the control panel, we saw that the name of the detector begins with NEQ1545018. We have two entries at our disposal - the first ends at :0 and the second at :1. We'll pick the second one here (if you take the first one and you'll see that there are other variables available, including LOWBAT, which includes a low battery warning that we could include in our Node-RED flows.)
  4. As data point we choose Motion. This will always give us a message payload of true once the sensor has detected a movement.

Homematic CCU3


Now we will always receive a message in Node-RED for motion detections and need to respond to it. We can do this with the following flow, which you can copy and import into Node-RED (this flow includes the configuration of my motion detector - this you have to replace with your newly created one):

[{"id":"1cb03303.2daf2d","type":"ccu-value","z":"654e5181.3b745","name":"PIR Sensor","iface":"BidCos-RF","channel":"NEQ1545018:1 HM-Sen-MDIR-O-2 NEQ1545018:1","datapoint":"MOTION","mode":"","start":true,"change":true,"cache":false,"queue":false,"on":0,"onType":"undefined","ramp":0,"rampType":"undefined","working":false,"ccuConfig":"38263145.35ea0e","topic":"${CCU}/${Interface}/${channel}/${datapoint}","x":90,"y":60,"wires":[["aed51eec.42084"]]},{"id":"560c0d74.11df54","type":"change","z":"654e5181.3b745","name":"Alarm","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"val\":\"triggered\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":368,"y":36,"wires":[["cbb0f690.7d1e18"]]},{"id":"cbb0f690.7d1e18","type":"mqtt out","z":"654e5181.3b745","name":"","topic":"/homematic/pir/alarm","qos":"1","retain":"false","broker":"32d092dd.920b8e","x":554,"y":59,"wires":[]},{"id":"aed51eec.42084","type":"switch","z":"654e5181.3b745","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":240,"y":60,"wires":[["560c0d74.11df54"],["40c14a0b.811054"]]},{"id":"40c14a0b.811054","type":"change","z":"654e5181.3b745","name":"Alarm","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"val\":\"idle\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":368,"y":87,"wires":[["cbb0f690.7d1e18"]]},{"id":"38263145.35ea0e","type":"ccu-connection","z":"","name":"localhost","host":"localhost","regaEnabled":true,"bcrfEnabled":true,"iprfEnabled":true,"virtEnabled":true,"bcwiEnabled":false,"cuxdEnabled":false,"regaPoll":true,"regaInterval":"30","rpcPingTimeout":"60","rpcInitAddress":"127.0.0.1","rpcServerHost":"127.0.0.1","rpcBinPort":"2047","rpcXmlPort":"2048"},{"id":"32d092dd.920b8e","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"nodered","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Homematic CCU3


The output node on the right is an MQTT transmitter. Please make sure that this server is registered to localhost: 1883 - this is the MQTT server we have installed before.


Homematic CCU3


When you click on the red Deploy button and then trigger an alarm on your motion detector, you should see the message {"val":"triggered"} on the MQTT topic /homematic/pir/alarm in MQTT.fx.


Homematic CCU3


INSTAR IP Camera

Now we have to implement this motion message so that it triggers an alarm in our camera. For this we can reuse a flow from one of the previous Node-RED tutorials:


Homematic CCU3


[{"id":"476976cd.d97608","type":"mqtt in","z":"654e5181.3b745","name":"Push Alarm","topic":"ipcam/alarm/pushalarm","qos":"1","broker":"be559f9e.42004","x":90,"y":400,"wires":[["dc4b5e6c.55524"]]},{"id":"dc4b5e6c.55524","type":"function","z":"654e5181.3b745","name":"Alarm","func":"var ip = \"192.168.2.111\";\nvar user = \"admin\";\nvar password = \"instar\";\n\n// Update the status with current timestamp\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd  = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm  = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss  = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\nvar currenttime= hh + \":\" + mmm + \":\" + ss;\nvar currentdate= dd + \".\" + mm + \".\" + yyyy;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"Last update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"pushalarm\";\nmsg.payload = ip+\"/param.cgi?cmd=pushhostalarm&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":224,"y":400,"wires":[["80da80c4.b3952"]]},{"id":"17925b0a.f59825","type":"string","z":"654e5181.3b745","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{ \"pushalarm\": \"triggered\" }"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"pushalarm\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":663,"y":400,"wires":[["1b3013a2.b7b63c"]]},{"id":"1b3013a2.b7b63c","type":"json","z":"654e5181.3b745","name":"","property":"payload","action":"","pretty":false,"x":533,"y":443,"wires":[["f9f0d5ea.ab4548","360e56b2.29d25a"]]},{"id":"f9f0d5ea.ab4548","type":"ui_text","z":"654e5181.3b745","group":"9c82c990.e99ad8","order":2,"width":0,"height":0,"name":"UI Alarm","label":"Alarm Push","format":"{{msg.payload.pushalarm}}","layout":"row-spread","x":708,"y":444,"wires":[]},{"id":"80da80c4.b3952","type":"change","z":"654e5181.3b745","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":349,"y":400,"wires":[["a93cf3a0.83f78"]]},{"id":"a93cf3a0.83f78","type":"http request","z":"654e5181.3b745","name":"pushhostalarm","method":"GET","ret":"txt","url":"","tls":"","x":506,"y":400,"wires":[["17925b0a.f59825"]]},{"id":"948c7b7b.3fad08","type":"mqtt out","z":"654e5181.3b745","name":"Push Alarm","topic":"ipcam/alarm/pushalarm","qos":"1","retain":"false","broker":"be559f9e.42004","x":551,"y":353,"wires":[]},{"id":"15f29651.6e0e4a","type":"ui_button","z":"654e5181.3b745","name":"Alarm","group":"9c82c990.e99ad8","order":0,"width":0,"height":0,"passthru":true,"label":"Trigger Alarm!","tooltip":"","color":"#ffffff","bgcolor":"#f3100b","icon":"fa-bell","payload":"{\"pushalarm\" : \"triggered\"}","payloadType":"json","topic":"pushalarm","x":412,"y":353,"wires":[["948c7b7b.3fad08"]]},{"id":"7b5307f4.e001b8","type":"mqtt in","z":"654e5181.3b745","name":"","topic":"/homematic/pir/alarm","qos":"1","broker":"be559f9e.42004","x":120,"y":353,"wires":[["6526d51a.a2ae3c"]]},{"id":"360e56b2.29d25a","type":"delay","z":"654e5181.3b745","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":366,"y":487,"wires":[["d1f9e81.78b3218"]]},{"id":"d1f9e81.78b3218","type":"change","z":"654e5181.3b745","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"pushalarm\" : \"\"}","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":524,"y":487,"wires":[["271157e1.7d77e8"]]},{"id":"de5c11ca.bd2cd","type":"comment","z":"654e5181.3b745","name":"Trigger an Alarm","info":"","x":101,"y":310,"wires":[]},{"id":"271157e1.7d77e8","type":"json","z":"654e5181.3b745","name":"","property":"payload","action":"","pretty":false,"x":674,"y":487,"wires":[["f9f0d5ea.ab4548"]]},{"id":"6526d51a.a2ae3c","type":"switch","z":"654e5181.3b745","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"{\"val\":\"triggered\"}","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":287,"y":353,"wires":[["15f29651.6e0e4a"]]},{"id":"be559f9e.42004","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"9c82c990.e99ad8","type":"ui_group","z":"","name":"Trigger","tab":"fa59fc29.87608","disp":true,"width":"6","collapse":false},{"id":"fa59fc29.87608","type":"ui_tab","z":"","name":"Homatic","icon":"dashboard","disabled":false,"hidden":false}]

Note that you must edit the node marked above and enter the IP address and administrator login of your INSTAR FullHD camera (the command to manually trigger the alarm - /param.cgi?cmd=pushhostalarm - is only available on Full HD Camera Models. However, if you are using an HD or VGA camera model, you can substitute the CGI command in the flow with another that can be used with your camera model):


Homematic CCU3


If you now trigger motion detection on your Homematic motion detector, you will find an Audio Alarm in the System Logbook in your camera's WebUI - this will trigger all alarm actions that you have activated in the WebUI of your camera - e.g. an alarm recording on the internal SD card or sending an alarm email.


Homematic CCU3


Homematic Sensors (Door Sensor)

As a second example we can add the Homematic Funk-Tür/Fensterkontakt, optisch to let our camera pan towards the door as soon as it opens. The integration of the sensor into the homematic software and in Node-RED is identical to the previous example (the complete Node-RED Flow can be copied and pasted into Node-RED from the bottom of this page):


Homematic CCU3


In the following part you can see that we have paired the door sensor with our Push alarm. Thus, both the PIR motion detector and the door sensor can trigger an alarm on the camera. Furthermore, a sequence was added to, when opening the door, pan our Full HD PTZ camera (e.g. IN-8015 Full HD or IN-9020 Full HD) in the direction of the door (this position must be stored in the WebUI camera under position 1: /param.cgi?cmd=preset&-act=goto&-number=0) and when closing the door the camera returns to the idle position ( stored in position 2: /param.cgi?cmd=preset&-act=goto&-number=1). For this to work, you must enter the IP address and the login of your camera in the two nodes under the red arrow (just as before):


Homematic CCU3


INSTAR IP Camera -> Homematic

Creating the system variables

So far we have controlled the camera via the Homematic Control Center using Homematic sensors to trigger actions on the camera. The reverse case can be realized via the alarm server on the camera. In the following we want to use the System Variable: Anwesenheit - which represents a logic value by type and in which Homematic is pre-defined - in the Homematic control center to switch a self-created alarm variable (Eingangsbereich).

These variables can be created as follows under Einstellungen > Systemvariable:


Homematic CCU3

Homematic CCU3

Homematic CCU3


To link these variables, we have to click on the Programs button - marked with a red arrow at the top of the image - and create the following program:


Homematic CCU3


This program pays attention when the system status Anwesenheit is switched to anwesend and in this case switches the system status Eingangsbereich area to triggered.

Or to put it simply, if our camera detects a person (via the internal motion detector or motion/audio detection), the Homematic Control Center should be notified of the presence of a person and an alarm triggered for the entrance area.

It makes sense to define a time window in which this rule should be active by clicking UND on the green +, selecting Zeitsteuerung and then selecting a time window in the Zeitmodul:


Homematic CCU3

Homematic CCU3


The example specifies that the alarm is only triggered when the camera detects motion between 18:00 and 8:30 hours.

Configuration of Node-RED

We can now take a sysvar node in Node-RED and feed it via two Inject nodes with the Boolean true or false.


Homematic CCU3

Homematic CCU3


Shown above is the configuration of the True Inject node - for the second one false must be selected.

In the sysvar node we can select our presence system variable here:


Homematic CCU3


If we now click on our true and false nodes, the system variable Presence in the Homematic central will be set to true or false. In the picture below we have placed a debug node at the end of the sequence which gives us a text output on the right side - so we can see exactly what has just been sent to the CCU:


Homematic CCU3


You can copy this flow from here and paste it into Node-RED (note that after copying you still have to set your own system variable in the sysvar node):

[{"id":"b3f13ca9.05d1e","type":"debug","z":"654e5181.3b745","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":370,"y":853,"wires":[]},{"id":"692ab837.89e6a8","type":"inject","z":"654e5181.3b745","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":813,"wires":[["3d291fff.a2c3b"]]},{"id":"3d291fff.a2c3b","type":"ccu-sysvar","z":"654e5181.3b745","name":"Anwesenheit","ccuConfig":"38263145.35ea0e","topic":"ReGaHSS/${Name}","change":true,"cache":true,"x":220,"y":853,"wires":[["b3f13ca9.05d1e"]]},{"id":"5e80cc6f.f25da4","type":"inject","z":"654e5181.3b745","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":893,"wires":[["3d291fff.a2c3b"]]},{"id":"f38ce21d.2de39","type":"comment","z":"654e5181.3b745","name":"Alarmserver Test","info":"","x":100,"y":769,"wires":[]},{"id":"38263145.35ea0e","type":"ccu-connection","z":"","name":"localhost","host":"localhost","regaEnabled":true,"bcrfEnabled":true,"iprfEnabled":true,"virtEnabled":true,"bcwiEnabled":false,"cuxdEnabled":false,"regaPoll":true,"regaInterval":"30","rpcPingTimeout":"60","rpcInitAddress":"127.0.0.1","rpcServerHost":"127.0.0.1","rpcBinPort":"2047","rpcXmlPort":"2048"}]

Since we have coupled the system variable Anwesenheit with our alarm variable Eingangsbereich via program, we now also see a system alarm in the Homematic every time we click on the true Inject Knoten:


Homematic CCU3


In an earlier tutorial we had already created a webhook in Node-RED that we can use as an alarm server to trigger a Node-RED sequence with our camera. We can recycle this code here - in simplified form:


Homematic CCU3


[{"id":"b79554c0.4b0938","type":"http in","z":"654e5181.3b745","name":"Alarmserver","url":"/alarm/eingang","method":"get","upload":false,"swaggerDoc":"","x":90,"y":1059,"wires":[["e7e1fe7c.d917e","db35556e.deb218","7a713636.05ca38"]]},{"id":"e7e1fe7c.d917e","type":"change","z":"654e5181.3b745","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":264,"y":1059,"wires":[["ac29789f.fd0688"]]},{"id":"ac29789f.fd0688","type":"ccu-sysvar","z":"654e5181.3b745","name":"Anwesenheit","ccuConfig":"38263145.35ea0e","topic":"ReGaHSS/${Name}","change":true,"cache":true,"x":454,"y":1058,"wires":[[]]},{"id":"263551c7.fba44e","type":"http response","z":"654e5181.3b745","name":"Status Received","statusCode":"","headers":{"content-type":"text/html"},"x":386,"y":1019,"wires":[]},{"id":"db35556e.deb218","type":"template","z":"654e5181.3b745","name":"page","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n    <head></head>\n    <body>\n        <h1>Presence:</h1>\n        <p>Cellar alarm {{req.query.alarm}}!</p>\n        <p>Trigger {{req.query.active}}!</p>\n    </body>\n</html>","x":237,"y":1019,"wires":[["263551c7.fba44e"]]},{"id":"7a713636.05ca38","type":"delay","z":"654e5181.3b745","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":243,"y":1104,"wires":[["cf961dde.8fa7f"]]},{"id":"cf961dde.8fa7f","type":"change","z":"654e5181.3b745","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":403,"y":1104,"wires":[["ac29789f.fd0688"]]},{"id":"4bd4fb38.6e1224","type":"comment","z":"654e5181.3b745","name":"Alarmserver Webhook","info":"","x":121,"y":977,"wires":[]},{"id":"38263145.35ea0e","type":"ccu-connection","z":"","name":"localhost","host":"localhost","regaEnabled":true,"bcrfEnabled":true,"iprfEnabled":true,"virtEnabled":true,"bcwiEnabled":false,"cuxdEnabled":false,"regaPoll":true,"regaInterval":"30","rpcPingTimeout":"60","rpcInitAddress":"127.0.0.1","rpcServerHost":"127.0.0.1","rpcBinPort":"2047","rpcXmlPort":"2048"}]

This sequence provides an HTTP inbound node that, when the camera contacts the alarm server, sends an HTML page in response. In the node you can see that this node builds a Webhook based on the URL alarm/eingang - note however that this URL is relative to the address of Node-RED. The full path to access the Webhook was //addons/red/alarm/eingang:


Homematic CCU3


When this message shows up we use a change node to send a true to the presence of sysvar node - just like we did manually above via the inject node. Below we have another delay node which automatically sets the status back to false after 5s and thus activates the alarm again.

Alarm server setting on the camera

Now we have to set up the alarm server connection in our camera. The whole thing should look like this:


Homematic CCU3


The address of our alarm server is the local IP address of the CCU, the port is 80 and the server path is /addons/red/alarm/In. The parameter below is optional and is only used for the web page that our webhook provides. In the WebUI of the camera it has also been activated that the alarm trigger should be attached as well - if, for example, you only use the internal PIR sensor of your camera for motion detection, an &active=5 will be attached to the URL (which number stands for which trigger can be found here). You can test the URL by calling the address in your web browser http://<IP Adresse der CCU>/addons/red/alarm/eingang?alarm=ausgelöst&active=5:


Homematic CCU3


Calling this URL simulates the triggering of the alarm server by the camera. We should expect to see an alarm in the CCU:


Homematic CCU3


Every time the camera now triggers an alarm and contacts the alarm server, the presence of a person is now registered in the Homematic control centre and an alarm is triggered immediately outside working hours from 18:00 to 8:30 - please note, however, that this function has a cooldown of 60s on the camera - so an alarm can only be triggered a maximum of 1 time per minute! You can now link this alarm to any variable in your home automation system and thus automate reactions to intrusion.

Complete Node-RED Flow

[{"id":"1cb03303.2daf2d","type":"ccu-value","z":"654e5181.3b745","name":"PIR Sensor","iface":"BidCos-RF","channel":"NEQ1545018:1 HM-Sen-MDIR-O-2 NEQ1545018:1","datapoint":"MOTION","mode":"","start":true,"change":true,"cache":false,"queue":false,"on":0,"onType":"undefined","ramp":0,"rampType":"undefined","working":false,"ccuConfig":"38263145.35ea0e","topic":"${CCU}/${Interface}/${channel}/${datapoint}","x":90,"y":98,"wires":[["aed51eec.42084"]]},{"id":"560c0d74.11df54","type":"change","z":"654e5181.3b745","name":"Alarm","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"val\":\"triggered\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":368,"y":74,"wires":[["cbb0f690.7d1e18"]]},{"id":"cbb0f690.7d1e18","type":"mqtt out","z":"654e5181.3b745","name":"","topic":"/homematic/pir/alarm","qos":"1","retain":"false","broker":"32d092dd.920b8e","x":542,"y":98,"wires":[]},{"id":"cbf3c696.ca53c8","type":"ccu-value","z":"654e5181.3b745","name":"Door Sensor","iface":"BidCos-RF","channel":"OEQ1985716:1 HM-Sec-SCo OEQ1985716:1","datapoint":"STATE","mode":"","start":true,"change":true,"cache":false,"queue":false,"on":0,"onType":"undefined","ramp":0,"rampType":"undefined","working":false,"ccuConfig":"38263145.35ea0e","topic":"${CCU}/${Interface}/${channel}/${datapoint}","x":90,"y":205,"wires":[["35ee1096.27b0f"]]},{"id":"aed51eec.42084","type":"switch","z":"654e5181.3b745","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":240,"y":98,"wires":[["560c0d74.11df54"],["40c14a0b.811054"]]},{"id":"40c14a0b.811054","type":"change","z":"654e5181.3b745","name":"Alarm","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"val\":\"idle\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":368,"y":125,"wires":[["cbb0f690.7d1e18"]]},{"id":"35ee1096.27b0f","type":"switch","z":"654e5181.3b745","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":230,"y":205,"wires":[["94280d47.14851"],["38ed727d.f46e3e"]]},{"id":"94280d47.14851","type":"change","z":"654e5181.3b745","name":"Alarm","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"val\":\"open\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":363,"y":178,"wires":[["9253d1fd.dbffe"]]},{"id":"9253d1fd.dbffe","type":"mqtt out","z":"654e5181.3b745","name":"","topic":"/homematic/door/alarm","qos":"1","retain":"false","broker":"32d092dd.920b8e","x":536,"y":202,"wires":[]},{"id":"38ed727d.f46e3e","type":"change","z":"654e5181.3b745","name":"Alarm","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"val\":\"closed\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":363,"y":229,"wires":[["9253d1fd.dbffe"]]},{"id":"476976cd.d97608","type":"mqtt in","z":"654e5181.3b745","name":"Push Alarm","topic":"ipcam/alarm/pushalarm","qos":"1","broker":"be559f9e.42004","x":90,"y":452,"wires":[["dc4b5e6c.55524"]]},{"id":"dc4b5e6c.55524","type":"function","z":"654e5181.3b745","name":"Alarm","func":"var ip = \"192.168.2.111\";\nvar user = \"admin\";\nvar password = \"instar\";\n\n// Update the status with current timestamp\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd  = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm  = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss  = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\nvar currenttime= hh + \":\" + mmm + \":\" + ss;\nvar currentdate= dd + \".\" + mm + \".\" + yyyy;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"Last update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"pushalarm\";\nmsg.payload = ip+\"/param.cgi?cmd=pushhostalarm&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":224,"y":452,"wires":[["80da80c4.b3952"]]},{"id":"17925b0a.f59825","type":"string","z":"654e5181.3b745","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{ \"pushalarm\": \"triggered\" }"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"pushalarm\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":663,"y":452,"wires":[["1b3013a2.b7b63c"]]},{"id":"1b3013a2.b7b63c","type":"json","z":"654e5181.3b745","name":"","property":"payload","action":"","pretty":false,"x":533,"y":495,"wires":[["f9f0d5ea.ab4548","360e56b2.29d25a"]]},{"id":"f9f0d5ea.ab4548","type":"ui_text","z":"654e5181.3b745","group":"9c82c990.e99ad8","order":2,"width":0,"height":0,"name":"UI Alarm","label":"Alarm Push","format":"{{msg.payload.pushalarm}}","layout":"row-spread","x":708,"y":496,"wires":[]},{"id":"80da80c4.b3952","type":"change","z":"654e5181.3b745","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":349,"y":452,"wires":[["a93cf3a0.83f78"]]},{"id":"a93cf3a0.83f78","type":"http request","z":"654e5181.3b745","name":"pushhostalarm","method":"GET","ret":"txt","url":"","tls":"","x":506,"y":452,"wires":[["17925b0a.f59825"]]},{"id":"948c7b7b.3fad08","type":"mqtt out","z":"654e5181.3b745","name":"Push Alarm","topic":"ipcam/alarm/pushalarm","qos":"1","retain":"false","broker":"be559f9e.42004","x":551,"y":380,"wires":[]},{"id":"15f29651.6e0e4a","type":"ui_button","z":"654e5181.3b745","name":"Alarm","group":"9c82c990.e99ad8","order":0,"width":0,"height":0,"passthru":true,"label":"Trigger Alarm!","tooltip":"","color":"#ffffff","bgcolor":"#f3100b","icon":"fa-bell","payload":"{\"pushalarm\" : \"triggered\"}","payloadType":"json","topic":"pushalarm","x":412,"y":380,"wires":[["948c7b7b.3fad08"]]},{"id":"7b5307f4.e001b8","type":"mqtt in","z":"654e5181.3b745","name":"","topic":"/homematic/pir/alarm","qos":"1","broker":"be559f9e.42004","x":120,"y":405,"wires":[["6526d51a.a2ae3c"]]},{"id":"360e56b2.29d25a","type":"delay","z":"654e5181.3b745","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":366,"y":539,"wires":[["d1f9e81.78b3218"]]},{"id":"d1f9e81.78b3218","type":"change","z":"654e5181.3b745","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"pushalarm\" : \"\"}","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":524,"y":539,"wires":[["271157e1.7d77e8"]]},{"id":"de5c11ca.bd2cd","type":"comment","z":"654e5181.3b745","name":"Trigger an Alarm","info":"","x":101,"y":309,"wires":[]},{"id":"271157e1.7d77e8","type":"json","z":"654e5181.3b745","name":"","property":"payload","action":"","pretty":false,"x":674,"y":539,"wires":[["f9f0d5ea.ab4548"]]},{"id":"16eb7e29.270fb2","type":"mqtt in","z":"654e5181.3b745","name":"","topic":"/homematic/door/alarm","qos":"1","broker":"be559f9e.42004","x":120,"y":357,"wires":[["196d5004.ae1d8"]]},{"id":"83c4f592.0eb038","type":"switch","z":"654e5181.3b745","name":"Push","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"{\"val\":\"open\"}","vt":"str"},{"t":"eq","v":"{\"val\":\"closed\"}","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":290,"y":654,"wires":[["622a1870.7599b8"],["1ec9ed97.043b82"]]},{"id":"622a1870.7599b8","type":"function","z":"654e5181.3b745","name":"Alarm Pos 1","func":"var ip = \"192.168.2.111\";\nvar user = \"admin\";\nvar password = \"instar\";\n\n// Update the status with current timestamp\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd  = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm  = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss  = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\nvar currenttime= hh + \":\" + mmm + \":\" + ss;\nvar currentdate= dd + \".\" + mm + \".\" + yyyy;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"Last update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"pushalarm\";\nmsg.payload = ip+\"/param.cgi?cmd=preset&-act=goto&-number=0&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":630,"wires":[["da5b2ed7.12a7b"]]},{"id":"da5b2ed7.12a7b","type":"change","z":"654e5181.3b745","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":578,"y":630,"wires":[["f1bd868.ce72c78"]]},{"id":"f1bd868.ce72c78","type":"http request","z":"654e5181.3b745","name":"pushhostalarm","method":"GET","ret":"txt","url":"","tls":"","x":735,"y":630,"wires":[[]]},{"id":"34254a4a.5ca5d6","type":"comment","z":"654e5181.3b745","name":"Go to Position","info":"","x":90,"y":614,"wires":[]},{"id":"fb1c3fd5.b4b6e","type":"mqtt in","z":"654e5181.3b745","name":"","topic":"/homematic/door/alarm","qos":"1","broker":"be559f9e.42004","x":120,"y":654,"wires":[["83c4f592.0eb038"]]},{"id":"1ec9ed97.043b82","type":"function","z":"654e5181.3b745","name":"Alarm Pos 2","func":"var ip = \"192.168.2.111\";\nvar user = \"admin\";\nvar password = \"instar\";\n\n// Update the status with current timestamp\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd  = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm  = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss  = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\nvar currenttime= hh + \":\" + mmm + \":\" + ss;\nvar currentdate= dd + \".\" + mm + \".\" + yyyy;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"Last update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"pushalarm\";\nmsg.payload = ip+\"/param.cgi?cmd=preset&-act=goto&-number=1&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":677,"wires":[["ffc4e8f9.34d5b8"]]},{"id":"ffc4e8f9.34d5b8","type":"change","z":"654e5181.3b745","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":578,"y":677,"wires":[["3b35d14d.42014e"]]},{"id":"3b35d14d.42014e","type":"http request","z":"654e5181.3b745","name":"pushhostalarm","method":"GET","ret":"txt","url":"","tls":"","x":738,"y":677,"wires":[[]]},{"id":"196d5004.ae1d8","type":"switch","z":"654e5181.3b745","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"{\"val\":\"open\"}","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":288,"y":357,"wires":[["15f29651.6e0e4a"]]},{"id":"6526d51a.a2ae3c","type":"switch","z":"654e5181.3b745","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"{\"val\":\"triggered\"}","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":287,"y":405,"wires":[["15f29651.6e0e4a"]]},{"id":"b3f13ca9.05d1e","type":"debug","z":"654e5181.3b745","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":370,"y":853,"wires":[]},{"id":"692ab837.89e6a8","type":"inject","z":"654e5181.3b745","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":813,"wires":[["3d291fff.a2c3b"]]},{"id":"3d291fff.a2c3b","type":"ccu-sysvar","z":"654e5181.3b745","name":"Anwesenheit","ccuConfig":"38263145.35ea0e","topic":"ReGaHSS/${Name}","change":true,"cache":true,"x":220,"y":853,"wires":[["b3f13ca9.05d1e"]]},{"id":"5e80cc6f.f25da4","type":"inject","z":"654e5181.3b745","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":893,"wires":[["3d291fff.a2c3b"]]},{"id":"b79554c0.4b0938","type":"http in","z":"654e5181.3b745","name":"Alarmserver","url":"/alarm/eingang","method":"get","upload":false,"swaggerDoc":"","x":90,"y":1059,"wires":[["e7e1fe7c.d917e","db35556e.deb218","7a713636.05ca38"]]},{"id":"e7e1fe7c.d917e","type":"change","z":"654e5181.3b745","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":264,"y":1059,"wires":[["ac29789f.fd0688"]]},{"id":"ac29789f.fd0688","type":"ccu-sysvar","z":"654e5181.3b745","name":"Anwesenheit","ccuConfig":"38263145.35ea0e","topic":"ReGaHSS/${Name}","change":true,"cache":true,"x":454,"y":1058,"wires":[[]]},{"id":"263551c7.fba44e","type":"http response","z":"654e5181.3b745","name":"Status Received","statusCode":"","headers":{"content-type":"text/html"},"x":386,"y":1019,"wires":[]},{"id":"db35556e.deb218","type":"template","z":"654e5181.3b745","name":"page","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n    <head></head>\n    <body>\n        <h1>Anwesenheit:</h1>\n        <p>Eingang Alarm {{req.query.alarm}}!</p>\n        <p>Auslöser {{req.query.active}}!</p>\n    </body>\n</html>","x":237,"y":1019,"wires":[["263551c7.fba44e"]]},{"id":"7a713636.05ca38","type":"delay","z":"654e5181.3b745","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":243,"y":1104,"wires":[["cf961dde.8fa7f"]]},{"id":"cf961dde.8fa7f","type":"change","z":"654e5181.3b745","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":403,"y":1104,"wires":[["ac29789f.fd0688"]]},{"id":"f38ce21d.2de39","type":"comment","z":"654e5181.3b745","name":"Alarmserver Test","info":"","x":100,"y":769,"wires":[]},{"id":"4bd4fb38.6e1224","type":"comment","z":"654e5181.3b745","name":"Alarmserver Webhook","info":"","x":121,"y":977,"wires":[]},{"id":"3aa805a9.15656a","type":"comment","z":"654e5181.3b745","name":"Homematic Sensors","info":"","x":110,"y":50,"wires":[]},{"id":"38263145.35ea0e","type":"ccu-connection","z":"","name":"localhost","host":"localhost","regaEnabled":true,"bcrfEnabled":true,"iprfEnabled":true,"virtEnabled":true,"bcwiEnabled":false,"cuxdEnabled":false,"regaPoll":true,"regaInterval":"30","rpcPingTimeout":"60","rpcInitAddress":"127.0.0.1","rpcServerHost":"127.0.0.1","rpcBinPort":"2047","rpcXmlPort":"2048"},{"id":"32d092dd.920b8e","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"nodered","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"be559f9e.42004","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"9c82c990.e99ad8","type":"ui_group","z":"","name":"Trigger","tab":"fa59fc29.87608","disp":true,"width":"6","collapse":false},{"id":"fa59fc29.87608","type":"ui_tab","z":"","name":"Homatic","icon":"dashboard","disabled":false,"hidden":false}]