Last tested with: v2.2.1
STATUS:stable
This document describes how RaZberry can send status updates as short UDP mesages. These messages consist of (SensorName.Value) pairs. This recipe is used in the communication with OpenRemote. See the full description at OpenRemote. Note: This recipe can also be used in other applications, since it does not depend on OR-specific things!
Note: On the Listener side there now is an extension on the rules that implements a watchdog. If no UDP messages are received since a prolonged time, the live Z-wave icon turns to red: This part deals with the configuration settings on the Raspberry Pi, where you have to do some editing in files. Using Putty make a terminal connection. You can copy and paste(only touch right mouse button) the following instructions.
The remainder of the instruction assumes you have set your working directory to:
Code: Select all
cd /opt/z-way-server
CAUTION: unsolicited status updates will only work if the Z-Wave controller is properly notified. This notification is done through the basic association mechanism. Most often association group 3 is used for that. With the RaZberry Expert tool you can check that the primary controller (node 1, RaZberry) is in that association group. In case of failure consult the documentation of the failing device first.
automation/storage/UDPORSock.js
Code: Select all
sudo nano automation/storage/UDPORSock.js
Code: Select all
var sock = new sockets.udp();
sock.connect("192.168.4.88", 9091); //Use IP, and port number of your OpenRemote Controller
this.bindFunc1 = function (zwayName) {
if (zwayName != "zway")
return; // you want to bind to default zway instance
var devices = global.ZWave[zwayName].zway.devices;
//from here insert your devices
// Zwave>Me Binary Switch
devices[2].SwitchBinary.data.level.bind(function () {
var status = (this.value) ? "on" : "off";
sock.send("ZWay_2," + status);
});
// Fibaro Universal Sensor-Temperature
devices[13].instances[5].SensorMultilevel.data[1].val.bind(function () {
var status = this.value;
sock.send("ZWay_13_5_1," + status);
});
// Vision Door/window sensor
devices[30].SensorBinary.data[1].level.bind(function () {
var status = (this.value) ? "on" : "off";
sock.send("ZWay_30_0_1," + status);
});
// End of your devices
};
// process all active bindings
if (global.ZWave) {
global.ZWave().forEach(this.bindFunc1);
}
// and listen for future ones
global.controller.on("ZWave.register", this.bindFunc1);
Activate UDPSender
In principle the UDPSendStatusOR.js could be executed from the main.js file. The preferred and easiest way to it, is the RaZberry Home Automation engine. Therefore goto menu -Preferences-Modules-Scripting. Choose CustomUserCodeLoader. It is important to load this javascript code first in your modules setup.
Assessment
Be aware that UDP is not the most reliable protocol. There is no correction mechanism for missing data. So do not apply this recipe in mission critical applications. Some places are more susceptible for such errors.
See next post for testing UDP communication