Easy Scripting problem

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
AlesKO
Posts: 84
Joined: 24 Nov 2016 09:58

Easy Scripting problem

Post by AlesKO »

Would like to learn Easy Scripting by testing basic functionalities on my first simple example (if Light dimmer is over 50 then turn switch ON else turn switch OFF):

......
### ZWayVDev_zway_71-2-38 // Light Dimmer (71.2)

var sensorValue = vdev("ZWayVDev_zway_71-2-38").value();
debugPrint("My dimmer value = ",sensorValue);

if (sensorValue>50) {
vdev("ZWayVDev_zway_81-0-37").on();
} else {
vdev("ZWayVDev_zway_81-0-37").off();
}
......


Why it does not work? Why debugPrint does not write message into log file?
I am really confused. It should not be hard to code such a simple logic.
seattleneil
Posts: 172
Joined: 02 Mar 2020 22:41

Re: Easy Scripting problem

Post by seattleneil »

Use console.log instead of debugPrint. Something like this:

console.log("My dimmer value = ",sensorValue);

I'm guessing your script is exiting on debugPrint. Kinda funny that the debug statement is the problem - the rest of your script looks correct.

Don't give up on EasyScripting - I find it to be the easiest way to support complicated automation logic. In addition, it's a very flexible way to support scenes. Something like this will switch a device on and off (using the same scene command):
### ZWayVDev_zway_XX-0-91-DS // Scene Control (XX)

var scene = vdev("ZWayVDev_zway_XX-0-91-DS").value();
console.log("In Scene Control (XX) - scene:", scene);

if (scene == "10" || scene == "1") {
if (vdev("ZWayVDev_zway_5-2-37").value() === "on") {
vdev("ZWayVDev_zway_5-2-37").off();
} else {
vdev("ZWayVDev_zway_5-2-37").on();
}
} else if (scene == "20" || scene == "2") {
if (vdev("ZWayVDev_zway_5-1-37").value() === "on") {
vdev("ZWayVDev_zway_5-1-37").off();
} else {
vdev("ZWayVDev_zway_5-1-37").on();
}
}
Post Reply