What updates log?

Discussions about RaZberry - Z-Wave board for Raspberry computer
codefox
Posts: 15
Joined: 04 May 2016 22:27

What updates log?

Post by codefox » 19 Jul 2016 01:50

So I really would like to be able to get a real-time feed of activity from my Razberry so that I can feed it into other systems. I've looked at using UDP but I haven't been able to get it to send any messages. While I was tailing the log, I saw that when I switched my swich on/off manually, that the log updated immedately with something like the following:

[2016-07-18 22:47:03.663] [D] [zway] RECEIVED: ( 01 10 00 49 84 03 0A 04 10 01 25 27 75 73 86 72 77 B9 )
[2016-07-18 22:47:03.664] [D] [zway] SENT ACK
[2016-07-18 22:47:03.664] [zway] Node info received: 3
[2016-07-18 22:47:03.664] [D] [zway] SETDATA devices.3.data.basicType = 4 (0x00000004)
[2016-07-18 22:47:03.664] [D] [zway] SETDATA devices.3.data.genericType = 16 (0x00000010)
[2016-07-18 22:47:03.664] [D] [zway] SETDATA devices.3.data.specificType = 1 (0x00000001)
[2016-07-18 22:47:03.665] [D] [zway] SETDATA devices.3.data.deviceTypeString = "Binary Power Switch"
[2016-07-18 22:47:03.665] [D] [zway] SETDATA devices.3.data.nodeInfoFrame = byte[7]
[2016-07-18 22:47:03.666] [D] [zway] ( 25 27 75 73 86 72 77 )
[2016-07-18 22:47:03.666] [D] [zway] SETDATA devices.3.data.lastReceived = 0 (0x00000000)

Can we get access to this update mechanism? That would be incredibly valuable.

pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: What updates log?

Post by pz1 » 19 Jul 2016 10:40

codefox wrote:I've looked at using UDP but I haven't been able to get it to send any messages.
Did you fail to get this recipe working?
Since 29-12-2016 I am no longer a moderator for this forum

codefox
Posts: 15
Joined: 04 May 2016 22:27

Re: What updates log?

Post by codefox » 19 Jul 2016 14:37

I have and I'm not sure why yet. I am going to try more this morning but after I set up the UDP, I get nothing to anything lrying to listen to it.

pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: What updates log?

Post by pz1 » 19 Jul 2016 15:12

codefox wrote: I get nothing to anything lrying to listen to it.
Well, if you do not yet have a client in mind, then it seems a bit premature to me to think about solutions like UDP.

codefox
Posts: 15
Joined: 04 May 2016 22:27

Re: What updates log?

Post by codefox » 19 Jul 2016 15:57

I think you misunderstand me. Neither client I used received a message. My intended client is a camel route but when that didn't work, I set up a simple netcat client to see if ZWay was broadcasting. When that didn't work I checked a tcpdump of the port I'm sending over and didn't see anything.

So the problem is in the sender, not the client.

pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: What updates log?

Post by pz1 » 19 Jul 2016 17:53

thanks for the clarification. Now I understand your setup. I assume you did use TCPDump on the RaspberryPi with the parameters as described in the Recipe?
As described in the recipe, I have my code loaded in Smarthome with module Load custom JavaScript file. Sometimes if it hangs, I just stop/start this module under the Active Apps view.

codefox
Posts: 15
Joined: 04 May 2016 22:27

Re: What updates log?

Post by codefox » 20 Jul 2016 00:24

I did. I'm not sure what I'm missing here. This is my code:

Code: Select all

var sock = new sockets.udp();
        sock.connect("192.168.1.73", 9091); //Use IP 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[3].SwitchBinary.data.level.bind(function () {
                        var status = (this.value) ? "on" : "off";
                        sock.send("ZWay_3," + 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);

pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: What updates log?

Post by pz1 » 20 Jul 2016 10:14

Strange in essence your code is the same as the one I am actually using.
As a regular test I have included a start message after the sock.connect:

Code: Select all

sock.send("Socket quadras started");
One other thing I can think off is that your Switch does not send state changes. I have the Association of my switch as follows:
Assoc.PNG
Assoc.PNG (10.78 KiB) Viewed 3423 times

codefox
Posts: 15
Joined: 04 May 2016 22:27

Re: What updates log?

Post by codefox » 20 Jul 2016 16:21

I put a logging statement in there and, yes, thank you...I can at least confirm that the JS is loading and that my UDP client is receiving the message. I feel stupid for not putting that in to validate the connection. :)

So that does, obviously, lead me to my plug-in switch. I don't have the option of setting the association groups for the switch since they're not reported by the interview. I'm still new to Z-Wave but I suppose this would indicate that the switch I'm using does not have the ability to report status changes in the way that I need. I do have a question though:

In my first post, I noted that the log immediately updates when I press the button on my switch to turn it on or off. So something is being notified on the status change. Is that mechanism available in JS that's outputting the server log? If it is, I can modify my script to use that.

pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: What updates log?

Post by pz1 » 20 Jul 2016 17:02

What is the brand and type of your switch. Some of the older (often US) don't support the unsolicited updates. That can be mimicked with the Periodical Switch Polling app.

I am not at all a specialist, but I assume the log is driven by the same Eventbus as the bind function in my code.
So my hope is that the polling app will help.

PS: IIRC, there is also a more generic polling app for other types of devices.
PS2: I have never tried any of these polling apps, since my client (OpenRemote) polls my old Duwi plugin switch every 10 seconds. That fast enough for my heater application. My Fibaro plugin works fine with the UDP sender though.

Post Reply