Virtual Button Send HTTP Post to IFTTT or Stringify

Is there a way to have a virtual button send a HTTP Post to IFTTT or even better Stringify?

e.g On button press send POST to https://maker.ifttt.com/trigger/{hook}/with/key/{key}

As a newb to MIoT im revolving in a loop of searching solutions for this.
I wouldnt have thought it would be that complexā€¦
any thoughts?

1 Like

I donā€™t think thereā€™s currently an obvious way to do this in the UI, but it could be possible do write an add-on or app which does it.

  1. You could create a web application hosted elsewhere which listens for button events from the gateway using WebSockets via the Web Thing API and sends the POST request
  2. You could implement an adapter add-on which represents the IFTTT or Stringify services as a Thing which has an action that can be triggered, which will send the POST request from the adapter. You could then trigger that action as an output of a rule in the rules engine.
  3. Probably the right long term solution for this is ā€œService Add-onsā€ which will allow you to use general web services as the input or output of rules. Either through an add-on specific to IFTTT & Stringify, or a general purpose HTTP add-on which can send custom HTTP requests

Thanks Ben.
#3 sounds like the ideal long term solution. Waiting to see how this develops.
#1 sounds like a straight forward woek around. Unfortunately, I donā€™t have the skills to create this. Apart from the Web Thing API documentation are there any tutorials I could follow?

Thanks again.

I canā€™t think of anything specific that would help you with that, sorry. Iā€™d really like to improve our docs with a ā€œUsing the Web Thing APIā€ page at some point with some helpful examples.

Ive hacked this by using an ESP8266 to define some ā€˜thingsā€™.
The code then reacts to state changes and posts maker request to IFTTT.
No ideal but a quick work around.
Im having some problems describing a push button in arduino but will create a seperate post.

Is it possible to define an action for a web thing that sends a http post?
https://iot.mozilla.org/wot/#actions-resource

Not currently, weā€™re looking at adding the ability to write addons that enable this capability in a scalable way. If you want to see the super hacky way I did this a while back thereā€™s some prior art here: https://github.com/hobinjk/gateway/tree/rules-user-visible-ifttt

Although youā€™d need an ā€œAdd-onā€ (service) to bridge the WebThings Gateway to the IFTTT service, (which I have not seen anyone contribute as yet), if the IFTTT service result is directed back at your house, then you could use local WebThings Gateway rules instead. I can offer a couple examples for easily enabling virtual buttons and ā€œtimedā€ triggers in the gateway GUI.

Pulse Add-on. It works like a virtual button. Enable the ā€œPulseā€ add-on. Configure a 1-second pulse, with pulse ā€œnameā€ corresponding to a hint of a rule to be applied when it is triggered. For example, create pulse ā€œdinner timeā€ and go to the ā€œThingsā€ page to add it. It will show up as an on/off switch icon. Then create a rule. Drag the dinner time icon as the rule input, and select Event "turnedOn". Drag the lights you want set as the action output for the rule. Rule name could be ā€œtime for dinnerā€. It might affect a group of lights, some turning on, others turning off, maybe also affecting brightness or color to set the desired dinner mood. Later just click the ā€œdinner timeā€ icon to set all the lights (per the rule). Or I could say ā€œturn on dinner timeā€ since I use the voice-controller add-on.

Timer Add-on. Like the Pulse Add-on, you can configure as many timer ā€œthingsā€ as you want, each with a desired duration in seconds. Currently, each timer has actions ā€œstartā€ and ā€œresetā€ that can be clicked on in the detail page or triggered as the output of a rule, and properties ā€œElapsedā€ and ā€œNot elapsedā€ (boolean checkbox on detail thing page) that are useful as rule inputs. For example, if your bedtime routine typically takes 10 minutes, you can configure a timer of ā€œbedtimeā€ with duration 600 seconds. Trigger a rule called ā€œtime for bedā€ with any input (maybe electric toothbrush on), and an output of bedtime timer Action "start". That starts the 10-minute timer. Another rule of bedtime timer Elapsed (as the input) could then turn all your lights off (as the output). Your house will be dark in 10 minutes after the timer is triggered so you better be speedy. Create a ā€œsunriseā€ rule (using ā€œif sunsetā€ or ā€œif 6amā€ as input) to trigger an output of bedtime timer Action "reset" to reset the boolean property back to ā€œNot elapsedā€.

Hi Kathy
Thank you for the ideas, I really appreciate them.
I guess the issue is that the devices Im trying to control are not visible in the WebThings Gateway. The devices are sonoff switches and Im not keen at this stage in flashing the firmware.
What Iā€™m trying to achieve is WebThings Gateway --> IFTTT --> Sonoff.
Of course, this wonā€™t allow direct communication with the device and WebThings Gateway but at least I can control it.
At the moment I have an ESP8266 acting as a ā€˜brokerā€™.

Anyone know if there is a publicly published protocol or API for how IFTTT communicates with Sonoff? Does it use MQTT? I did a quick search and found this link: https://www.itead.cc/blog/sonoff-works-with-ifttt
The eWeLink app adapts IFTTT to Sonoff devices. It seems that an eWeLink add-on for the WebThings Gateway would remove the need for an IFTTT cloud go-between altogether. Keep data local and private. :slight_smile:

I didnā€™t understand your last comment about using an ESP8266 as a broker.

Hi Kathy
ā€˜brokerā€™ might have been the wrong terminology :slight_smile:.

I am using the ESP8266 to publish devices (ā€˜lightsā€™) to the WebThing Gateway.
The ESP8266 monitors for state changes of the devices. On state change, it sends a webhook request to IFTTT to turn on/off the sonoff device.