Access ZWaveAPI from userModule
Posted: 26 Mar 2015 13:34
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:
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:
I've also tried with
but it's not working. Any idea of how can I access ZWaveAPI or any other solution to solve my restart problem?
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
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")
});
Code: Select all
var sensorLevel = ZWaveAPI.Run.devices[6].instances[0].SensorBinary.data[1].level