In this project, we have used a Raspberry Pi 3+ and Aeotec Z-Stick Gen5 to create a Z-Wave gateway used to report data from Aeotec MultiSensor6 and control the state of Aeotec LED Bulb6 with WolkAbout IoT Platform. Other Z-Wave devices can be used instead. To check if there is support for your device, please refer to PyZwaver that was used as a dependency for this project.Hardware Setup
Add all Z-Wave devices to your Z-Wave network by following the inclusion guide listed in the device manuals. After successfully adding all nodes to the network, go ahead and plug in the controller into the USB port of the Raspberry Pi.Software Setup
WolkGateway bridges the communication between WolkAbout IoT Platform and multiple non-IP-enabled devices connected to it through modules. The modules enable communication with subordinate devices by implementing the devices’ network communication protocol on one end (Z-Wave in this project) and parsing data between the Mosquitto MQTT broker on the other end.
Start with connecting to the Raspberry Pi and cloning the WolkGateway repository:
git clone --recurse-submodules https://github.com/Wolkabout/WolkGateway.git
After that, install WolkGateway’s dependencies.
Now that the dependencies are installed change the directory into WolkGateway and run the
configure.sh script. This script will prepare the build system and compile OpenSSL. Because of the limited hardware capabilities, this step will take some time (up to 10 minutes), so while waiting for this step to finish, create a gateway on WolkAbout IoT Platform.
Head over to demo.wolkabout.com and register/log in with your account. Next, switch to the Device Management tool from the application menu.
Press + and from the dropdown menu select Create device without device type.
Enter the name for the gateway and the optionally a device key.
Set the Protocol to WolkAbout MQTT Gateway, Connectivity Type to MQTT and Sub device Management to GATEWAY.
Tick the checkbox for Create Default Semantic and click Save.
A pop-up will appear with the gateway name and the key, as well as its password.
Save this information by using one of the options from the bottom on the left as you will need to enter it into WolkGateway/out/gatewayConfiguration.json.
configure.sh script finishes, change the directory to WolkGateway/out/ and run
make. To run the application correctly, you need to enter the device credentials into gatewayConfiguration.json:
Before running the gateway application, make sure that Mosquitto is running by invoking
sudo systemctl start mosquitto
Then start the application with
After a couple of seconds, the gateway will connect to the Platform and perform its initial configuration, after which you can register the devices through the gateway.
For easier use, create a service that will run the gateway by creating a new file
wolk_gateway.service and copy the content from the project’s attachments. Make changes to the username and the path if necessary. Then move the service file and enable it with the following commands:
sudo mv wolk_gateway.service /lib/systemd/system/wolk_gateway.service
sudo chmod 644 /lib/systemd/system/wolk_gateway.service
sudo systemctl daemon-reload
sudo systemctl enable wolk_gateway.service
sudo systemctl start wolk_gateway.service
To check the state of the service use
sudo systemctl status wolk_gateway.service
and also use
disable if needed.
This completes the setup for WolkGateway repository resulting in a service that will forward the data from the Z-Wave module to WolkAbout IoT Platform.
Next, clone the WolkGatewayModule-Z-Wave repository:
git clone https://github.com/Wolkabout/WolkGatewayModule-Z-Wave.git
This module requires Python 3.7. Also, installing it on Raspberry Pi unfortunately still isn’t as easy as running
sudo apt-get install, but it is achievable if you follow this guide.
After installing Python3.7, run the
setup.sh as sudo that is located inside WolkGatewayModule-Z-Wave folder. It will download the necessary dependencies for this project.
Within the same folder, there is a
configuration.json file that should be edited to match the address of your Z-Wave controller. You can check the port assigned to the Z-Wave controller with
dmesg | grep tty.
"serial_port": "/dev/ttyACM0", // Z-Wave controller port
"host": "localhost", // Host address of WolkGateway
"port": 1883, // WolkGateway's MQTT broker address
"module_name": "Z-Wave Module" // Unique module identifier
The application is split into several files to make it easier to manage:
demo.py- This is the main part of the application that will include the other files contained in this list.
devices.py- This file contains device templates that describe the type and the format of the data that will be sent from devices. It includes a ready-to-use device template for Aeotec MultiSensor 6, LED Bulb 6 and Smart Dimmer 6. If you want to connect other Z-Wave devices, this documentation should help.
handlers.py- This file is responsible for getting the current connection status of Z-Wave devices and controlling the value of switches, sliders, etc.
zwave.py- This file is responsible for setting up the Z-Wave controller and translating command messages.
In the project’s attachments, you will find
handlers.py that have been modified to work with Aeotec MultiSensor 6 and LED Bulb 6. Go ahead and copy their contents over the cloned files.
According to these files, the MultiSensor’s node address is 3 and the LED bulb’s node address is 4. If your setup is different than this, make changes to the loop in
demo.py and to the functions in
Now, if you run the application with
it will start to poll data from your Z-Wave devices and send a registration request to the gateway.
By following the same steps as for
wolk_gateway.service, create a service for the Z-Wave module using the
z_wave_module.service file from the project’s attachments.
Now that the devices have been registered and have started to send the data to WolkAbout IoT Platform, create a dashboard and add some widgets.
Choose Reading widget and make one for Illuminance, Humidity, Temperature and Ultraviolet from the MultiSensor6 device.
Next, create an actuator widget for the LED Bulb dimmer.
And now you have a dashboard displaying the data from your Z-Wave devices!
We have created this project to showcase the WolkGatewayModule-Z-Wave and provide you with an insight into how to use this library to enable Z-Wave devices to communicate with WolkAbout IoT Platform. This allows you to build your home automation projects and create a unique digital experience with WolkAbout IoT Platform.
This project can be further expanded through the use of WolkAbout IoT Platform’s rule engine. Compare the value of the MultiSensor’s illuminance sensor against a fixed value, and if it’s above or below that value, then change the value of LED Bulb dimmer. Another way to add more value to the project is by creating reports that allow you to see how the temperature or humidity have changed over time.
WolkAbout IoT Platform offers a range of features that help you build killer apps for intelligent home products in a few days instead of weeks. By design and through different libraries, it is compatible with virtually any modern consumer product or microchip.
Stay tuned for more amazing projects!
In the meantime, find out more about our platform and its features by visiting our website.