HTTPd Plugin (useful for IFTTT Maker integration)

Posted on
Mon Jun 17, 2019 4:39 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: HTTPd Plugin (useful for IFTTT Maker integration)

Hi.
I have gotten a new gadget for my "brewery". This time it is a digital air lock that will count the bobbles and do several estimations based on that. The interesting thing is that this device supports webhooks, so it should be able to interface with Indigo.

The Plaato Airlock will send a POST request with a JSON object to the webhook every 5 minutes as long as it is connected to power and WiFi.
https://plaato.io/apps/help-center#!hc-values

The big question now, is it possible to use the HTTPd Plugin to interface this device?

/Håvard
Attachments
Capture.PNG
Capture.PNG (27.33 KiB) Viewed 3669 times

Håvard

Posted on
Mon Jun 17, 2019 5:42 am
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: HTTPd Plugin (useful for IFTTT Maker integration)

I don't use the HTTPd plugin--but if that doesn't work for you--you may be able to use the GhostXML plugin (which also works with JSON payloads).

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Jun 17, 2019 7:43 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: HTTPd Plugin (useful for IFTTT Maker integration)

haavarda wrote:
The big question now, is it possible to use the HTTPd Plugin to interface this device?


Yes.


Oh, you want to know how? ;)

FIrst, set up the HTTPd plugin. Make sure you fill in the DDNS name field. If the device is on the local LAN, and it's the only device you're using with the plugin, you can use the local address of the Indigo server instead of a DDNS name. Something like "http://<indigoservername>.local/" or "http://192.168.1.101/".

Test that the HTTPd plugin is working properly. Use 'curl' in the Terminal window to test it, don't use a browser.

Something like this with set a variable named http_foo:

Code: Select all
curl  http://192.168.1.101:5555/setvar?foo=bar


Once you're sure that's working, create an HTTPd device of type WebProxy. Then create a trigger for HTTPd Events -> Proxy Request Received for that device. Set the action to run a Python script:
Code: Select all
httpPlugin = indigo.server.getPlugin("com.flyingdiver.indigoplugin.httpd")
if httpPlugin.isEnabled():
    hook_data = httpPlugin.executeAction("getWebhookData", deviceId=1375148185)
    indigo.server.log("Webhook Payload:\n{}".format(hook_data))


Look at the Web Proxy device custom device states, and get the http state value. Use it to test again, something like:

Code: Select all
curl  -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" http://192.168.1.101:5555/webhook-1375148185


You should see something like this in the log:

Code: Select all
   Script                          Webhook Payload:
Data : (dict)
     payload : (dict)
          key1 : value1 (string)
          key2 : value2 (string)
     request : (dict)
          client : 192.168.1.101 (string)
          command : POST (string)
          headers : (dict)
               accept : */* (string)
               authorization : Basic aG9va191c2VyOmhvb2tQYXNzMTAx (string)
               content-length : 34 (string)
               content-type : application/json (string)
               host : 192.168.1.101:5555 (string)
               user-agent : curl/7.54.0 (string)
          path : /webhook-1375148185 (string)
     vars : (dict)


If you get that, the web hook is working. Now you need to tell your device to use that URL for the webhook. I didn't see anything in the link you posted on how that's done. Maybe it's in the Plaato app.

You'll need to parse the payload part of the webhook data for your data. That's not too hard in Python. Depends on what you want to do with it.

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

Posted on
Mon Jun 17, 2019 7:48 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: HTTPd Plugin (useful for IFTTT Maker integration)

DaveL17 wrote:
I don't use the HTTPd plugin--but if that doesn't work for you--you may be able to use the GhostXML plugin (which also works with JSON payloads).


That would probably work if he wants to poll the analyzer, rather than use the webhook capability. Which honestly would seem to make more sense in this application. Webhooks are good for asynchronous event data, but they add a lot of complexity for something that's you just want to monitor on a fixed schedule.

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

Posted on
Mon Jun 17, 2019 8:12 am
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: HTTPd Plugin (useful for IFTTT Maker integration)

An excellent point.


Sent from my iPhone using Tapatalk

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Jun 18, 2019 3:53 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: HTTPd Plugin (useful for IFTTT Maker integration)

Thank you for your reply and input FlyingDiver :) .
I was able to get your tests for work. So just need to sort out the rest. I thought that the communication was direct, but it might be a cloud thing, so then I need to open some ports etc...
But it seams as I do some sort of polling with a get funcion. GET http://plaato.blynk.cc/auth_token/get/pin. And perhaps I can use the GhostXML.
I have requested a token from Plaato, and will start play with it to see what I can make of it.

Thanks again for your support :)

Håvard

Håvard

Posted on
Wed Oct 16, 2019 10:51 am
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: HTTPd Plugin (useful for IFTTT Maker integration)

Hi!

I'm trying to use this plugin for IFTTT but the plugin hangs about 1-3 times a day (need to be force quitted).
What could be the problem?

At reload:
Code: Select all
   Error                           process (pid 91815) failed to quit after polite request -- forcing it to quit now
   Stopped plugin "HTTPd 1.3.2"
   Starting plugin "HTTPd 1.3.2" (pid 94636)
   Started plugin "HTTPd 1.3.2"
   HTTPd                           Starting HTTPd
   HTTPd Error                     Certificate file missing, unable to start HTTPS server


Best regards, L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Posted on
Wed Oct 16, 2019 10:54 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: HTTPd Plugin (useful for IFTTT Maker integration)

DrLove wrote:
I'm trying to use this plugin for IFTTT but the plugin hangs about 1-3 times a day (need to be force quitted).
What could be the problem?


First, how do you know it's hanging? Is it just that IFTTT can't reach it? Have you tried using a local command (curl or similar) to communicate with it?

Second, is there anything in the logs? Try setting debug level logging and see if that shows anything.

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

Posted on
Wed Oct 16, 2019 10:58 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: HTTPd Plugin (useful for IFTTT Maker integration)

Also, I just realized I forgot to push the latest release to the plugin store (It was released on GitHub). Please upgrade to that.

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

Posted on
Wed Oct 16, 2019 11:02 am
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: HTTPd Plugin (useful for IFTTT Maker integration)

IFTTT timeout and using Curl locally does not work until reload.

I'll try the updated version! Thank you for a quick reply!

Best regards, L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Posted on
Sat Oct 19, 2019 12:27 pm
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: HTTPd Plugin (useful for IFTTT Maker integration)

Hi.

It ran stable for a few days and then the latest release also crashed :(
Nothing in the log.

Best regards, L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Posted on
Sat Oct 19, 2019 3:00 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: HTTPd Plugin (useful for IFTTT Maker integration)

What port are you using?


Sent from my iPhone using Tapatalk

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

Posted on
Sat Oct 19, 2019 4:11 pm
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: HTTPd Plugin (useful for IFTTT Maker integration)

HTTP 5555.

/L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Posted on
Sun Oct 20, 2019 4:52 am
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: HTTPd Plugin (useful for IFTTT Maker integration)

Update.
Yesterday, after my reply, the plugin did not even want to start at all. It looks like it's running (startup ok in log after force quit as usual) but does not respond to HTTP-requests. Tried different ports to no avail.
This morning after many reloads and disable/enable of the plugin it is running again, but who knows for how long :/
The log (at debug level) does not show anything odd.

//L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Posted on
Sun Oct 20, 2019 8:39 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: HTTPd Plugin (useful for IFTTT Maker integration)

Ok, time to take this off the forums.

Please create a new issue here: https://github.com/FlyingDiver/Indigo-HTTPd/issues

Describe the problem with as much detail as you can (which in this case, might not be much). Then attach the plugin-specific log file and the plugin preferences file. Paths will be something like:

Code: Select all
/Library/Application Support/Perceptive Automation/Indigo 7.4/Logs/com.flyingdiver.indigoplugin.httpd/plugin.log
/Library/Application Support/Perceptive Automation/Indigo 7.4/Preferences/Plugins/com.flyingdiver.indigoplugin.httpd.indiPref

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

Who is online

Users browsing this forum: No registered users and 0 guests