Author Topic: Another Scrape question  (Read 2938 times)

0 Members and 1 Guest are viewing this topic.

Foggy

  • $upporter
  • Contributor
  • *****
  • Posts: 86
  • Karma: 4
    • View Profile
Another Scrape question
« 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.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Another Scrape question
« Reply #1 on: January 08, 2017, 12:08:35 PM »
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 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.
« Last Edit: January 08, 2017, 12:16:16 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Foggy

  • $upporter
  • Contributor
  • *****
  • Posts: 86
  • Karma: 4
    • View Profile
Re: Another Scrape question
« Reply #2 on: January 08, 2017, 12:20:41 PM »
Thank you. I was fiddling a little more before your response.

Code: [Select]
<?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

Code: [Select]
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:
« Last Edit: January 08, 2017, 12:29:04 PM by nime5ter »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Another Scrape question
« Reply #3 on: January 08, 2017, 12:25:53 PM »
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.
« Last Edit: January 08, 2017, 12:28:36 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Another Scrape question
« Reply #4 on: January 08, 2017, 12:33:44 PM »
This looks like the Hue API.  Is it?

If so, is there some reason you don't want to use the Hue plugin?

Foggy

  • $upporter
  • Contributor
  • *****
  • Posts: 86
  • Karma: 4
    • View Profile
Re: Another Scrape question
« Reply #5 on: January 08, 2017, 12:44:06 PM »
@ 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
It appears to be very powerful.

Best wishes.