Page 1 of 1

Extend Z-Way Api

Posted: 27 Aug 2014 19:25
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

Re: Extend Z-Way Api

Posted: 28 Aug 2014 11:12
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.

Re: Extend Z-Way Api

Posted: 29 Aug 2014 23:10
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

Re: Extend Z-Way Api

Posted: 30 Aug 2014 00:20
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.

Re: Extend Z-Way Api

Posted: 02 Sep 2014 14:06
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)

Re: Extend Z-Way Api

Posted: 02 Sep 2014 15:29
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.