What should I make?
This is the first question to ask once you get semi-interested. My short list of things I want to (or have made):
- Build server status notification
- Umbraco version notifier
- Blog visitor notifier
- Weather alerter
I've made the last two and the first one is on my radar. My future build server status notifier will be an old Lego Darth Vader clock with the guts removed and red LED's that blink and Darth will say "You've failed me for the last time." However this blog post will document the blog visitor notifier instead.
You should be aware that the device has limited memory\CPU cycles and in general shouldn't be doing a whole lot. If you want to parse an XML\JSON feed on the device; you may want to rethink that and send only small bits to your device.
In order for something in one part of the internet to alert something in another part, we must have a communication path (duh). I see two options in general:
1) Push notification - I like push notifications. They are efficient and direct and do not require a constant polling of a server. However to pull off a push notification, it requires fiddling with the router via port forwarding. The main issue here is that you have to a) fiddle with the router and b) the public IP can change if your ISP decides it wants it to change. If I tell my blog to communicate to my home network via my public IP, this could easily break and I have to update my website (that sends the push) each time that happens.
2) Polling - Dammit I hate polling but this actually solves my router issue easily. If my device can just "ask for some information" via polling, it simplifies the code on my device. However this means I have to have some sort of API endpoint somewhere to ping.
So polling is the solution I chose. I could have also easily just added an endpoint to my website that the device can reach out to but I instead decided to create what I call is a 'fact' server. In general it's just a key-value pair API exposed to the public internet and secured by API key and\or device ID. The details of the fact server aren't really the point of this blog, but if you want to integrate with it; ping me on twitter. I'd say it's in beta form right now. This image below helps illustrate the interconnections:
My device(s) reach out to the fact server and poll it once every minute. I've added rate limiting to reduce device abuse. When a visitor visits my blog, I tell the fact server; the devices then check the fact server for information. With this information, the devices can decide what to do.
On a side note, I've also added an IFTTT integration that listens to Jeroen Breuer's twitter account. When he tweets, a fact gets created on the fact server if he tweets a certain pattern of characters. He's widely known for tweeting when the Umbraco CMS releases a new version. In the near future, I will have yet-another-device examine the created fact and react.