Easy Scripting App - Documentation/Example

Discussions about Z-Way software and Z-Wave technology in general
micky1500
Posts: 298
Joined: 07 Feb 2016 16:29
Location: England

Re: Easy Scripting App - Documentation/Example

Post by micky1500 »

After some testing, I have feedback.

Think this script needs a caviet.
Run a check on values before sending a response to z-way.

I did a test with my devices and with ridewithstyle's example.
ignore the names of devices, its just a test.

It works, If my house power consumption exceeds 600 Watts, then a light turns on.
it then turns off when below 600W.
oops. Then it also turns the light off every 20 seconds, even though the light is already off.
and it does this every 20 seconds - forever.


My test script.
var thermostat_sensor_device = vdev("ZWayVDev_zway_124-1-50-2")
var thermostat_target_temperature_device = vdev("ZWayVDev_zway_36-0-38")
var dad_target_dummydevice = vdev("DummyDevice_46")

//Get Sensor Value
var sensorValue = thermostat_sensor_device.value()
var targetValue = thermostat_target_temperature_device.value()
var targetDadValue = dad_target_dummydevice.value()

//Reduce Target Temperature according to Dad Mode
if (sensorValue > 600) {
thermostat_target_temperature_device.set(targetValue + 1)
}
else {
thermostat_target_temperature_device.set(targetValue = 0)
}
Raspi 4 - (Buster - 32 Bit) Zwave Version 4.1.1, Raz 7 Pro, Serial API Version: 07.38
aivs
Posts: 68
Joined: 04 Mar 2011 15:26

Re: Easy Scripting App - Documentation/Example

Post by aivs »

Hi, I think the problem in your algorithm.
You device sends energy report every 20 seconds and every time start your script -> If power consumption belom 600, then light off.
You need additional check like this -> if light already off do not light off.
ridewithstyle
Posts: 155
Joined: 02 Jan 2016 01:20

Re: Easy Scripting App - Documentation/Example

Post by ridewithstyle »

Hi micky1500,

regarding your sample code, you need an additional check if the targetValue != 0 prior to setting it to 0.

Regards,
rws
micky1500
Posts: 298
Joined: 07 Feb 2016 16:29
Location: England

Re: Easy Scripting App - Documentation/Example

Post by micky1500 »

Ok. I agree
I was testing it out.
So people need to be advised that they need to include additional checks in their coding.
So Easy Scripting isn't as easy after all.

Regards,
Micky.
Raspi 4 - (Buster - 32 Bit) Zwave Version 4.1.1, Raz 7 Pro, Serial API Version: 07.38
ridewithstyle
Posts: 155
Joined: 02 Jan 2016 01:20

Re: Easy Scripting App - Documentation/Example

Post by ridewithstyle »

Well, your code is semantically correct, just not as efficient as it could be. Without event tracing you wouldn't even have noticed. Don't be too hard on yourself, the majority of code is imperfect, hence the need for peer review. Keep it up :-)

I am looking forward to sharing and exchanging cool snippets.

Best regards,
rws
micky1500
Posts: 298
Joined: 07 Feb 2016 16:29
Location: England

Re: Easy Scripting App - Documentation/Example

Post by micky1500 »

Might have noticed with a slow system !
Hey. It was your example code I stole and tried.

I was just trying it out for fun. Spare time now days.
Feedback is good.

I try things, never said I knew what i as doing !

Kind regards,
Micky
Raspi 4 - (Buster - 32 Bit) Zwave Version 4.1.1, Raz 7 Pro, Serial API Version: 07.38
ridewithstyle
Posts: 155
Joined: 02 Jan 2016 01:20

Re: Easy Scripting App - Documentation/Example

Post by ridewithstyle »

Most code is stolen, don't worry. And I shared mine because I wanted others to engage, so no harm there. I used to code for a living, I enjoy the little flashbacks now and then. Notice that I only updated my value if there was a change needed. Feel free to continue and shared your experience
ridewithstyle
Posts: 155
Joined: 02 Jan 2016 01:20

Re: Easy Scripting App - Documentation/Example

Post by ridewithstyle »

ok, ssh is pretty much restricted for security reasons, that reduced my time to debug.

PoltoS, I added debugPrintStack, where do I find the dump? The log doesn't show anything
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

Re: Easy Scripting App - Documentation/Example

Post by PoltoS »

It should go in the log
Xan
Posts: 3
Joined: 31 May 2020 22:54

Re: Easy Scripting App - Documentation/Example

Post by Xan »

Hi PoltoS,

Wondering whether you can help me... I'm trying to use Easy Scripting in order to "bind" two dimmers together. In other words, when one of my dimmers is set to whatever level, I want the other one to be set there too.

It seems like this should be very simple. I came up with this:

Code: Select all

###ZWayVDev_zway_18-0-38

vdev("ZWayVDev_zway_5-0-38").set(vdev("ZWayVDev_zway_18-0-38-1").value())
But I get a "Loop detected" error in my event log when I adjust the dimmer. I don't really see a loop here...
Post Reply