Zway JS Apps

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
User avatar
marco
Posts: 67
Joined: 03 Dec 2015 19:50

Zway JS Apps

Post by marco »

Dear All,
I’m writing because I’m searching to deep some zway Apps. I looked around to find some example of using JS Apps (Load custom JavaScript code, Load custom JavaScript code for Z-Wave application and Load custom JavaScript file) but I wasn’t able to find something useful to me.
Could you please post some basic indications on how they work and some simple example to quickly test them using common devices (such as binary switch)?
Thanks
Marco
Marco

User avatar
PoltoS
Posts: 5886
Joined: 26 Jan 2011 19:36

Re: Zway JS Apps

Post by PoltoS »

May be CodeDevice is something you want to start with?

User avatar
marco
Posts: 67
Joined: 03 Dec 2015 19:50

Re: Zway JS Apps

Post by marco »

Hi,
Actually I was looking for something like the following:

Load custom Java Script Code

zway.devices[26].instances[0].DoorLock.data.mode.bind(function() {
var status = (zway.devices[26].instances[0].DoorLock.data.mode.value);
if (status == false)
zway.devices[5].instances[0].commandClasses[0x20].Set(255);
});

This simple code turn ON a light when someone unlock the door.

May be I'm wrong but I think that Code Device is not so useful for this kind of action.
Thank you in any case
Marco
Marco

User avatar
PoltoS
Posts: 5886
Joined: 26 Jan 2011 19:36

Re: Zway JS Apps

Post by PoltoS »

Yes, binding is better to do here. But note that on start this code starts before Z-Wave binding, so you need to stop-start it. Another solution will be to use new module with similiar name instead (will work in next RC)

Plainsane
Posts: 81
Joined: 20 Apr 2015 01:22

Re: Zway JS Apps

Post by Plainsane »

I'm curios, would the if the rule work for you?

bogr
Posts: 180
Joined: 16 Nov 2015 22:46

Re: Zway JS Apps

Post by bogr »

marco wrote: Load custom Java Script Code
Did you get the JavaScript module to work? I've just had bad experience with this so it would be interesting to hear about your solution.

User avatar
marco
Posts: 67
Joined: 03 Dec 2015 19:50

Re: Zway JS Apps

Post by marco »

Hi,

to Plainsane
Yes, the if rule work fine. Some problem happen sometime but they'r not related to the rule.

to Bogr
Yes I can state that JS Apps work fine for me. Since beginning, every day, 2 Schedule modules turn ON/OFF a light. A JS module send me an email on that light activity. No fault till now.
Marco

Post Reply