OpenHAB is an open source home automation platform with a focus on "transparent" work with various device and technology manufacturers. As a result, if a device is popular, it will likely be supported by it sooner or later. It was developed on Java, which allows to launch on different devices; there is a well-developed community of users and developers.
At the heart of openHAB's concept аре the so-called "Bindings" - these are software communication modules that connect different types of devices to the platform. Of course, MQTT and SNMP are supported as "Bindings", which makes NetControl integration extremely easy.
For the main objects with which OpenHAB works, there are several terms:
"Things" - These are the real hardware devices that connect to the platform using a particular "Binding". In our case, a NetControl represents a "Thing" for openHAB that uses "MQTT Binding"
"Channels - These are the different input/output channels that a "Thing" supports: for example, 2pcs. relay outputs, 1 pcs. alarm input and 2 pcs. inputs for sensors at NetControl 2R2S1A.
"Items" - These are the abstract objects with which openHAB actually works at the automation and control level - creating graphics, buttons, rules, scripts, timers, etc.
NetControl (MQTT) and openHAB
NetControl integration is extremely easy and is done entirely through the openHAB WEB interface. We assume that you already have an MQTT broker (it is not part of openHAB) and NetControl is connected to it. Below are the steps to be followed (openHAB 3.0.1 used):
- Make sure 'PUBLISH value format' = JSON is selected in NetControl MQTT settings.
- Add "MQTT" support: openHAB::Settings->Bindings->Add (+), find "MQTT Binding" in the list, and install it
- Add "JSONPath Transformation" and "RegEx Transformation" from openHAB::Settings->Transformations->Add (+)
- Add MQTT Thing for the link to your broker: openHAB::Settings->Things->Add (+), select "MQTT Binding and then "MQTT Broker". Specify a name for "thing" e.g. "MyMQTTBroker", IP address, port, user, password, etc. for the connection to the broker.
- In openHAB::Settings->Things must have already added "MyMQTTBroker" and has the status "Online": the connection to the broker is ready and working.
- We add your NetControl just like "Things": openHAB::Settings->Things->Add (+), select "MQTT Binding" under "Choose Binding", then "Generic MQTT Thing". You name yourself for the newly created "Thing" object, such as a "MyNetControl". The most important thing is select the "Parent Bridge" box and select "MyMQTTBroker" – so you indicate that your NetControl will use the MQTT connection you created in step 3.
- In openHAB::Settings->Things must have already added "MyNetControl" and has the status "Online".
- Channels supported by the device should be added: openHAB::Settings->Things->MyNetControl->Channels->AddChannel.
You must first specify a channel name, ID, and its type. For relay channels, you can select "On/Off Switch", for sensor - "Number Value", for alarm input - "Open/Close Contact".
MQTT topics for the channel should then be introduced, for example, for Line 1:
MQTT State Topic = NetControl/subgroup/out/ch9The supported channel numbers for the different models you should see in the guide. If you have set "User defined sub-topic" in the MQTT netcontrol settings, you should also reflect it.
MQTT Command Topic = NetControl/subgroup/in/ch9 (set only for channels that accept commands, e.g. relay outputs)
There is a "Show advanced" checkbox in the channel menu - CHECK IT OUT! In the "Incoming Value Transformations" box, it is necessary to add:
For relay channels: Incoming Value Transformations = JSONPATH:$.value.real
For sensor inputs:Incoming Value Transformations = JSONPATH:$.value.real∩REGEX:(.*?) C
/replacing the symbol 'C' (in this case for the TDS300 sensor) with the dimes of the corresponding channel that is fed into the JSON MQTT channel message
- Go back to the "Channels" menu and under the created channels will appear 'Add link to item...'. Create a new 'Item' for each channel.
With the 'Items' created, you can now create 'Pages' with buttons, graphics and so on. For more details visit https://www.openhab.org/docs/