INSTAR Deutschland GmbHINSTAR Deutschland GmbH

Home Automation with Node-RED and OpenHAB on a Raspberry Pi



Trigger an Alarm using Node-RED

The screenshot below shows the final UI that we are going to build using Node-RED and the Node-RED Dashboard on a Raspberry Pi. We want to build a button that can trigger an alarm on your IP Camera to be able to start all set Alarm Actions manually.


OpenHAB2


We already built a component that will store the camera login in a global variable (if you haven"t already, please import it into your Node-RED flow). We now just need a button to send the command to trigger an alarm in our Node-RED Dashboard.


Be aware: that this flow uses the MQTT protocol to publish and subscribe to messages. This allows you to integrate the flow into other software platforms like the OpenHAB Home Automation. But you will have to install a MQTT Broker on your Pi to be able to use it. Those MQTT entry and endpoints can be replaced by Link Nodes, if you don"t only want to use the Node-RED dashboard to control your camera.



Push Alarm

Node-RED Flow




Bonus :: OpenHAB Integration

Adding to the OpenHAB tutorial we are now going to consume the Node-RED flow in our OpenHAB 2 Basic UI.


OpenHAB2


Switch PushAlarm (MDGeneralControlGroup) {mqtt=">[mosquitto:openhab/alarm/pushalarm/triggered:command:ON:1],>[mosquitto:openhab/alarm/pushalarm/triggered:command:OFF:0]"}
String PushAlarmState "Push to Alarm [%s]" <camera> (MDGeneralControlGroup) {mqtt="<[mosquitto:openhab/alarm/pushalarm:state:JSONPATH($.pushalarm)]"}



OpenHAB2


Switch item=PushAlarm label="Trigger Alarm"
Text item=PushAlarmState