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.
Easy Scripting problem
-
- Posts: 172
- Joined: 02 Mar 2020 22:41
Re: Easy Scripting problem
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();
}
}
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();
}
}