Page 1 of 1

http commands

Posted: 22 Jan 2016 22:02
by HendrikM
I am attempting to use http request to turn a light on/off but no success thus far. Is there any example code available?

I am new to Zwave and any information would be appreciated.

Thanks,

Re: http commands

Posted: 23 Jan 2016 01:51
by bogr

Re: http commands

Posted: 23 Jan 2016 04:22
by viper384
Multiple ways to skin a cat. I think it's better to use /ZwaveAPI rather than /ZAutomation, unless you want to control a automation group or something. In my example I am using device #5.

The command for a single switch on / off, once authenticated from a web browser.

Code: Select all

#on
http://127.0.0.1:8083/ZWaveAPI/Run/devices[5].instances[0].commandClasses[25].Set(255)
#off
http://127.0.0.1:8083/ZWaveAPI/Run/devices[5].instances[0].commandClasses[25].Set(0)
To do this from the command line you need to authenticate first and save a session cookie...

Code: Select all

wget -q --header "Accept: application/json" --header "Content-Type: application/json" --post-data '{"form":true,"login":"admin","password":"admin","keepme":false,"default_ui":1}' http://127.0.0.1:8083/ZAutomation/api/v1/login --keep-session-cookie --save-cookie /tmp/zway-cookie.txt -O - 1>&2 >/dev/null
Then you use that session cookie for all subsequent requests with --load-cookies.

Code: Select all

wget --load-cookies /tmp/zway-cookie.txt "http://127.0.0.1:8083/ZWaveAPI/Run/devices[5].instances[0].commandClasses[25].Set(255)" - O - 1>&2 >/dev/null
From my testing the session cookie will at last about 24 hours, or a z-way-server restart, which ever is first.

Re: http commands

Posted: 24 Jan 2016 02:44
by HendrikM
Thanks for the swift reply, I will try this.

Re: http commands

Posted: 26 Jan 2016 19:52
by bogr
viper384 wrote:Multiple ways to skin a cat. I think it's better to use /ZwaveAPI rather than /ZAutomation, unless you want to control a automation group or something.
Define "better" ;)