Binding battery level of my flood sensor

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
tromper
Posts: 5
Joined: 11 Oct 2017 20:38

Binding battery level of my flood sensor

Post by tromper » 06 Apr 2018 16:16

Hi everyone,

I am trying to bind the battery level of my sensor using the JS automation engine. I bind other values perfectly so i guess i am doing something wrong with this one. Here is the code i use:

Code: Select all

//BATTERY//
zway.devices[2].commandClasses[128].data[1].val.bind(function(){ //Binds event

                if(this.value){ //Notification 

                console.log('COMPRUEBA BATTERY BIND!!!!!!'+this.value);

                        try { //here begins the code for sending
                                var options = {};
                                // send data to server
                                options.url = "http://192.168.0.30/portada1.php";
                                options.method = "POST";
                                options.data = "battery="+this.value;  //this can be accessed by $_POST['battery']
                                var res = http.request(options);
                                console.log('COMPRUEBA BATTERY BIND!!!!!!'+options.data);
                        } 
			catch(err) { // here is the code to display the error in the console server log if something is wrong
                                debugPrint("Failed to send data: " + err);
                        }
                }
});
It does not even enter the bind as the console.log is not shown in tail -f /var/log/z-way-server.log.
I dont know what the error might be. CommandClasses 128 is the one for battery and the sensor is device 2.
Hope you know what can be going on.

I also tried with zway.devices[2].commandClasses[128].data.lastlevel.bind() but it still doesn't work as i get this error in the log:

Code: Select all

[2018-04-02 15:36:27.586] [I] [core] Executing script: //Bindings for value changes ...
[2018-04-02 15:36:27.626] [E] [core] result: Error: TypeError: Cannot read property 'bind' of undefined
    at automation/binding.js:80:51
    at automation/main.js:170:1
[2018-04-02 15:36:27.637] [E] [core] result: Error: Error: Uncaught TypeError: Cannot read property 'bind' of undefined
    at Error (native)
    at automation/main.js:170:1
[2018-04-02 15:36:27.888] [I] [core] Creating device sensorBinary ZWayVDev_zway_2-0-48-1
[2018-04-02 15:36:27.946] [I] [core] Notification: device-info (device-OnOff): {"dev":"Fibaro General purpose (2.0)","l":"off","location":""}
[2018-04-02 15:36:28.033] [I] [core] Creating device battery ZWayVDev_zway_2-0-128
[2018-04-02 15:36:28.180] [I] [core] Creating device sensorBinary ZWayVDev_zway_2-0-156-5-A
[2018-04-02 15:36:28.201] [I] [core] Notification: device-info (device-OnOff): {"dev":"Fibaro Water Alarm (2.0)","l":"off","location":""}
[2018-04-02 15:36:28.255] [I] [core] Creating device sensorMultilevel ZWayVDev_zway_2-2-49-1
[2018-04-02 15:36:28.275] [I] [core] Notification: device-info (device-temperature): {"dev":"Fibaro Temperature (2.2)","l":"17.1 °C","location":""}
[2018-04-02 15:36:28.348] [I] [core] Creating device sensorBinary ZWayVDev_zway_4-0-48-1
[2018-04-02 15:36:28.377] [I] [core] Notification: device-info (device-OnOff): {"dev":"Fibaro General purpose (4.0)","l":"off","location":""}
[2018-04-02 15:36:28.447] [I] [core] Creating device battery ZWayVDev_zway_4-0-128
[2018-04-02 15:36:28.558] [I] [core] Creating device sensorBinary ZWayVDev_zway_4-0-156-5-A
[2018-04-02 15:36:28.572] [I] [core] Notification: device-info (device-OnOff): {"dev":"Fibaro Water Alarm (4.0)","l":"off","location":""}
[2018-04-02 15:36:28.619] [I] [core] Creating device sensorMultilevel ZWayVDev_zway_4-2-49-1
[2018-04-02 15:36:28.632] [I] [core] Notification: device-info (device-temperature): {"dev":"Fibaro Temperature (4.2)","l":"17.9 °C","location":""}
[2018-04-02 15:36:28.723] [I] [core] Creating device switchBinary ZWayVDev_zway_6-0-37
[2018-04-02 15:36:28.738] [I] [core] (Mobile App Support) Notify listener (DeviceUpdate) skipped
[2018-04-02 15:36:28.839] [I] [core] Creating device switchBinary ZWayVDev_zway_8-0-37
[2018-04-02 15:36:28.848] [I] [core] Notification: device-info (device-OnOff): {"dev":"UFairy G.R. Tech Switch (#8)","l":"on","location":""}
I hope someone can help me with this...

Post Reply