http commands

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
HendrikM
Posts: 2
Joined: 22 Jan 2016 21:31

http commands

Post 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,
viper384
Posts: 42
Joined: 18 Feb 2015 05:25

Re: http commands

Post 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.
HendrikM
Posts: 2
Joined: 22 Jan 2016 21:31

Re: http commands

Post by HendrikM »

Thanks for the swift reply, I will try this.
bogr
Posts: 190
Joined: 16 Nov 2015 22:46

Re: http commands

Post 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" ;)
Post Reply