Page 1 of 1

Problems after power outage.

Posted: 31 Dec 2014 08:59
by crayoneater
Hello, recently the power went out at my house. After getting power back, my custom javascript code is no longer working. Can somebody help me understand what is going on...? The log shows this related to my code:

[2014-12-31 05:09:17.623] [core] --- Starting module Load custom JavaScript code
[2014-12-31 05:09:17.640] [core] Executing script: this.bindFunc1 = function(zwayName) { ...


and below is my code (this same exact code was working before my power outage):

Code: Select all

this.bindFunc1 = function(zwayName) {
if (zwayName != "zway") return;
var devices = global.ZWave[zwayName].zway.devices;

devices[16].SensorBinary.data[1].level.bind(function() {
    debugPrint( 'CHANGED\n ');
    if (this.value == true)
         http.request({
                            url: "myurlhere",
                            method: "POST",
                            async: true
                        });   
});

devices[17].SensorBinary.data[1].level.bind(function() {
    debugPrint( 'CHANGED\n ');
    if (this.value == true)
         http.request({
                            url: "http://myurlhere",
                            method: "POST",
                            async: true
                        });   
});

devices[20].SensorBinary.data[1].level.bind(function() {
    debugPrint( 'CHANGED\n ');
    if (this.value == true)
         http.request({
                            url: "http://myurlhere",
                            method: "POST",
                            async: true
                        });   
});

devices[21].SensorBinary.data[1].level.bind(function() {
    debugPrint( 'CHANGED\n ');
    if (this.value == true)
         http.request({
                            url: "http://myurlhere",
                            method: "POST",
                            async: true
                        });   
});
};

global.controller.on("ZWave.register", this.bindFunc1);
The logs will show things like this, but never trigger my bindFunc1 (related to device 17):

Code: Select all

[2014-12-31 05:05:55.150] [D] [zway] SETDATA devices.17.instances.0.commandClasses.48.data.1.level = True
[2014-12-31 05:05:55.151] [D] [zway] SETDATA devices.17.instances.0.commandClasses.48.data.1 = Empty
[2014-12-31 05:06:48.563] [D] [zway] RECEIVED: ( 01 09 00 04 00 11 03 30 03 00 D3 )
[2014-12-31 05:06:48.564] [D] [zway] SENT ACK
[2014-12-31 05:06:48.564] [D] [zway] SETDATA devices.17.data.lastReceived = 0 (0x00000000)
[2014-12-31 05:06:48.564] [D] [zway] SETDATA devices.17.instances.0.commandClasses.48.data.1.level = False
[2014-12-31 05:06:48.565] [D] [zway] SETDATA devices.17.instances.0.commandClasses.48.data.1 = Empty
I am on version 2.0.0

Re: Problems after power outage.

Posted: 04 Jan 2015 01:21
by pofs
Your code will work only when executed BEFORE z-wave module is started. If it executes AFTER z-wave, "ZWave.register" event handler is never called.
Refer to viewtopic.php?f=3422&t=20816&p=53488&hi ... ter#p53478 for correct way of handling this.