VoxCommando
Help and Support (Using VoxCommando) => VoxCommando Basics and Core Features => Topic started by: Foggy on January 08, 2017, 11:38:33 AM
-
I hope some one could help. I just can't get my head around sending Put commands through Voxcommando.
I want to send this command (Works sending through the Terminal)
curl -H 'Content-Type: application/json' -X PUT -d {"on":true} http://192.168.0.116:8080/api/username/lights/1602928626/state
Can you explain what goes where, when using the scrape.put command.
Best wishes.
-
Can you share the xml showing what you've tried in VC? It may not be you. The Scrape.Put action has not been extensively tested, though I've tried it with a few different Restful APIs without issue so far.
URL is your URL (http://192.168.0.116:8080/api/username/lights/1602928626/state).
-d in curlspeak is the datastring.
The content-type info should go in the "Content-Type" parameter field ... you can roll over the fields to see which one that is, or open the parameter helper (http://voxcommando.com/mediawiki/index.php?title=Parameter_Helper) window and enter it there.
In curlspeak, -H just means that you'll be defining a header parameter next (in this case, the content-type). VC defines that header for you already, as one of the optional parameters.
-
Thank you. I was fiddling a little more before your response.
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.2.9-->
<command id="68" name="Pause " enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
<action>
<cmdType>Scrape.Put</cmdType>
<params>
<param>http://192.168.0.116:8080/api/username/lights/1602928626/state</param>
<param>{"on":true}</param>
<param />
<param />
<param>Content-Type: application/json</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType />
<params />
<cmdRepeat>1</cmdRepeat>
</action>
</command>
This actually worked, but I got another error after this ran
Log Entry:
Scrape.Put:http://192.168.0.116:8080/api/username/lights/1602928625/state&&{"on":true}&&&&&&Content-Type: application/json
08/01/2017 16:18:06 260 Doing scrape put/post with headers:
Content-Type: Content-Type: application/json
08/01/2017 16:18:06 566 Action RESULT:
08/01/2017 16:18:06 566 Action is NOT threadsafe:
08/01/2017 16:18:06 566 action repeat set to: 1
08/01/2017 16:18:06 566 Action:
08/01/2017 16:18:06 566 addHistoryItem [action] :
08/01/2017 16:18:06 582 Action ERROR: Unknown base action:
-
Great. When you say the command works, do you mean that the lights are turning on?
The "unknown base action" error is because you have an extra empty action in your command. Not a problem. Deleting the empty action line will solve that error.
-
This looks like the Hue API. Is it?
If so, is there some reason you don't want to use the Hue plugin?
-
@ nime5ter Yes it does. I removed the entry from content type as on a second look I could see that it defaulted to default: application/json". Now the error is gone. Thank you for your help.
@jitterjames. Actually it is for HA-Bridge https://github.com/bwssytems/ha-bridge (https://github.com/bwssytems/ha-bridge)
It appears to be very powerful.
Best wishes.