HTTPd Plugin (useful for IFTTT Maker integration)

Posted on
Sat Nov 26, 2016 2:24 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

HTTPd Plugin (useful for IFTTT Maker integration)

First test release available here: https://github.com/FlyingDiver/Indigo-H ... tag/v0.0.1

Per the readme, the plugin needs to be configured with a port number, user name, and password. Then your router needs to be configured to forward the the specified port. You must use a port number > 1024 in the plugin. Your external port can be anything your router allows.

Here's an example URL to use to activate the plugin:

Code: Select all
http://username:password@my.domain.org:5566/setvar?foo=bar&zig=zag

The username, password, and port are as set in the plugin. The server name is whatever you have set up for the external name of your router, usually some sort of Dynamic DNS service.

For this release, the only "action" the plugin will do is "/setvar". This will set the specified variables to the values given. For protection, the variables have "httpd_" prepended to the names provided. In this case, the Indigo variable "httpd_foo" would be set to "bar", and the Indigo variable "httpd_zig" would be set to "zag". If they don't exist, the variables are created in an "HTTPd" variable folder.

I've tested this on my local LAN, and I've also tested it using my dynamic DNS name coming through my server. It works fine. But I have not been able to get IFTTT to send the request yet. I'm not an experienced IFTTT user, so I might have set it up wrong.

Running on local lan:

Code: Select all
Shamu:~ jkeenan$ curl "http://username:password@miniserver.local:5566/setvar?foo=bar&zig=zag"
<html><head><title>Indigo HTTPd Plugin</title></head></body></html>
Shamu:~ jkeenan$

Results in Indigo Log:
Code: Select all
   HTTPd Debug                     AuthHandler: authorized do_GET: /setvar?foo=bar&zig=zag
   HTTPd Debug                     AuthHandler: setting variable httpd_zig to zag
   HTTPd Debug                     AuthHandler: setting variable httpd_foo to bar


I'll need some help trying to figure out what I'm doing wrong with the IFTTT setup. Maybe I'm not returning headers or request body the way they want.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Nov 26, 2016 2:44 pm
ChopOMatic offline
Posts: 110
Joined: Sep 12, 2014

Re: HTTPd Plugin for IFTTT Maker integration

Huge thanks, Joe! Will definitely be trying this out in a little while!

Posted on
Sat Nov 26, 2016 9:24 pm
ChopOMatic offline
Posts: 110
Joined: Sep 12, 2014

Re: HTTPd Plugin for IFTTT Maker integration

No luck yet, Joe. The IFTTT applet is firing, but I don't see any indication of anything happening in the Indigo event log and no variables are being created.

The screenshots show the fields available when configuring the IFTTT applet using the Maker service and the type of web action available.

Any ideas?
[img]
https://www.dropbox.com/s/q33f558eruvbm ... r.png?dl=0[/img]

Image
Attachments
ifttt-maker.png
ifttt-maker.png (68.25 KiB) Viewed 10532 times

Posted on
Sat Nov 26, 2016 9:26 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: HTTPd Plugin for IFTTT Maker integration

Same result I'm getting. The plugin works, as evidenced by the curl commands running in Terminal. But there's something about the IFTTT channel action that's not working. And I can't find anything on IFTTT about how to troubleshoot those actions.

Oh, and the setvar, etc needs to go on the end of the URL, not in the request body.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Nov 27, 2016 2:17 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: HTTPd Plugin for IFTTT Maker integration

Yeah, if you can't do port forwarding you're not going to get this to work. My problem is that I can set up the forwarding, but I still can't it to work from the external sites I can test from. Inside the LAN works, and so does the external interface of the router using NAT loopback.

But I CAN get normal http access to my mac OS X Server to work from external sites. Very strange.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Nov 27, 2016 2:41 pm
ChopOMatic offline
Posts: 110
Joined: Sep 12, 2014

Re: HTTPd Plugin for IFTTT Maker integration

Got port forwarding working. Had to bypass the dynamic DNS and go straight to my current IP. Still no joy.

Using curl locally, I'm getting an authentication error:

Code: Select all
HTTPd Debug                     AuthHandler: do_GET with invalid Authorization header: /setvar?foo=bar&zig=zag


I'm using the exact curl syntax copied from your first post, Joe, obviously with my info substituted.

Posted on
Sun Nov 27, 2016 4:49 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: HTTPd Plugin for IFTTT Maker integration

I was finally able to get this to work this afternoon. I think most of the issues were internal firewall issues on my Indigo machine.

On IFTTT, the "Make a Web Request" part of the applet is:

URL: http://<username>:<password>@<your computer address>:<port>/setvar?<variable>=<value>

It's the same format I posted before. It was always correct, I think. The only thing that's really variable is the port number. Most anything you're not already using over 1024 should work, I'm currently using 5555.

Method should be "GET". Content Type should be "test/plain". Body should be empty.

Now set up the plugin. You need to specify the username and password that you're using in IFTTT. You also need to specify at port number. You can use the same port number for external (IFTTT) and internal (the plugin), but you don't have to unless your router doesn't handle translating the number. Some seem very limited that way.

Here's the real trick - you need to make sure you that any firewalls on the Indigo system are configured to let connections on your internal port number through. I think this is what was keeping my system from working properly.

Lastly, set up port forwarding on your router from the external port you specified on IFTTT to the internal port in the plugin, and the IP address of your Indigo server.

Honestly, this is not something I would expect a non-networking savvy person to do.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Nov 27, 2016 4:50 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: HTTPd Plugin for IFTTT Maker integration

ChopOMatic wrote:
Got port forwarding working. Had to bypass the dynamic DNS and go straight to my current IP. Still no joy.

Using curl locally, I'm getting an authentication error:

Code: Select all
HTTPd Debug                     AuthHandler: do_GET with invalid Authorization header: /setvar?foo=bar&zig=zag


I'm using the exact curl syntax copied from your first post, Joe, obviously with my info substituted.


If you're getting that message, then the username and password you specified in the plugin config don't match what you're putting in the curl command.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Nov 27, 2016 8:51 pm
ChopOMatic offline
Posts: 110
Joined: Sep 12, 2014

Re: HTTPd Plugin for IFTTT Maker integration

Got it going, Joe! My problem was the port. Something else was obviously already using the original (8088) port I had configured. Switched it to another port and it worked on the first try. THANKS.

Now I just need to freshen up on how to make Indigo do things based on a variable being set. :)

Any plans to extend the plugin to directly perform actions?

This is gonna be huge!

Posted on
Sun Nov 27, 2016 8:55 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: HTTPd Plugin for IFTTT Maker integration

ChopOMatic wrote:
Any plans to extend the plugin to directly perform actions?


Possibly, but I'm really concerned about the security of the interface. Directly performing actions could be very dangerous. Being able to set random variables, not so much.

And you can set multiple variables with one action. And set up multiple applets doing different things. So I think it's pretty flexible.

And, yeah, 8088 was obviously a really bad choice on my part. I didn't realize it was commonly used for something.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Nov 27, 2016 10:41 pm
ChopOMatic offline
Posts: 110
Joined: Sep 12, 2014

Re: HTTPd Plugin for IFTTT Maker integration

No worries on the actions. I'm refreshed and it's easy to do whatever I want with variables. You rock, sir.

Now I just need to figure out how to send a similar web request FROM Indigo. That will let me trigger Tasker on my phone to handle the few things I can't do directly from within Indigo. (UPDATE: Easy as pie with an AppleScript. Done.)

Again, thanks so much, Joe. If I can do anything to help you, lemme know!

Posted on
Mon Nov 28, 2016 9:51 am
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Re: HTTPd Plugin for IFTTT Maker integration

Really glad someone bumped this up to visibility. This is exactly what I need to get SmartThings talking directly to Indigo!

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Mon Nov 28, 2016 9:58 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: HTTPd Plugin for IFTTT Maker integration

ChopOMatic wrote:
Now I just need to figure out how to send a similar web request FROM Indigo. That will let me trigger Tasker on my phone to handle the few things I can't do directly from within Indigo. (UPDATE: Easy as pie with an AppleScript. Done.)


Probably just as easy with Python, and more future proof. Something like:

Code: Select all
import requests

requests.get("https://maker.ifttt.com/trigger/<<your applet>>/with/key/<<your key>>")

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Nov 28, 2016 10:17 am
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Re: HTTPd Plugin for IFTTT Maker integration

You can also do this with an URL Extension via the EPS Device Extensions plugin. This has the advantage of making an Indigo device that sends the URL. It can send a different one for on and off and toggle. This is why I said talking TO IFTTT is easy. Getting IFTTT to talk to Indigo was the problem before I saws the HTTPd plugin.

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Mon Nov 28, 2016 1:30 pm
Woetjes offline
Posts: 117
Joined: Apr 04, 2016
Location: Belgium

Re: HTTPd Plugin for IFTTT Maker integration

Thanks Joe - I've got it working. I was planning to use this to connect my Ring doorbell to Indigo but it seems there is a 15m delay from IFTTT... so not really ideal in this case.
Will use your betteremail plugin in this case as that is almost instant :)

Who is online

Users browsing this forum: No registered users and 0 guests