Skip to main content

MQTT Networks with OpenHAB 2

Bhaktapur, Nepal

OpenHAB Configuration though Paper UI

The Paper UI is a new interface that helps setting up and configuring your openHAB instance. It does not (yet) cover all aspects, so you still need to resort to textual configuration files.

Add-on management: Easily install or uninstall openHAB add-ons:

MQTT Binding

Go to the Add-Ons Menu and click on the Bindings Tab. We are going to use the MQTT protocol to communicate with our INSTAR IP camera from OpenHAB. To be able to connect to the INSTAR MQTT Server we need to install the MQTT Binding - make sure that you choose the Version 2 (at the moment of writing this is the 2.5.0 version).


OpenHAB 2 with your INSTAR IP Camera


Now switch to your OpenHAB Inbox:


OpenHAB 2 with your INSTAR IP Camera


Click on the + icon to add the MQTT Binding:


OpenHAB 2 with your INSTAR IP Camera


Find the MQTT Binding inside the list and select it:


OpenHAB 2 with your INSTAR IP Camera


Click on Add Manually:


OpenHAB 2 with your INSTAR IP Camera


And choose the MQTT Broker:


OpenHAB 2 with your INSTAR IP Camera


Add your brokers IP address and the broker port - by default this is 1883. Note that we are first not going to use TLS encryption. We can add it once we are able to establish the connection:


OpenHAB 2 with your INSTAR IP Camera


Your INSTAR Full HD cameras MQTT login is the one you added in the MQTT Menu. Then save your setting by clicking on the blue confirmation button:


OpenHAB 2 with your INSTAR IP Camera


Back in the Things Menu click on + again - this time to add a Thing that we can use for an PaperUI button later on:


OpenHAB 2 with your INSTAR IP Camera


Click on MQTT Binding:


OpenHAB 2 with your INSTAR IP Camera


And Add Manually:


OpenHAB 2 with your INSTAR IP Camera


This time we need to add a Generic MQTT Thing:


OpenHAB 2 with your INSTAR IP Camera


I am going to create switch that activates or deactivates the alarm areas of an INSTAR IN-8015FHD camera. The Thing ID represents the MQTT topic that we will have to address to send the command to the selected camera. As Bridge you need to select the MQTT broker you just created. Click on the blue button to confirm:


OpenHAB 2 with your INSTAR IP Camera


Back in the Thing Menu click to edit the Thing you just created:


OpenHAB 2 with your INSTAR IP Camera


Click on the blue + button to add a Channel to the Thing:


OpenHAB 2 with your INSTAR IP Camera


I am going to use an ON/Off Switch. The MQTT topic to go to switch the first alarm area is created by adding the prefix instar and your cameras LAN MAC Address (e.g. 00:03:89:88:88:11 - without the colons) to the corresponding INSTAR MQTT topic alarm/area1/enable -> instar/000389888811/alarm/area1/enable for the COMMAND Topic and as message payload we need to add {'val':'1'} and {'val':'0'} to either switch the area on or off. To set the state of our switch, we can use the STATUS Topic instar/000389888811/status/alarm/area1/enable:


OpenHAB 2 with your INSTAR IP Camera

OpenHAB 2 with your INSTAR IP Camera


In the expanded settings we have to set up the Quality-of-Service QoS to deliver every update At-least-once. Now click on Save to continue.

By clicking on the blue icon in front of the created channel we are now able to link it to a switch in the OpenHAB PaperUI:


OpenHAB 2 with your INSTAR IP Camera


Click on Create new item...:


OpenHAB 2 with your INSTAR IP Camera


Click on Link:


OpenHAB 2 with your INSTAR IP Camera


You can now click on Control to open the PaperUI:


OpenHAB 2 with your INSTAR IP Camera


Our Alarm Areas can now be switched from the OpenHAB Paper UI. Clicking the switch will send the MQTT message to our MQTT server that is going to notify our camera to either switch area 1 on or off.

All right that's it - the Binding was successfully added and we are now able to control all of our camera functions with the MQTT interface.