Skip to main content

Zwave

Z-Wave is a wireless communications protocol used primarily for home automation. It is a mesh network using low-energy radio waves to communicate from appliance to appliance, allowing for wireless control of residential appliances and other devices, such as lighting control, security systems, thermostats, windows, locks, swimming pools, and garage door openers. For integration of Zwave you need a [Zwave USB stick] (https://aeotec.com/z-wave-usb-stick/index.html) and one or more devices. The advantage of Zwave compared to Wifi is larger distance and less power consumption. A Zwave sensor can run several years on a single battery.

Raspberry PIZwave stickZWave device

Zwave2MQTT

For communication with Zwave devices you can use a Raspberry Pi or other computer with a Zwave stick and Zwave2MQTT software, which can be downloaded free of charge. For integration of Zwave connect the stick to a USB port and check the name of the device. Instead of using /dev/ttyACM0 is it better to use the serial/by-id device because this is independent on the USB slot in which the stick is inserted. On a Raspberry Pi this is something like /dev/serial/by-id/usb-0658_0200-if00.

Follow the installation instructions for zwave2mqtt or start a docker container:

docker run --name zwave2mqtt -d -it -p 8091:8091 --device=/dev/serial/by-id/usb-0658_0200-if00 -v /home/pi/zwave2mqtt/store:/usr/src/app/store robertslando/zwave2mqtt:latest

Open a web browser and login:

http://localhost:8091

Go to the settings section and enter the device /dev/serial/by-id/usb-0658_0200-if00 in the Zwave section. In the Mqtt section enter the details of the MQTT host where the data should be sent to and select retain. In the Gateway section you can map the Zwave device information to MQTT topic.

Subscribe

The raw MQTT data sent by the Zwave2MQTT service includes a topic and a JSON body with the time and a value:

mosquitto_sub -h [HOSTNAME] -u [Username] -P [password] -v -t zwave/#

The output looks as follows:

zwave/office/printer/voltage {"time":1637850956331,"value":226.79}
zwave/office/lamp/kwh {"time":1637851022338,"value":96.44}
zwave/office/2/50/1/256 {"time":1637851022343,"value":false}
zwave/office/pir/temperature {"time":1637850316964,"value":68}
zwave/office/lamp/on {"time":1637851320475,"value":true}
zwave/office/lamp/voltage {"time":1637851024324,"value":233.59}

Publish

To update an MQTT device you can publish a message to the topic with suffice /set. For example, to turn on a lamp you can use the following command:

mosquitto_sub -h [HOSTNAME] -u [Username] -P [password] -v -t 'zwave/office/lamp/on/set' -m '{"value": true}'