HTTPd Plugin (useful for IFTTT Maker integration)
Re: HTTPd Plugin (useful for IFTTT Maker integration)
I have looked at the logs and they are actually empty between time for failure and next start after forced reload, no errors :/
I have now went back to monitoring status of our dishwasher via energy consumption (Fibaro Wallplug) and the physical sensor I have installed in the cabinet for the door.
Right now I'm not using the plugin but I might enable it again later, I have upgraded to High Sierra (can't go higher) and Indigo 7.4, maybe that helpes.
Best regards, L
I have now went back to monitoring status of our dishwasher via energy consumption (Fibaro Wallplug) and the physical sensor I have installed in the cabinet for the door.
Right now I'm not using the plugin but I might enable it again later, I have upgraded to High Sierra (can't go higher) and Indigo 7.4, maybe that helpes.
Best regards, L
-
JaceJenkins
- Posts: 59
- Joined: Fri Oct 16, 2015 6:41 am
Re: HTTPd Plugin (useful for IFTTT Maker integration)
Hello FD,
Love your plugin, been using it since it came out.
I have a need to run 2 instances of HTTPd on separate ports. I am using Geofency for presence awareness. It has a built-in feature to define a webhook when you pass through different geofences and can make direct GET's to HTTPd. Having said that, GEOFency is being run on two phones at the same time and I need a way for each phone to have its own instance of HTTPd to post to. Timing issues arise if both phones try to make calls to the same HTTPd at the same time. They step all over each other, so having an HTTPd per phone will solve my issues.
One issue would be each HTTPd instance would need its own variable prefix's so they don't mix with each other. Attached is a screenshot of all the variables one event can post to HTTPd. And there is no way to specify a prefix for each phone.
Thoughts?
Love your plugin, been using it since it came out.
I have a need to run 2 instances of HTTPd on separate ports. I am using Geofency for presence awareness. It has a built-in feature to define a webhook when you pass through different geofences and can make direct GET's to HTTPd. Having said that, GEOFency is being run on two phones at the same time and I need a way for each phone to have its own instance of HTTPd to post to. Timing issues arise if both phones try to make calls to the same HTTPd at the same time. They step all over each other, so having an HTTPd per phone will solve my issues.
One issue would be each HTTPd instance would need its own variable prefix's so they don't mix with each other. Attached is a screenshot of all the variables one event can post to HTTPd. And there is no way to specify a prefix for each phone.
Thoughts?
- Attachments
-
- Screen Shot 2020-01-21 at 6.54.52 PM.png (81.52 KiB) Viewed 4052 times
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: HTTPd Plugin (useful for IFTTT Maker integration)
I can do that. If I support multiple "instances", then it's just as easy to put the values into device states rather than variables. That is, you would create a device for http on port 5555 (for example), and another on port 5577. Then instead of having multiple sets of variables, each device would have their own states, which would replace the variables. Would that work?
Add any additional comments on what you need to this enhancement request: https://github.com/FlyingDiver/Indigo-HTTPd/issues/4
Add any additional comments on what you need to this enhancement request: https://github.com/FlyingDiver/Indigo-HTTPd/issues/4
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
-
JaceJenkins
- Posts: 59
- Joined: Fri Oct 16, 2015 6:41 am
Re: HTTPd Plugin (useful for IFTTT Maker integration)
Yeah, that would be perfect. I assume the states are dynamically created based values in the POST? So when GeoFency posts all the values to the webhook, those would all get created as states if they don't already exist?
You are awesome btw.
You are awesome btw.
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: HTTPd Plugin (useful for IFTTT Maker integration)
Yes, exactly. I already do that in several other plugins.JaceJenkins wrote:Yeah, that would be perfect. I assume the states are dynamically created based values in the POST? So when GeoFency posts all the values to the webhook, those would all get created as states if they don't already exist?
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: HTTPd Plugin (useful for IFTTT Maker integration)
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Re: HTTPd Plugin (useful for IFTTT Maker integration)
Hi Joe,
Many thanks for a great plugin.
I'm having a little bit of difficulty with the webhook proxy device setup: when I try and create an instance of a proxy I get a settings pane with no options (just save or cancel). On pressing save I get an error:
I've got my server set up on the default port (5555) and can confirm it is receiving data using the setvar test. Others may wish to note that if they are using the new zsh script shell in OSX you need to escape character the ? so the command is best quoted like this:
{that took me an embarrassingly long time to figure out}
I've set up a trigger action as per previous posts on this page - HTTPd event -> proxy request received , proxy device dbell, set up to trigger the following script:
and send a curl command like:
I can see that the json data is received:
... but the proxy does not trigger any actions - I suspect related to the error above when trying to create the proxy? I've restarted the plugin a number of times, and tried to create different proxies all with the same result.
Any advice very gratefully received!
Many thanks for a great plugin.
I'm having a little bit of difficulty with the webhook proxy device setup: when I try and create an instance of a proxy I get a settings pane with no options (just save or cancel). On pressing save I get an error:
Code: Select all
HTTPd dbell: Starting proxyDevice Device 1518360974
HTTPd Error Error in plugin execution ServerReplacedElem:
Traceback (most recent call last):
File "/Library/Application Support/Perceptive Automation/Indigo 7.4/IndigoPluginHost.app/Contents/Resources/PlugIns/plugin_base.py", line 1179, in deviceUpdated
File "plugin.py", line 395, in deviceStartComm
AttributeError: 'NoneType' object has no attribute 'get'
Code: Select all
curl -X POST "http://192.168.1.100:5555/setvar?hello=world"
I've set up a trigger action as per previous posts on this page - HTTPd event -> proxy request received , proxy device dbell, set up to trigger the following script:
Code: Select all
httpPlugin = indigo.server.getPlugin("com.flyingdiver.indigoplugin.httpd")
if httpPlugin.isEnabled():
hook_data = httpPlugin.executeAction("getWebhookData", deviceId=1518360974)
indigo.server.log("Webhook Payload:\n{}".format(hook_data))
Code: Select all
curl -d '{"deviceid":"HSL-XXX-XXXX", "alias":"Home doorbell", "action": "HTTP Hook"}' -H "Content-Type: application/json" http://192.168.1.100:5555/webhook-1518360974
Code: Select all
HTTPd Debug RequestHandler: POST from 192.168.1.100:57404 to /webhook-1518360974
HTTPd Debug RequestHandler: No password specified in plugin preferences, skipping authentication
HTTPd Debug POST Webhook to httpd_webhook-1518360974 = {'request': {'path': '/webhook-1518360974', 'client': '192.168.1.100', 'command': 'POST', 'headers': {'host': '192.168.1.100:5555', 'content-type': 'application/json', 'content-length': '75', 'accept': '*/*', 'user-agent': 'curl/7.64.1'}}, 'payload': {u'action': u'HTTP Hook', u'alias': u'Home doorbell', u'deviceid': u'HSL-XXX-XXXX'}, 'vars': {}}
Any advice very gratefully received!
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: HTTPd Plugin (useful for IFTTT Maker integration)
I think I noticed some issues with Proxy devices when I was revising that code for the HTTPd 2 plugin. I'll try to take a look at it again this weekend.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: HTTPd Plugin (useful for IFTTT Maker integration)
OK, a couple of things. First, I can't replicate the error you're seeing when you initially save the Proxy device. The blank settings dialog is expected. I really should put a label in there saying so. The only thing I can think of that might cause that error is something weird in the plugin configuration. Please confirm you're on the latest version (1.4.2) and make sure the plugin config is correct. You should have 5555 in the http field and 0 in the https field.
Second, I don't think the Proxy devices are going to do what you want. They were intended for use by external (long running) Python scripts. Python scripts can't use the indigo.server.subscribeToBroadcast() method needed to get notifications about web hooks directly. So the Proxy device was intended to be used to "capture" the web hook data in a way that an external script could fetch later. The trigger is meant to be used to notify the external script that there was webhook data waiting for them. I actually had this all running on my development system before I shelved it.
So, why don't you tell me what you're actually trying to accomplish and maybe I can point you in the right direction. Which, BTW, might be to change to the HTTPd-2 plugin.
Second, I don't think the Proxy devices are going to do what you want. They were intended for use by external (long running) Python scripts. Python scripts can't use the indigo.server.subscribeToBroadcast() method needed to get notifications about web hooks directly. So the Proxy device was intended to be used to "capture" the web hook data in a way that an external script could fetch later. The trigger is meant to be used to notify the external script that there was webhook data waiting for them. I actually had this all running on my development system before I shelved it.
So, why don't you tell me what you're actually trying to accomplish and maybe I can point you in the right direction. Which, BTW, might be to change to the HTTPd-2 plugin.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: HTTPd Plugin (useful for IFTTT Maker integration)
So, I was mistaken before. I never actually finished the Proxy implementation. It worked for the specific case I was using it for, but not the general case.
I've got it pretty much working, but it's in the HTTP-2 plugin. So check out that thread on converting to the new plugin, and I'll post the version with the changes tomorrow.
I've got it pretty much working, but it's in the HTTP-2 plugin. So check out that thread on converting to the new plugin, and I'll post the version with the changes tomorrow.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Re: HTTPd Plugin (useful for IFTTT Maker integration)
Thanks Joe,
I'm simply trying to catch a webhook that is sent from my doorbell (https://www.dbell.ca) when the button is pressed. I've got two of these low cost door cams (front and back of the house)- they have a reasonably good picture performance, support ONVIF so you can record the streams, and have webhook capability to (hopefully) integrate with Indigo. So far so good.
I've set the hardware to transmit the http hook to the HTTPd server at http://192.168.1.100:5555/webhook?name=dbell
I'm trying to catch the hook that looks like this:
At the moment I'm just trying to get the plugin to dump the info to the log as proof of concept, but ultimately I'd like to create variables for each of the 3 keys in the hook so I can trigger events on a state change.
So I think my use case is pretty basic - perhaps I don't need to use a proxy for this after all?
I'm simply trying to catch a webhook that is sent from my doorbell (https://www.dbell.ca) when the button is pressed. I've got two of these low cost door cams (front and back of the house)- they have a reasonably good picture performance, support ONVIF so you can record the streams, and have webhook capability to (hopefully) integrate with Indigo. So far so good.
I've set the hardware to transmit the http hook to the HTTPd server at http://192.168.1.100:5555/webhook?name=dbell
I'm trying to catch the hook that looks like this:
Code: Select all
POST /dbell HTTP/1.1
User-Agent: curl/7.21.0 (arm-unknown-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8g zlib/1.2.11
Host: 192.168.1.21:5000
Accept: */*
Content-Length: 79
Content-Type: application/json
{"deviceid":"HSL-XXX-XXXX", "alias":"Home doorbell", "action": "HTTP Hook"}
So I think my use case is pretty basic - perhaps I don't need to use a proxy for this after all?
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: HTTPd Plugin (useful for IFTTT Maker integration)
Do you have complete control of the URL that it will use for the webhook, or will it only take the server info and it adds it's own path string after that? Your example shows it using POST and sending the device-specific information in the payload. If you set the complete URL to something like this, then you don't need a proxy.LSpad wrote: I've set the hardware to transmit the http hook to the HTTPd server at http://192.168.1.100:5555/webhook?name=dbell
I'm trying to catch the hook that looks like this:At the moment I'm just trying to get the plugin to dump the info to the log as proof of concept, but ultimately I'd like to create variables for each of the 3 keys in the hook so I can trigger events on a state change.Code: Select all
POST /dbell HTTP/1.1 User-Agent: curl/7.21.0 (arm-unknown-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8g zlib/1.2.11 Host: 192.168.1.21:5000 Accept: */* Content-Length: 79 Content-Type: application/json {"deviceid":"HSL-XXX-XXXX", "alias":"Home doorbell", "action": "HTTP Hook"}
So I think my use case is pretty basic - perhaps I don't need to use a proxy for this after all?
Code: Select all
http://192.168.1.100:5555/setvars?dbell=front
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: HTTPd Plugin (useful for IFTTT Maker integration)
Actually, I'm pretty sure you'll need to use a Proxy. Your capture has this:
Which means it used a URL ending in /dbell. Which isn't what you told it to send. But maybe. Set it up using the URL above and let me know what happens. Put the plugin in debug log mode so you see everything that it receives.
Code: Select all
POST /dbell HTTP/1.1
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
-
petematheson
- Posts: 847
- Joined: Sun Sep 14, 2014 9:51 am
- Location: Southampton, UK
Re: HTTPd Plugin (useful for IFTTT Maker integration)
Sorry for using the wrong version! Misunderstood
So I'm using this version to modify variables for presence detection using IFTTT and Life360.
When I manually run the following cmd:
curl http://username:[email protected]:5 ... ca360=Home
I get:
HTTPd Debug getWebhookInfo, info = {u'hook_name': u'httpd_webhook-1662899611', u'http': 'http://username:[email protected]:5 ... 1662899611'}
HTTPd Debug RequestHandler: GET from 192.168.0.10:49995 for /setvar?LocationErica360=Home
HTTPd Debug RequestHandler: auth_map = {'username': 'username', 'password': 'password'}
HTTPd Debug Requesthandler: basic authorization valid
HTTPd Debug RequestHandler: setting variable httpd_LocationErica360 to 'Home'
But the variable doesn't change ??
So I'm using this version to modify variables for presence detection using IFTTT and Life360.
When I manually run the following cmd:
curl http://username:[email protected]:5 ... ca360=Home
I get:
HTTPd Debug getWebhookInfo, info = {u'hook_name': u'httpd_webhook-1662899611', u'http': 'http://username:[email protected]:5 ... 1662899611'}
HTTPd Debug RequestHandler: GET from 192.168.0.10:49995 for /setvar?LocationErica360=Home
HTTPd Debug RequestHandler: auth_map = {'username': 'username', 'password': 'password'}
HTTPd Debug Requesthandler: basic authorization valid
HTTPd Debug RequestHandler: setting variable httpd_LocationErica360 to 'Home'
But the variable doesn't change ??
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: HTTPd Plugin (useful for IFTTT Maker integration)
What variable are you looking at? The log says it’s updating httpd_LocationErica360. Is that not happening?
Sent from my iPhone using Tapatalk
Sent from my iPhone using Tapatalk
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177