Opening blinds every morning

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
jchabik
Posts: 5
Joined: 11 Oct 2014 22:22

Opening blinds every morning

Post by jchabik » 04 Oct 2015 15:09

I have a nice feature in my bedroom - I'm opening all blinds every morning. It was a Razberry adapter on RPi board, an entry in the crontab every working day at certain hour, executing

Code: Select all

wget call to wget -q --spider "http://192.168.1.200:8083/ZWaveAPI/Run/devices[13].instances[0].Basic.Set(80)"
This worked great before I upgraded to the newest version of Razberry and Z-way. Now the device needs an authentication so I needed to execute shell script instead of just plain wget comand. So I wrote an open_blinders.sh:

Code: Select all

curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"form": true, "login": "smarthome", "password": "<my password>", "keepme": false, "default_ui": 1}' localhost:8083/ZAutomation/api/v1/login -c cookie.txt
curl localhost:8083/ZAutomation/api/v1/devices/ZWayVDev_zway_13-0-38/command/set/80 -b cookie.txt
...and call it in crontab. Unfortunately it doesn't work. What did I do wrong? I feel this is the syntax in the second line... can you help?

islipfd19
Posts: 126
Joined: 07 Jul 2014 03:35

Re: Opening blinds every morning

Post by islipfd19 » 05 Oct 2015 13:34

This is how I call a command in my script.

The first is to save the cookie:

Code: Select all

curl http://<IP ADDRESS>:8083/ZAutomation/api/v1/devices/ZWayVDev_zway_28-0-49-3 -b /home/pi/cookie.txt -k
The second and third turn the device off and on:

Code: Select all

http://<IP ADDRESS>:8083/ZWaveAPI/Run/devices[$dev].instances[0].commandClasses[37].Set(0)

Code: Select all

http://<IP ADDRESS>:8083/ZWaveAPI/Run/devices[$dev].instances[0].commandClasses[37].Set(255)
This script actually compares the uptime associated with one of the sensors on the Aeotec multi-sensor and if it exceeds the expected time when the sensors was supposed to send an update it turns a power plug off and then back on. I've found the aeotec multi-sensors (the 4 in 1) to be very unreliable when powered from main. They work better when power from batteries but you end up replacing batteries every two weeks.

I also want to note that I have an anonymous user setup without a password that allows local login access. This allows me to save the cookie and execute the scripts.
Last edited by islipfd19 on 06 Oct 2015 17:17, edited 1 time in total.

jchabik
Posts: 5
Joined: 11 Oct 2014 22:22

Re: Opening blinds every morning

Post by jchabik » 05 Oct 2015 19:59

islipfd19 - thanks for your a quick answer.

This is another interface - ZWaveAPI (rather than ZAutomation). I know this one but I wasn't able to use it with curl. The trouble is I can't make it work with parantheses or square brackets. Escaping with '\' doesn't work. Any idea?

Also, thanks valuable insight regarding Aeotec multi-sensor. I gave them up due to unreliable behaviour. Nights here in Poland tend to be cold and below -5C batteries are dead after one night. I had an idea of replacing 4 AA batteries with permanent power supply but hearing what you say I will give that up.

islipfd19
Posts: 126
Joined: 07 Jul 2014 03:35

Re: Opening blinds every morning

Post by islipfd19 » 06 Oct 2015 17:28

What scripting language are you using? I'm using bash and have found the commands I provided work just fine; the $dev variable should have been replaced with the actual device id. I forgot to update it when I copied and pasted it. The same commands work in a web browser. My actual reply wasn't complete as I look into my script a bit more. I use a cron job to fetch the cookie every so often so that it doesn't expire.

Cookie

Code: Select all

curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"form": true, "login": "<USER>", "password": "<PASS>", "keepme": false, "default_ui": 1}' https://<IP ADDRESS>:8083/ZAutomation/api/v1/login -c /home/pi/cookie.txt -k
Command:

Code: Select all

curl --globoff --data POST "http://<IP ADDRESS>:8083/ZWaveAPI/Run/devices[29].instances[0].commandClasses[37].Set(0)"

Code: Select all

curl --globoff --data POST "http://<IP ADDRESS>:8083/ZWaveAPI/Run/devices[29].instances[0].commandClasses[37].Set(255)"

islipfd19
Posts: 126
Joined: 07 Jul 2014 03:35

Re: Opening blinds every morning

Post by islipfd19 » 06 Oct 2015 18:07

To expand on the Aeotec 4-in-1 multisensor, Aeotec has released a new 6-in-1 multisensor; though I did see a post of someone having difficulty in adding it to their system. I don't think I'm at a point to buying it and testing it out either.

pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: Opening blinds every morning

Post by pofs » 08 Oct 2015 19:52

You can just use basic auth after 2.1.2 rc's:

Code: Select all

curl -u admin:admin "http://192.168.1.200:8083/ZWaveAPI/Run/devices[13].instances[0].Basic.Set(80)"

jchabik
Posts: 5
Joined: 11 Oct 2014 22:22

Re: Opening blinds every morning

Post by jchabik » 14 Oct 2015 00:12

Thanks guys!

Do you know the equivalent using ZAutomation (rather than ZWaveAPI) syntax?

pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: Opening blinds every morning

Post by pofs » 15 Oct 2015 17:42

ZAutomation usually doesn't have Basic CC as a device if there's more specific command class (like Multilevel Switch) present, so there's no exact analog for your command. But here's something similar:

Code: Select all

.../ZAutomation/api/v1/devices/ZWayVDev_zway_13-0-38/command/exact?level=80

Post Reply