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.