Controlling devices via API / HTTP

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
ihagon
Posts: 5
Joined: 17 Aug 2011 19:43

Controlling devices via API / HTTP

Post by ihagon » 09 Apr 2012 20:27

Is there a way to perform some sort of API call to activate scenes or switch devices outside of the GUI?

What I'm thinking here is if I have a small script that runs locally and I want it to have the ability to ask z-cloud to switch a device or scene or report the status of a device based on a local trigger is that possible?

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

Please read related posts

Post by PoltoS » 09 Apr 2012 20:27

Z-Cloud supports external API. Read this article with detailed description of the API.Some examples are also available on th forum.

ihagon
Posts: 5
Joined: 17 Aug 2011 19:43

Perfect, just what I was

Post by ihagon » 09 Apr 2012 20:27

Perfect, just what I was looking for but not finding :o)

Thanks

ihagon
Posts: 5
Joined: 17 Aug 2011 19:43

got it

Post by ihagon » 09 Apr 2012 20:27

Okay I figured it out so posting this for others too

To set a Dimmer full on
curl --user user:password --data " " "https://z-cloud.z-wave.me:port/ZWaveAPI/Run/devices[45].instances[0].commandClasses[0x26].Set(99)" -k

To set a dimmer off
curl --user user:password --data " " "https://z-cloud.z-wave.me:port/ZWaveAPI/Run/devices[45].instances[0].commandClasses[0x26].Set(0)" -k

The command can be found by opening the log window in network management turning on debug and then performing the command in the UI. The string you need should appear in there.

Still trying to figure out how I can pull the current value of the dimmer though. I can send the get command but I guess that just updates z-cloud and I then need a different command to read the updated value out.

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

All data is returned back using ZWaveAPIData tree

Post by PoltoS » 09 Apr 2012 20:27

You are right, Get() command just put a new job in the queue. It will be out as soon as it will reach it's turn and the device will (but not obliged to!) respond in some time.Our Z-Wave stack inside Z-Way engine is fully asynchronous. All the data are returned back into data tree that we call ZWaveAPIData. To get updates of this tree you have to make a POST request for /ZWaveAPI/Data/<timestamp>. To get everything use 0 for timestamp. The response is a JSON object that contains pairs (path, new value).The light level you need is located in devices[nodeID].instances[instanceID].SwitchMultilevel.data.level.value. As a hint, go in Expert commands and press on Command Class name. A window will be opened containing the data in hierarchical view (the subtree). It is quite flat for SwitchMultilevel, but is not for Configuration or Association Command Classes.Have fun!

Post Reply