roblans / ZWave4Net

ZWave4Net is a .NET library that interfaces with the Aeotec / Aeon Labs Z-Stick.
MIT License
41 stars 34 forks source link

Aeotec Multisensor6 Motion Detection problems #29

Closed mariusdu closed 5 years ago

mariusdu commented 5 years ago

Hello,

I have a Aeotec Z-wave stick gen5 and a Aeotec Multisensor6(usb connected, not on batteries). I am trying to use Zwave4net library to detect motion. I am using ZWave.Devices.Aeon.MultiSensor6 class in order to achieve this but it doesn't work for me. Everything works fine for the Vibration detection part, but for the motion detecion nothing is triggered. This is how I use MultiSensor6 class:

        var node = nodes.FirstOrDefault(x => x.NodeID == MultiSensorId);
        var multisensor = new MultiSensor6(node);

        multisensor.MotionDetected += (_, e) => Console.WriteLine("motion detected");
        multisensor.MotionCancelled += (_, e) => Console.WriteLine("motion cancelled");
        multisensor.VibrationDetected += (_, e) => Console.WriteLine("vibration detected");

Could you, please, provide more info on how should I use the library in order to detect motions? Am I doing something wrong? Should I use something else?

Thank you!

roblans commented 5 years ago

Try to associate the multisensor with the controller:

var association = node.GetCommandClass<Association>();
await association.Add(1, await controller.GetNodeID());

This will make sure that the Basic Set command from the multisensor is send to the controller.

Rob.

mariusdu commented 5 years ago

Hello, I've updated the association and also added some other configuration based on the sensor's specs:

        var association = node.GetCommandClass<Association>();
        await association.Add(1, await controller.GetNodeID());

        var configuration = node.GetCommandClass<Configuration>();
        await configuration.Set(3, 10, 2);//Parameter 3 [2 byte] = 10 This will set the timeout of the PIR sensor to 10 seconds
        await configuration.Set(4, 5, 1);//Parameter 4 [1 byte] = 5 This is the default setting, but sending it in anyways may active the PIR sensor
        await configuration.Set(5, 2, 1);//Parameter 5 [1 byte] = 2

And it seems that now I have some positive results, Thank you for your help!!