Page 3 of 6

Re: Easy Scripting App - Documentation/Example

Posted: 04 May 2020 21:43
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)
}

Re: Easy Scripting App - Documentation/Example

Posted: 05 May 2020 13:21
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.

Re: Easy Scripting App - Documentation/Example

Posted: 06 May 2020 11:06
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

Re: Easy Scripting App - Documentation/Example

Posted: 06 May 2020 20:22
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.

Re: Easy Scripting App - Documentation/Example

Posted: 06 May 2020 20:27
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

Re: Easy Scripting App - Documentation/Example

Posted: 06 May 2020 20:46
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

Re: Easy Scripting App - Documentation/Example

Posted: 06 May 2020 20:52
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

Re: Easy Scripting App - Documentation/Example

Posted: 24 May 2020 00:26
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

Re: Easy Scripting App - Documentation/Example

Posted: 26 May 2020 05:18
by PoltoS
It should go in the log

Re: Easy Scripting App - Documentation/Example

Posted: 31 May 2020 22:56
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...