An installable groovy SmartApp that provides event-based webhook functionality for SmartThings.
Switch branches/tags
Nothing to show
Clone or download
harperreed Made changes suggested by SmarthThings
* Please add comments in the code.
* Please add a try/catch block around the HTTP request. It may be better to check the endpoint and send the user a message if the endpoint isn't available (doesn't exist or is down).
* Not all the inputs are used in subscribe methods. Since the callback method requires an event to send that data, these inputs don't need to be listed:
  - input "actuator", "capability.actuator", title: "Actuator", required: false, multiple: true
  - input "configuration", "capability.configuration", title: "Configuration", required: false, multiple: true
  - input "lockCodes", "capability.lockCodes", title: "Lock Codes", required: false, multiple: true
  - input "momentary", "capability.momentary", title: "Momentary", required: false, multiple: true
  - input "polling", "capability.polling", title: "Polling", required: false, multiple: true
  - input "refresh", "capability.refresh", title: "Refresh", required: false, multiple: true
  - input "speechSynthesis", "capability.speechSynthesis", title: "Speech Synthesis", required: false, multiple: true
  - input "testCapability", "capability.testCapability", title: "Test Capability", required: false, multiple: true
  - input "tone", "capability.tone", title: "Tone", required: false, multiple: true
Latest commit 5432e07 Sep 4, 2015
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md updated README Dec 7, 2014
webhook.groovy Made changes suggested by SmarthThings Sep 4, 2015

README.md

SmartThings-webook

An installable groovy SmartApp that provides event-based webhook functionality for SmartThings.

##Webhooks

Webhooks are awesome. I choose to send all events to one URL and then have that URL push to other URLs.

My goals was to be able to make adhoc event based apps (without having to deploy them to the hub directly), to do extensive logging and to be able to do analytics on events that happen in my house.

If you want to send a specific event to a specific webhook, you can do this a couple ways.

  1. Install an instance of this app per event type (not efficient)
  2. Write a middleware that pushes webhooks based on the name

If I get bored, I may do #2 in a bit.

###Post body

On an event, the smartapp will POST the following to a URL

{  
   "id":"000000000",
   "date":"2014-12-07T20:00:14.670Z",
   "value":"73",
   "name":"temperature",
   "display_name":"Backdoor",
   "description":"Backdoor was 73?F",
   "source":"DEVICE",
   "state_changed":true,
   "physical":false,
   "location_id":"000000000",
   "hub_id":"000000000"
}

###Installation

  1. Sign into the SmartThings backend:
  2. Go to the SmartApps IDE
  3. Create a new smartapp (or click here)
    • Name it something that makes sense
  4. Paste in the webhook groovy code into the IDE
  5. Click save
  6. Click publish
  7. It should show up in your smartthings app to be configured. You can also configure it on the right hand side of the IDE.
    • Enter your webhook URL (I like pushing all the events to loggly)
    • Select the devices you want to receive notifications for
  8. Profit

##Inspiration

I spent a bunch of time reading groovy scripts and understanding WTF is going on with the SmartApps paradigm.

The code from @R-OG really helped (EventGhost Notification.groovy) me understand how to subscribe to events and how capabilities work.

Most of the example code is pretty solid. I couldn't find any that did exactly what this code does (even though people talked about it in the forums).

##Help out!?

Fork, make a change and then submit a pull request.

Feel free reach out if you have questions: @harper, harper@nata2.org.