I recently slept through a PagerDuty incident — or rather, I woke up, looked at the back of my phone, assumed that I dreamt it and went back to sleep. I can do better…what if PagerDuty incidents could turn on the lights for me?
So I picked up a Belkin WeMo Switch, which is an internet enabled on/off switch that works with anything. Honestly, I am pretty disappointed with it; the mobile app is crappy and it essentially went dead after a firmware upgrade and most importantly, there’s no documented API. Next time (or this time…I might end up returning it if it keeps falling off the network), I’ll go with the Philips Hue Wireless Lighting, although I really wanted a PagerDuty alert to start the kettle as well.
Since there’s no public API for the WeMo, I’m going to work through If This Then That, which is always a fun thing to plug into. IFTTT doesn’t take PagerDuty webhooks (not yet anyway, I’m pestering them now), so I’m going to repurpose a PHP code sample that I wrote for a customer to send IFTTT an email with one tag if the lights should go on, and another if they should go off (on incident resolution).
As a side note, this was my first time using Runscope1 to test and debug some code. Wow, is that a smooth product! Basically I tell PagerDuty to send the webhook to Runscope, and Runscope forwards it along to my script but lets me view, edit and replay traffic between them. This was a very simple project, so I didn’t save more than 20 minutes, but I’ll be using it again in the future for sure. 2
Anyway, the whole thing works. It takes about 5-15 seconds between the incident firing and the light turning on:
- I have fond memories of using Fiddler locally, Runscope is Fiddler++ and it works for web glue ↩
- As a weird co-incidence, one of the Runscope co-founders also worked for IFTTT, and before that he worked for yet another company whose product I used today — SF is a small place, you should totally live here ↩