Page 1 of 1

Access ZWaveAPI from userModule

Posted: 26 Mar 2015 13:34
by elvizgz
Hello!

I've written a module that executes a script when SensorBinary level of a sensor is on. The sensor used is a BeNext panic watch. When someone push the panic watch, the following is sent:

Code: Select all

[2015-03-26 10:47:28.714] [D] [zway] RECEIVED: ( 01 09 00 04 00 06 03 20 01 FF 29 )
[2015-03-26 10:47:28.716] [D] [zway] SENT ACK
[2015-03-26 10:47:28.717] [D] [zway] SETDATA devices.6.data.lastReceived = 0 (0x00000000)
[2015-03-26 10:47:28.718] [D] [zway] SETDATA devices.1.instances.0.commandClasses.32.data.srcNodeId = 6 (0x00000006)
[2015-03-26 10:47:28.719] [D] [zway] SETDATA devices.1.instances.0.commandClasses.32.data.srcInstanceId = 0 (0x00000000)
[2015-03-26 10:47:28.721] [D] [zway] SETDATA devices.1.instances.0.commandClasses.32.data.level = 255 (0x000000ff)
[2015-03-26 10:47:28.722] [D] [zway] SETDATA devices.6.instances.0.commandClasses.48.data.1.level = True
[2015-03-26 10:47:28.723] [D] [zway] SETDATA devices.6.instances.0.commandClasses.48.data.1 = Empty
The level of the sensor doesn't come back to off unless panic watch is pressed twice. So if the button has been pressed (sensor binary level = on) my module is executed. If later z-way-server is restarted, when automation modules are loaded, my module is executed again because the level of the panic button is on (although it has not been pressed).

To solve this I thought two solutions:

1. Set sensorBinaryLevel to off. I tried with vDev.set but the change is not persistent, it's just for the virtual device so when I restart the server, the level is again on
2. Access ZWaveAPI and check the updateTime (not the one available in vDev because in restart, it's set whith the time when restarted). I've tried to access ZWaveAPI with an http.request but I get a timeout:

Code: Select all

var response = http.request({
                method: 'GET',
                url: encodeURI("http://127.0.0.1:8083/ZWaveAPI/Run/devices[6].instances[0].SensorBinary.data[1].level")
});
I've also tried with

Code: Select all

var sensorLevel = ZWaveAPI.Run.devices[6].instances[0].SensorBinary.data[1].level
but it's not working. Any idea of how can I access ZWaveAPI or any other solution to solve my restart problem?

Re: Access ZWaveAPI from userModule

Posted: 26 Mar 2015 15:19
by pz1
I think you have to reset the switch with SwitchBinary if that is possible on that device

Code: Select all

zway.devices[4].instances[0].SwitchBinary.Set(255)

Re: Access ZWaveAPI from userModule

Posted: 26 Mar 2015 15:22
by elvizgz
No, it's not possible. The device doesn't support Switch Binary command class. Just these:

class: 0x30 COMMAND_CLASS_SENSOR_BINARY
class: 0x85 COMMAND_CLASS_ASSOCIATION
class: 0x84 COMMAND_CLASS_WAKE_UP
class: 0x86 COMMAND_CLASS_VERSION
class: 0x72 COMMAND_CLASS_MANUFACTURER_SPECIFIC
class: 0x70 COMMAND_CLASS_CONFIGURATION
class: 0x80 COMMAND_CLASS_BATTERY
class: 0x71 COMMAND_CLASS_ALARM
class: 0xEF COMMAND_CLASS_MARK
class: 0x20 COMMAND_CLASS_BASIC

Re: Access ZWaveAPI from userModule

Posted: 26 Mar 2015 15:26
by pz1
You're really challenged to go there :mrgreen: (No option to change behaviour with configuration class?)

Re: Access ZWaveAPI from userModule

Posted: 26 Mar 2015 16:02
by elvizgz
Impossible is nothing! 8-)

There is no option to change behaviour with configuration class. Just switch between send Sensor_binary report or alarm report.

I don't know if I have change anything but now I can access http://127.0.0.1:8083/ZWaveAPI/Run/devi ... a[1].level via http.request (before I was getting a timeout). So I'll go for comparing level update time and see if it's enough.