Easy-to-read version : https://qiot.qnap.com/blog/2019/07/19/4653/
Go into Inclusion-mode on your Z-Stick and add your desired Z-Wave device. We will be using the FGPB-101 Fibaro Button in this tutorial.
Instructions for this step can be found in the Z-Stick manual.
Plug your Z-Stick USB into your NAS.
Connect to your NAS via SSH (instructions here).
Enter insmod /usr/local/modules/cdc-acm.ko
if cdc-acm.ko is already installed, you will see this message:
Look for your Z-Stick device path by entering ls -al /dev/ttyACM*
In our case, we have found /dev/ttyACM0
Change the permissions to allow read and write for everyone by entering
chmod 666 /dev/ttyACM0
Then we create an OpenHAB docker and add our device /dev/ttyACM0, by entering:
docker run --name=openhab-zwave \
-p 18080:8080 -p 8443:8443 -p 5555:5555 \
-v /share/Container/OpenHab/addons/:/openhab/addons \
-v /share/Container/OpenHab/userdata/:/openhab/userdata \
-v /share/Container/OpenHab/conf/:/openhab/conf \
--device=/dev/ttyACM0 \
--privileged \
--tty \
openhab/openhab:2.2.0-amd64-debian
On your NAS, open Container Station > Overview > openhab-zwave (the new container you created) > [the given URL]
Alternatively, you can go onto your browser and enter <NAS IP>:18080
This is the OpenHAB UI, we will select Standard, then PAPER UI
Click on Add-ons (1) > BINDINGS (2) > search for and install MQTT Binding and Z-Wave Binding (3)
Under the ACTIONS tab, find and install MQTT Actions
Then, the Z-Wave Controller must be added as a Thing in OpenHAB. To do this, click on Configuration (1) > Things (2) > + (3)
Click on Z-Wave Binding > Z-Wave Serial Controller
Under Serial Port, enter our Z-Stick device path /dev/ttyACM0, then click on the check mark at the top
Now, to add the button, we click on the plus (+) once again to add a new Thing, then click on Z-Wave Binding, then click on the check mark beside your Z-Wave device, in our case it will be Z-Wave Node 4.
Enter a Thing name for your device and click Add Thing
Next, connect your new Thing’s Channel to an Item. Under Things, select your Thing and select the channel you’d like to link (1), then Create new Item (2).
In our tutorial, we will use these settings, then click Link
Under the Control tab, we can see our Thing’s information.
The FGPB-101 has Scene Numbers configured to these values:
Number of Button Presses
Scene Number
1
1.0
2
1.3
3
1.4
4
1.5
5
1.6
hold down
1.2
release
1.1
QIoT Suite Lite Configurations
Open QIoT Suite Lite and create a new Application. Click on IoT Applications (1) > Add IoT Application (2)
Click on your Application and select Add Thing. Then, configure your OpenHAB Thing as follows:
Click on the Add Resource icon
Enter the following information, then click Add
Then, click on the Rule tab.
Add a QBroker node
Then double click on it to add the Button resource we created earlier.
Connect the QBroker node to a debugging node, then save the Flow.
Under the Things tab, click on the ‘Connect a Device’ icon.
Select MQTT and hit Next
Open File Station and navigate to /Container/OpenHab/conf/services/ and edit mqtt.cfg
Edit mqtt.cfg so that the following information matches what was provided by QIoT Suite Lite. ※Note that our tcp address will be 10.0.3.1
(mqtt.cfg on the right)
In a file editor on your PC, create a .rules file (with any name), but it must contain the following lines.
// each rule needs its own rule name
rule “MQTT test”
// TRIGGER CONDITION: when Item FGPB101_SceneNumber changes (e.g. from 1.0 to 1.3)
when
Item FGPB101_SceneNumber received update
/* SCRIPT:
if FGPB101_SceneNumber changes to 1.0 do
publish value=1
if FGPB101_SceneNumber changes to 1.3 do
publish value=2
if FGPB101_SceneNumber changes to 1.4 do
publish value=3
if FGPB101_SceneNumber changes to 1.5 do
publish value=4
if FGPB101_SceneNumber changes to 1.6 do
publish value=5
if FGPB101_SceneNumber changes to 1.2 do
publish value=”up”
if FGPB101_SceneNumber changes to 1.1 do
publish value=”down”
*these values are SceneNumber/values are provided in the table above
*/
then
if (FGPB101_SceneNumber.state == 1.0){
logInfo(“test”, “push 1x”)
publish(“qiot”, “qiot/things/admin/openhab/button”, ‘{“value”: 1}’)
}
if (FGPB101_SceneNumber.state == 1.3){
logInfo(“test”, “push 2x”)
publish(“qiot”, “qiot/things/admin/openhab/button”, ‘{“value”: 2}’)
}
if (FGPB101_SceneNumber.state == 1.4){
logInfo(“test”, “push 3x”)
publish(“qiot”, “qiot/things/admin/openhab/button”, ‘{“value”: 3}’)
}
if (FGPB101_SceneNumber.state == 1.5){
logInfo(“test”, “push 4x”)
publish(“qiot”, “qiot/things/admin/openhab/button”, ‘{“value”: 4}’)
}
if (FGPB101_SceneNumber.state == 1.6){
logInfo(“test”, “push 5x”)
publish(“qiot”, “qiot/things/admin/openhab/button”, ‘{“value”: 5}’)
}
if (FGPB101_SceneNumber.state == 1.1){
logInfo(“test”, “release up”)
publish(“qiot”, “qiot/things/admin/openhab/button”, ‘{“value”: “up”}’)
}
if (FGPB101_SceneNumber.state == 1.2){
logInfo(“test”, “hold down”)
publish(“qiot”, “qiot/things/admin/openhab/button”, ‘{“value”: “down”}’)
}
end
In File Station, navigate to /Container/OpenHab/conf/rules/ and drag the .rules file you just created into this folder.
Head back to QIoT Suite Lite and check out the debug tab for your Flow.
Press on the FGPB-101 Button a few times and see the values appear under the debug tab.
Congratulations on succesfully connecting the Z-Wave device to QIoT!
Additional Information: you can visit : https://qiot.qnap.com/blog/en/
How to Connect a Z-Wave Device to QIoT Container Station / OpenHAB Configurations
-
- New here
- Posts: 4
- Joined: Tue Jul 23, 2019 4:39 pm
-
- New here
- Posts: 8
- Joined: Thu Apr 02, 2020 3:46 am
Re: How to Connect a Z-Wave Device to QIoT Container Station / OpenHAB Configurations
Does this still work for you after a reboot of the NAS?