whizzosoftware / WZWave

A native Java library for interfacing with Z-Wave PC controllers
Eclipse Public License 1.0
33 stars 22 forks source link

Problem running Example Client code #2

Closed trycoon closed 8 years ago

trycoon commented 8 years ago

I'm having problem with running the Example code of WZWave. I'm running WZWave (0.0.4, commit 5f9e38160ccc9c39acace864868d27ac95c0d5c7) on Ubuntu 16.04.1 LTS using Java 1.8.0_101-b13. My controller is a ZME-UZB1 (https://www.z-wave.me/index.php?id=28).

The code I'm running looks like this:

package com.test;
import com.whizzosoftware.wzwave.controller.ZWaveController;
import com.whizzosoftware.wzwave.controller.ZWaveControllerListener;
import com.whizzosoftware.wzwave.controller.netty.NettyZWaveController;
import com.whizzosoftware.wzwave.node.ZWaveEndpoint;

public class WZWaveTest implements ZWaveControllerListener {
   private ZWaveController controller;
   public WZWaveTest() {
      controller = new NettyZWaveController("/dev/ttyACM0");
      controller.setListener(this);
      controller.start();
   }
   public void onZWaveNodeAdded(ZWaveEndpoint node) {
      System.out.println("Z-Wave node added: " + node.getNodeId());
   }
   public void onZWaveNodeUpdated(ZWaveEndpoint node) {
      System.out.println("Z-Wave node updated: " + node.getNodeId());
   }
   public void onZWaveConnectionFailure(Throwable t) {
      System.out.println("Something bad happened: " + t);
   }
   public static void main(String[] args) {
      new WZWaveTest();
   }
    public void onZWaveControllerInfo(String libraryVersion, Integer homeId, Byte nodeId) {
         System.out.println(String.format("ControllerInfo received: libraryVersion=%s, homeId=%d, nodeId=%d", libraryVersion, homeId, nodeId));
    }
}

I'm inserting my Z-Wave controller in the USB-port, starts up NetBeans, and then run the program. The result is in the first stacktrace-file provided. stackdump1.txt

I don't know why I get those NPE(NullPointerExeption), maybe the controller have not had enought time to start up correctly? Because when I rerun my program I get other errors.

stackdump2.txt

I don't know if its some kind of timing problem, because I get different stacktraces every time I rerun the program. The datastream may be out of sync somehow?

stackdump3.txt

In this run I get several onZWaveControllerInfo-events in a row, I don't know if thats to expect? stackdump4.txt

Any suggestions on how to progress? Should I enable some additional logging? I know Z-Wave and WZWave so little I don't even know where to start. :-)

Thanks for any replies!

whizzosoftware commented 8 years ago

Thanks for the bug report. Turning on TRACE level logging would help a lot here to see what's actually occurring on the Z-Wave network. Take a look at this forum post:

https://community.hobson-automation.com/index.php?/topic/2466-detection-of-nodes-and-usage-of-the-basic_set-command/&do=findComment&comment=2525

There's an example project attachment with a logback.xml that sets the log level to TRACE. Try giving that a shot and see if you get a more detailed log file.

trycoon commented 8 years ago

Thanks, I made a quick trace-logging:

trace.txt

whizzosoftware commented 8 years ago

Thank you, that was very helpful. I just checked in a change that should solve the "io.netty.handler.codec.DecoderException: ZWaveFrameDecoder.decode() did not read anything but decoded a message" message you're seeing.

trycoon commented 8 years ago

That did the trick, Thanks you soo much, that was very quickly fixed! Now there are no exceptions recorded, its funny that it somehow detects a couple of binary switches (node 2 & 3) since I have no Z-wave devices connected besides a FGSS-001 Smokesensor laying on my desk. Maybe the smokesensor have some buttons on it that are detected? :-)

working trace.txt

whizzosoftware commented 8 years ago

Glad to hear it solved the problem!

From your log file, it looks like your Z-Wave controller thinks nodes 2 and 3 are valid. From what I've seen, the controller will remember nodes that were added until they are explicitly removed - even if those nodes don't exist anymore. Is it possible that you added those nodes in the past?

trycoon commented 8 years ago

I don't think they have been added in the past, these are brand new devices for me. And I have never had a working Z-Wave network in my home or used any other softwares with my controller. Maybe they have demo the controller in the store? Anyway that is not important now, I'm just glad its working.