Easy Scripting App - Documentation/Example

Discussions about Z-Way software and Z-Wave technology in general
captador
Posts: 14
Joined: 02 Dec 2016 22:02

Re: Easy Scripting App - Documentation/Example

Post by captador »

Probably code/js device is enough. Haven't tried them yet.

Then EasyScripting will be left as pure event-driven JS mechanism, although If->Then with JS device might work the same way.

I guess some wiki page at github about advance use cases above typical if-then/logical-rule/scene would be nice.

update: personally i am lazy to dive into developers guides and code suggestions of easyscript is too attractive. Plus i prefer to keep logic exposed as devices/scenes to have it as visual routines instead of logic buried into a code. In simple scenarios it works better than own app or script.
For now i made a dummy toggle device that is controlled by a scene and listened by easyscript. Without much rational thinking, it looks as preferable way for now.
ridewithstyle
Posts: 141
Joined: 02 Jan 2016 01:20

Re: Easy Scripting App - Documentation/Example

Post by ridewithstyle »

Hello Poltos,

I myself am also trying to expand my usage of easy Scripting (Halloween Season demands upgrades).

Currently I am trying to react to triggered scene (motion detection) and trigger some random scene out of a predefined set, as there currently is no such mechanism as app freely available. Things I would normally use in any

/dev/urandom % no_of_secenes
case statement with enumerated scenes to trigger

So yea, listening to a scene from the easyscripting app would be awesome, also being able to trigger scenes from the app. Without I would need a dummy switch that is being triggered from the scene which triggers easyscripting which then triggers a different switch that triggers a scene. A lot of functionally redundant scene-switch-app-switch-scene translation work because easy scripting doesn't work with scenes (yet).

As foreign language develeoper, your eventually mentioned code/js is probably the best way to go forward but just as with easyscripting initially, I lack the proper kickstarter/example/template to adapt and evolve from.

regards,
rws
User avatar
PoltoS
Posts: 6338
Joined: 26 Jan 2011 19:36

Re: Easy Scripting App - Documentation/Example

Post by PoltoS »

@ridewithstyle Easy Scripting can listen for Scenes activation too - exactly like for motion sensor. So no need in additional Dummy Devices. Just enable the scene and it will trigger EasyScripting code.

BTW, instead of /dev/urandom use Math.random() < 1/N (for N % probability). I don't think you need a so good random generator for Halloween ;)))

Also check for random (in search field) on http://developer.z-wave.me/?uri=public#/web/apps
ridewithstyle
Posts: 141
Joined: 02 Jan 2016 01:20

Re: Easy Scripting App - Documentation/Example

Post by ridewithstyle »

PoltoS wrote:
26 Oct 2020 19:58
@ridewithstyle Easy Scripting can listen for Scenes activation too - exactly like for motion sensor. So no need in additional Dummy Devices. Just enable the scene and it will trigger EasyScripting code.

BTW, instead of /dev/urandom use Math.random() < 1/N (for N % probability). I don't think you need a so good random generator for Halloween ;)))

Also check for random (in search field) on http://developer.z-wave.me/?uri=public#/web/apps
Hi PoltoS,

thanks for the reply, always happy when you point out the obvious like Math.random() - no sarcasm - because I feel stupid about not knowing the JavaScript Basics. Seems like I really need to find the time for a JavaScript online course. And - btw - my Halloween setup was to be reckoned with.

Remote Doormat triggered and ESP8266 MQTT client that fed my scene into ZWay. After that, smoke machine, strobe lights, crawling Zombies, Screaming and Moving Ghosts and - my personal favourite - my Dimmer-based Audio boxes. Those Boxes pretend to be a dimmer: 0-7 is volume, 99 is reboot, everything in between is taken as index from an attached SD-Card. Hence the "random" scene need, round robin seemed too trivial.

But I digress...

Thanks!

edit: Seems I have been missing out because I use Firefox and only rely on the documentation. The fancy addition is only possible in chrome so adding

Code: Select all

### DummyDevice_1XX // your-name-here
or in my case

Code: Select all

### LightScene_1xx// your-name-here
to documentation would be nice and would have saved my question. Also

Code: Select all

console.log("yourdebug")
would've saved me some time. It might seem trivial to JavaScript-Devs but to someone coming to ZWay without that it would help. Thx


rws
malik123
Posts: 1
Joined: 20 Nov 2020 18:22

Re: Easy Scripting App - Documentation/Example

Post by malik123 »

For what reason to that? You cavern Code Device and JS Code application for this. In the event that you need it since you like EasyScripting language structure partners, indeed, a spurious scene will be the arrangement. We can improve EasyScripting to add a checkbox to make a Dummy Scene directly from the EasyScripting. Is it something beneficial?
ridewithstyle
Posts: 141
Joined: 02 Jan 2016 01:20

Re: Easy Scripting App - Documentation/Example

Post by ridewithstyle »

malik123 wrote:
20 Nov 2020 18:25
Is it something beneficial?
Not sure if that would be beneficial, really
ridewithstyle
Posts: 141
Joined: 02 Jan 2016 01:20

Re: Easy Scripting App - Documentation/Example

Post by ridewithstyle »

the device access provides value() to work with the latest device value that has been cached in zway. If I want to poll a sensor, is there a way to trigger a device update? .get() and .update() don't work apparently.

Is there a documentation of all the members? Crawling through the index.js I found only
2021-02-01 10_02_28-Window.png
2021-02-01 10_02_28-Window.png (3.93 KiB) Viewed 1554 times
Can I add a

Code: Select all

 vDevWrapper.prototype.update = function() {
                 this.dev.performCommand("update");
        };
or would that be too easy thinking?
User avatar
PoltoS
Posts: 6338
Joined: 26 Jan 2011 19:36

Re: Easy Scripting App - Documentation/Example

Post by PoltoS »

yes, you can add this and even make a pull request in Git ;) Thanks for your contribution!
ridewithstyle
Posts: 141
Joined: 02 Jan 2016 01:20

Re: Easy Scripting App - Documentation/Example

Post by ridewithstyle »

Happy this worked, seemed too simply at first. Pull request is made
henning
Posts: 2
Joined: 13 May 2021 16:29

Re: Easy Scripting App - Documentation/Example

Post by henning »

Hi folks,

sorry if that sounds stupid, but how can I set a global variable in the Easy Scripting scope? I want to trigger a delayed action and be able to reset the timer, if the state of the device changes again.
eg:

Code: Select all

### ZWayVDev_zway_1-2-3 // Foo vdev

if(timerHandle === 'undefined') {
	var timerHandle = null;
}

function doSomething() {
...
	// 30 seconds delay
	timerHandle = setTimeout(function() {
		vdev("DummyDevice_01").on();	
	}, 30 *1000);
}

function dontDoIt() {
	if(vdev("DummyDevice_01").value() == "on") {
		// disable it again
		vdev("DummyDevice_01").off();
	} else {
		// well, no
	}	
}

if(vdev("ZWayVDev_zway_1-2-3").value() == "on") {
	doSomething();	
} else {
...
	if(timerHandle) {
		clearTimeout(timerHandle);
	}
	dontDoIt();
}
My problem is that the timerHandle is undefined, when the script gets called again and thus the clearTimeout function does nothing silently.
Is there a way to make the declaration persistent?

Thanks!
Henning
Post Reply