Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IFTT and HTTP Trigger parameter passing setup
#1
Hi Guys,  I need a steer on how to get IFTT to send a URL with a parameter in the HTTP get URL that CQC can parse and use as a variable.  i.e. How can I send something like set volume to 22 and then use one http trigger to get all the range from 0-100 with a variable / action parameter?

I'm stuck on syntax I think and my searching hasn't helped with an answer.  The HTTP trigger driver has mostly generic info on setting up blaster type devices from what I see.

In IFTT I have set up a webhooks configuration with googlehome trigger of say a phrase with a number. The URL field is set as http://ip:port/CQSL1Volume {{NumberField}}   The numberfield portion should contain whatever volume I tell Google to set CQC to.

I am assuming that translates to an actual URL of http://ip:port/CQSL1Volume22  assuming I said set volume to 22.  With that though I don't think CQC sees the 22 as a variable.

I have CQC's http trigger trained on http://ip:port/CQSL1Volume

I'm stuck on what syntax needs to be in the URL following the trigger command to be seen as a parameter.  I think if done right that 22 would then be available within %(LVar:CQCActParm_2) . Is that correct?

I tried just a space after volume with the number and no luck.  Should it be a , # or what is required here?

Thanks
Reply
#2
It has to be URL query parameters, so :

http://ip:port/CQSL1Volume?val=22

The query parameter names don't matter. They can be ?1=x&2=y and so on.
Dean Roddey
Software Geek Extraordinaire
Reply
#3
Works like a charm, thanks.

For anyone finding this in future.  Here's a quick and dirty synopsis on the steps I took to get IFTTT to send a command with a variable to CQC via Google home:

1. Install HTTP Trigger driver and note the external ip/port it is listening on. You'll have to expose that port and forward your external ip to the CQC server on your router as well. - not 100% safe to do from a security perspective... weigh the risk.
2. Setup an IFTTT account and a google home.
3. Create a new applet within IFTTT and for the THEN portion pick Google Assistant - Say a phrase with a number (text ingredient should work as well)
4. Input the command info you want Google Home to pick up on like "Set the CQC music to $" - Create the trigger. (the "$" is where you'll say the variable name - like Play or Pause)
5. Create the THAT portion and select webhooks - make a web request
6. For URL put in http://<your ip>:CQCport/command_name?var1=
7. After the = sign add in the variable - in the IFTTT web interface click add ingredient and select text field, IFTTT will sub in a block called text field where the variable will be inserted via voice command and CQC will be able to utilise it.
Other paramaters:
Method = Get
Content = text / plain
click create action
Finish
8. Now setup the HTTP trigger portion by training it to do an action when IFTTT hits the CQC trigger with: http://ip:port/command_name?var1=
For this use Firefox (or maybe IE) and just type in the URL as above when the HTTP trigger driver is in training mode and send it via enter key a few times.  (Chrome didn't work for me - it sends some other junk in the get request) You may have to send it a few times before it accepts it.
9. If all went well CQC should perform whatever action you set the HTTP trigger driver to perform when receiving that url from IFTTT.
10. The variable portion of what you put after the ?var1= part is available in an action via action parameter 2 (%(LVar:CQCActParm_2) - so you can say set music to: with pause or play as the variable and then sub those into a transport command via Action Parm 2 like:
Devices::FieldWrite
    P1=SRC1_CQSLMedia.Transport
    P2=%(LVar:CQCActParm_2)
    P3=True

tips/gotchas:
- CQC commands seem to be case sensitive, the variables seem to be substituted from IFTTT into the URL as lower case. 
- watch for spaces in the URL's when you create them as they'll come across as %20 and commands may not work

Here's what I did to change lower to upper case for transport commands:

// Need to have actparm2 to have a capital letter at the beginning.  this puts the first letter in actparm2 and remainder in transport variable for later manipulation
LocalVars::CreateVariable
    P1=LVar:ActParm2
    P2=String
    P3=
    P4=%(LVar:CQCActParm_2)

LocalVars::CreateVariable   <--Is not necessary
    P1=LVar:Transport
    P2=String
    P3=
    P4=

LocalVars::SplitAt
    P1=LVar:ActParm2
    P2=LVar:Transport
    P3=1

LocalVars::ToUpperCase
    P1=LVar:ActParm2

LocalVars::Insert
    P1=LVar:Transport
    P2=%(LVar:ActParm2)
    P3=0

Devices::FieldWrite
    P1=Variables.TestString
    P2=%(LVar:Transport)
    P3=True

Devices::FieldWrite
    P1=SRC1_CQSLMedia.Transport
    P2=%(LVar:Transport)
    P3=True
Reply
#4
Just FYI, for the LVar:Transport variable above, there's no need to create it. It's just a string type, so it will be created implicitly when you use it as the target of the SplitAt command. Any time you give a variable as a target, and it doesn't exist, it will be created for you as a string type. You only need to explicitly create them if you want to give them a non-string type or to set limits on them.
Dean Roddey
Software Geek Extraordinaire
Reply
#5
(03-09-2018, 07:04 PM)Dean Roddey Wrote: Just FYI, for the LVar:Transport variable above, there's no need to create it. It's just a string type, so it will be created implicitly when you use it as the target of the SplitAt command. Any time you give a variable as a target, and it doesn't exist, it will be created for you as a string type. You only need to explicitly create them if you want to give them a non-string type or to set limits on them.

Good point thanks! Edited the post to reflect.

Something else I was going to point out so you can edit next time you're in the docs.  The SplitAt command is referenced as Split in the docs still. @ http://www.charmedquark.com/Web2/CQCDocs.../Variables
Reply
#6
Oops, OK, I'll fix that.
Dean Roddey
Software Geek Extraordinaire
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  CQC Voice setup IVB 4 154 06-02-2018, 09:34 AM
Last Post: Dean Roddey
  HTTP Post zra 7 287 05-18-2018, 08:47 AM
Last Post: zra
  SSL certificate for HTTP trigger driver RichardU 7 736 01-16-2018, 09:50 AM
Last Post: Dean Roddey
  Echo setup: Backslash now slash in EchoCfg.TXT IVB 3 399 01-13-2018, 05:14 PM
Last Post: Dean Roddey
  Generate Random Number in a Trigger batwater 1 269 12-10-2017, 12:43 PM
Last Post: Dean Roddey
  Passing device name as variable jokermac 12 1,551 11-18-2017, 12:38 PM
Last Post: jokermac
  Writing to an external file from trigger event Ira 21 2,912 11-13-2017, 02:08 PM
Last Post: znelbok
  Zwave via http put kfly 6 1,424 11-07-2017, 07:57 AM
Last Post: kfly
  Simple field change trigger action Bugman 15 2,611 10-23-2017, 11:55 AM
Last Post: Dean Roddey
  Additional HTTP REST commands requested greymatter 3 910 08-25-2017, 09:17 AM
Last Post: Dean Roddey

Forum Jump:


Users browsing this thread: 1 Guest(s)