Stop for a moment and imagine….

It’s Christmas, and my youngest had a jar filled with fairies that would wake up at night.

.. obviously it’s Christmas, so there’s a certain degree of artistic licence in this first line but you can appreciate small led’s in a frosted jar that glow at night is pretty magical when you’re eight years old.

However these fairies kept leaving every couple of days because essentially batteries don’t last for ever and children never remember to turn lights off in the morning.

How best to keep the magic alive

So after a bit of thought the option of running some power to the jar would mean batteries could be a thing of the past.  However, that still didn’t mitigate the need for cutting the power every morning.  I love some experimentation so instead of adding another wifi plug (the simpler solution by far) I thought why not write some code for a raspberry pi and use the GPIO pins to power it.

After some further thought I wanted to be able to communicate with the Fairy Jar, so I could say ‘switch on’ or ‘switch off’.  In essence provide some kind of webhook to control it.  Google is all though the house so to really keep the magic alive it would be great if my daughter could ask Google to wake up the fairies or put them to bed.

Every thing works better together

IFTTT has been around for some time.  This has hundreds of integrations with other services including Google and time based components.  It’s also integrated with Google sign-in so by linking the accounts she will be the only one in control which made it even more exciting that only she would be able to wake up the fairies.

The mechanics behind the magic 

Build the raspberry pi as usual (flash card, get on the network, update and obtain git) then add some code to provide a REST endpoint that conforms to IFTTT’s API.  Here’s one I prepared earlier.

On IFTTT, create a developer account and add your chosen branding and point to your application.  They even provide a neat tool to test your endpoints.  Configure as you like and integrate with other services on IFTTT to provide the experience you want.