Z-Way to MQTT on Raspberry pi or RPI
A simple Z-Way to MQTT bridge in GO.
The service sends MQTT message for all handled classes to the a MQTT broker.
Classes can be handled either read only (ro), typicaly for sensors, or read only (ro) ,typicaly for switches.
There is a base subject for MQTT (root topic; per default "razberry").
The nodename will be read form the Z-Way node.
In principle nodes will be split between actuators and sensors and between binray and analogic ones.
The instance is always used. (i)
Currently the bridge is limited to certain ZWave classes (see bellow).
Usage of zwaymqtt:
mqtt topic root or ZWAY_HOME environment variable (default "razberry")
MQTT server or MQTT_SERVER environment variable (default "localhost:1883")
MQTT password or MQTT_PASSWORD environment variable
MQTT username or MQTT_USERNAME environment variable
Z-Way passsword or ZWAY_PASSWORD environment variable
Profile execution (cpu/mem/all)
MQTT protocol tcp/ws/tls MQTT protocol tcp/ws/tls or MQTT_PROTOCOL environment variable (default "tcp")
Z-Way refresh rate in seconds or ZWAY_REFRESH environment variable (default 30)
Z-Way server name or ZWAY_SERVER environment variable (default "localhost:8083")
Z-Way username or ZWAY_USERNAME environment variable (default "admin")
-v Show debug messages
notice that main parameters are mapped by an environment variable
All builds are pushed to docker:
Default tags includes:
- branch (i.e.: master) for latest commit in the branch
- latest for latest release
Please use environment variables to configure:
- MQTT topic root = ZWAY_HOME
- MQTT server = MQTT_SERVER
- MQTT password = MQTT_PASSWORD
- MQTT username = MQTT_USERNAME
- MQTT protocol = MQTT_PROTOCOL
- Z-Way server name = ZWAY_SERVER
- Z-Way username = ZWAY_USERNAME
- Z-Way password = ZWAY_PASSWORD
- Z-Way refresh rate = ZWAY_REFRESH
On your pi:
sudo tar -zxvf ./zwaymqtt.tgz -C /
sudo vi /etc/default/zwaymqtt
sudo systemctl enable zwaymqtt
sudo systemctl start zwaymqtt
I install the software at home with the RaZberry.
To do this:
be sure to have GO and ability to cross compile. (If you do not, you can alway run it with go on a pc)
compile for an arm running linux (raspberry) on a pc:
$ GOOS=linux GOARCH=arm GOARM=5 go get github.com/cblomart/zwaymqtt
- copy the necessary files to your Pi:
$ scp $GOPATH/src/github.com/cblomart/zwaymqtt/etc/systemd/system/zwaymqtt.server firstname.lastname@example.org:/tmp/
$ scp $GOPATH/src/github.com/cblomart/zwaymqtt/etc/default/zwaymqtt email@example.com:/tmp/
$ scp $GOPATH/bin/linux_arm/zwaymqtt firstname.lastname@example.org:/tmp/zwaymqtt.bin
- on your pi, place the files at the right places:
$ sudo cp /tmp/zwaymqtt.server /etc/systemd/system/
$ sudo cp /tmp/zwaymqtt /etc/default/
$ sudo cp /tmp/zwaymqtt.bin /usr/local/bin/zwaymqtt
on your pi, edit the /etc/default/zwaymqtt to match your preferences
on your pi, enable and start the service:
$ sudo systemctl enable zwaymqtt
$ sudo systemctl start zwaymqtt
- COMMAND_CLASS_BATTERY (ro)
The events on this class will be mapped to the "\<root\_topic\>/sensors/analogic/\<nodename\>/\<i\>/battery" topic.
- COMMAND_CLASS_SWITCH_BINARY (rw)
The events on this class will be mapped to the "\<root\_topic\>/actuators/binary/\<nodename\>/\<i\>/switch" topic.
- COMMAND_CLASS_SWITCH_MULTILEVEL (rw)
The events on this class will be mapped to the "\<root\_topic\>/actuators/analogic/\<nodename\>/\<i\>/dimmer" topic.
TODO: put an example (i have no multilevel switch to test)
- COMMAND_CLASS_SENSOR_BINARY (ro)
The utility will be determined by the sensor type described on the node. If it is a generic sensor... "generic" will be used.
The events on this class will be mapped to the "\<root\_topic\>/sensors/binary/\<nodename\>/\<i\>/\<utility\>" topic.
- COMMAND_CLASS_SENSOR_MULTILEVEL (ro)
- COMMAND_CLASS_METER (ro)
The utility is still used but the scale type has been added.
The events on this class will be mapped to the "\<root\_topic\>/sensors/binary/\<nodename\>/\<i\>/\<utility\>/\<scale\>" topic.
The MIT License (MIT)
Copyright (c) 2016 cblomart
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.