Case Alerts through Raspberry Pi

Posted on 21 July 2014 by Paul Weeden

Welcome to our first Labs post on Raspberry Pi.

Our idea was to create something that could alert us to a high priority case in Salesforce, allowing us to assist clients more quickly in the case of an emergency. We considered a number of methods and decided upon Raspberry Pi. If you haven’t heard of it before, Raspberry Pi is a low cost, credit- card sized computer.

Raspberry Pi

Lab #001 - Raspberry Pi Remote


  • To be notified about a high priority case by a visual /audible alert in the office
  • To  remotely control the power of devices in the office


Whilst considering different methods, we came across a brilliant web service called 'IFTTT' (If This Then That) which allows you to create a 'recipe' consisting of a trigger and an action. By creating a recipe with an email as the trigger and a Belkin WeMo as the action, IFTTT would do the rest in the background. However, we decided against this method, as it relied on too many variables; What if IFTTT goes down, or becomes a paid service? What if the WeMo loses Wi-Fi signal?

We then looked at Web Server Power Sockets but found these were expensive and had limited information online, such as what the Web Server ran on and how you controlled the individual sockets. They also required connections to be within a close physical location, plugged into the same power strip. Finally, we looked at a Raspberry Pi. Although we had one in the office, it had been collecting dust at the bottom of a drawer and had never been coded before. We undertook some research and found a USB device called a TellStick. The TellStick is a small radio transmitter that can be controlled by a Linux/Mac/Windows OS. We purchased the TellStick and some RF Plugs and after various tests, managed to pair the two devices together, hearing the sweet sound of a faint click as the plug powered on remotely! Things became a bit more challenging after this.


We needed a way to control the TellStick from a script and found a Python Wrapper that would allow us to do this. With limited experience of creating Python scripts, we brushed up on our Python skills via and started coding! Eventually we managed to make a script that could receive POSTs with variables, including power=on/off, device=(id), time(seconds to stay on for), password=(password). We also created a web interface to make the power controls more user friendly. This worked well, but still wasn't capable of doing what we needed it to do.

So lastly, we had to work out how to accept JSON (‘JavaScript Object Notation’ - a data interchange format that uses human readable text) on the Pi. After some research we found a Python microframework called Flask, and programmed it to send variables and values to it. We used a REST (Representational state transfer) client called Postman, which is a Chrome Extension, to send test JSON commands. Flask successfully controlled the power and even returned error messages when something went wrong!


It works! The Pi can now control the power via the web interface and via JSON commands. We are currently configuring Salesforce to send the JSON with a trigger and allow the Pi through the firewall to be publicly accessible (with authentication). Once this happens, the project will be complete.  Here is one of the devices we have remotely powered using the Pi.
Light Activated Raspberry Pi

Another big advantage of using the Raspberry Pi and JSON is that it can be easily adapted to work with other programs. We are planning to add an audible device too!

Stay tuned for more Raspberry Pi projects in the future.


Subscribe to Foration’s Blog Posts by Email