Page 1 of 1

Standard Variables within Code-App (or other generic apps)

Posted: 08 Jan 2017 17:28
by klaasjoerg
Quick question to the ones, that developed already apps around zwave-me:
Are there basically a certain number of default variables accessible within a app e.g. specially a code-app?

e.g. If I want to generate a SMS or E-Mail (e.g. by using a URL-call via code device app) I would like to pass over some more dynamic informations e.g. Device-Names that generated/triggered the alert or other things...

How would this be easily possible without having to write a new dedicated app?

Ideas?

Re: Standard Variables within Code-App (or other generic app

Posted: 11 Jan 2017 00:43
by BobElHat
You can store things in the metrics for the device. e.g. if you create a code device with a toggle button you could store something like so:

Code: Select all

controller.devices.get("Code_Device_toggleButton_118").set("metrics:mydata","whatever I want to store");

Re: Standard Variables within Code-App (or other generic app

Posted: 11 Jan 2017 01:12
by klaasjoerg
Thanks, but I was also wondering if there are default variable/objects I can access from any app/device without "saving/storing" first. Bascially I want to do the opposite. Simply use possibly existing informations to use them within different modules dynamically...

Re: Standard Variables within Code-App (or other generic app

Posted: 11 Jan 2017 02:36
by BobElHat
Yes, there's a lot you can access. There are links to documentation at the bottom of the Github repo.

I suggest you browse around the API docs to get a feel for what's available, it's trivial to get JSON dumps of the internal state of devices, modules, notifications etc. that way.

If you want to access things with JS from a code device or module have a look at the module developer documentation and maybe browse the code of some of the existing modules to get an idea of the syntax for accessing devices, events etc.