Extend Z-Way Api

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
raZcherry
Posts: 11
Joined: 24 Jun 2014 01:14

Extend Z-Way Api

Post by raZcherry »

Hi All,

I want to extend the z-way api with new functionality. For example I define my api with method doSomething() under

Code: Select all

/ZWaveApi/myapi/doSomeThing()

like in z-way

Code: Select all

/ZWaveApi/Run/zway.controller.AddNodeToNetwork(1)

Another interesting way will be just extend the /ZWaveApi/Run/ with more methods.
One reason why I want to extend the api is,for example setting configuration parameters not like

Code: Select all

/ZWaveAPI/Run/devices[X].instances[Y].commandClasses[132].Set(1800,1)
but in another way like

Code: Select all

/ZWaveAPI/myapi/SensorName.Set(WakeUp, 1800)[/b]
So the user or any other system must only know a "name" of the sensor, the command he wants to set (WakeUp) and the value (1800).
Is this somehow possible? Maybe I can also capsulate that in a module.

Thanks in advance for your answers! ;)

Best Regards
raZcherry
Using: Z-Way v2.0.1-rc11 on Raspberry Pi
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: Extend Z-Way Api

Post by pofs »

Currently you cannot extend /ZWaveAPI.
But if you define a global JS function, it will be accessible via /ZAutomation/YourFunctionName (the rest of url is passed as an arg, so you can handle it as you want). Take a look at OpenRemoteHelpers module, it does nearly the same you want to do.

In upcoming version 2.0 you'll be able to add your handler for any kind of url, even to intercept built-in API requests.
martinisonline
Posts: 14
Joined: 07 Jul 2014 22:41

Re: Extend Z-Way Api

Post by martinisonline »

In upcoming version 2.0 you'll be able to add your handler for any kind of url, even to intercept built-in API requests.
Any news/release date for this 2.0 version? :D
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: Extend Z-Way Api

Post by pofs »

martinisonline wrote:
In upcoming version 2.0 you'll be able to add your handler for any kind of url, even to intercept built-in API requests.
Any news/release date for this 2.0 version? :D
We expect to release a first public build in a month or so. The core itself is ready, but it is not fully supported by web UI yet.
raZcherry
Posts: 11
Joined: 24 Jun 2014 01:14

Re: Extend Z-Way Api

Post by raZcherry »

Thank you pofs for your answer!
I can execute global method over /ZAutomation like:

Code: Select all

/ZAutomation/getSomething
and I can read params like:

Code: Select all

/ZAutomation/getSomething/param1/param2
Would it be possible to use this kind of calling and if so how can I get the params values ;)

Code: Select all

/ZAutomation/getSomething(param1, param2) 
Including a device, z-way uses exactly the same calling mechanism like:

Code: Select all

/ZWaveApi/Run/zway.controller.AddNodeToNetwork(1)
Using: Z-Way v2.0.1-rc11 on Raspberry Pi
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: Extend Z-Way Api

Post by pofs »

raZcherry wrote:Would it be possible to use this kind of calling and if so how can I get the params values ;)

Code: Select all

/ZAutomation/getSomething(param1, param2) 
Not for second level, as it takes everything between /ZAutomation/ and next slash as a function name to call. But it is possible for next level, like /ZAutomation/myapi/getSomething(param1, param2). The remaining part of url is passed into your function (myapi in this case), so may write it whatever you like. For example, you can call eval(), or parse it yourself.
Post Reply