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.
- Install an instance of this app per event type (not efficient)
- 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
- Sign into the SmartThings backend:
- Go to the SmartApps IDE
- Create a new smartapp (or click here)
- Name it something that makes sense
- Paste in the webhook groovy code into the IDE
- Click save
- Click publish
- 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
- 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, [email protected].