Avoiding that awkward BBC interview moment as a remote worker

jim-rohm

Published on March 23rd 2020

1

Nobody wants their kid charging in during a meeting. Having experienced this during my first week of working at home I knew I needed a solution for letting my wife and kid know when I was going to be in a meeting/pair programming. I could just shout downstairs but where is the fun in that? By automating it, it's one less thing to have to remember in what is shaping up to be a stressful time for everyone.

I wanted this to be a quick Sunday evening project that only took a couple of hours so needed it to be simple and use the kit I already had. I also wanted it to work without the Raspberry Pi (RPi) being accessible from outside my home network.

I could have completed this project in a much simpler way if I had allowed access to the RPi from the outside world but in a world where IoT devices are the target of cyber attacks I wanted to limit the exposure.

On the hardware side of things, it seemed obvious to use an RPi and Mote LEDs. I have them already and they are simple to work with.

Mote is a collection of components allowing you to easily work with LEDs. The visual side of this project could be anything you have knocking around. I just happened to have these.

I am using an RPi 3 for this but you could any Pi that has is network connected.

All my meetings are in Google Calendar so I just needed a way to trigger an event when my meetings start and finish. If This Than That (IFTTT) is perfect for this. Google Calendar is the THIS of IFTTT and a webhook is the THAT.

I wanted this to be a quick project with as little programming as possible so I needed a way to accept the webhook but also be able to perform actions on a device in my local network. This part took a little longer to figure out, but a combination of Tasker and AutoRemote was able to perfectly meet my needs.

Tasker is an automation app that allows users to perform actions based on an event.

AutoRemote allows devices to communicate with each other without any user interaction.

N.B This article assumes some previous knowledge of Tasker and AutoRemote and so the instructions may be brief

Tasker and AutoRemote are built to work with each other and so we can use AutoRemote as a way of triggering an action in Tasker. AutoRemote is available as a plugin in Tasker.

AutoRemote acts as our "server" for the IFTTT webhook to callout to. When it receives a request, an event is triggered in Tasker which in turn sends a REST request to a local flask app that is running on the RPi. This Flask app controls the Mote LEDs.

Setting up Tasker and AutoRemote

In AutoRemote we need to register IFTTT as a device. Click the phone icon in the tab bar and then click the IFTTT logo and follow the instructions. This will give you a URL that can be added to the IFTTT webhook. It will look something like this:

Notice this is how we pass properties to AutoRemote. The left side of =:= is how we can filter incoming requests and the right side are any params you want to pass in.

With this set up we now need to trigger events in Tasker. Under the profiles tab create a new one profile selecting event -> plugin -> AutoRemote -> AutoRemote. Edit the configuration and add the name of the event (the left side of the request from IFTTT e.g IFTTTMEETING_BUSY). Next, click back and add the action. In my case, I wanted to perform an HTTP request to my RPi but there is a multitude of things that Tasker can do for you.

Your Tasker profiles will look like this:

The final step is setting up the local server to trigger the Mote lights. I wrote a really simple Flask app that listens to requests and calls the correct Mote methods. It looks something like this:

1import motephat

2from flask import Flask, jsonify, make_response

3

4app = Flask(__name__)

5

6motephat.set_brightness(0.5)

7motephat.configure_channel(1,16,False)

8#motephat.configure_channel(2, 16, False)

9#motephat.configure_channel(3, 16, False)

10#motephat.configure_channel(4, 16, False)

11

12colour ='FFFFFF'

13status =0

14

15defmote_on(c):

16for channel inrange(1,5):

17for pixel inrange(16):

18 motephat.set_pixel(channel, pixel,255,0,0)

19 motephat.show()

20

21returnTrue

22

23defmote_off():

24 motephat.clear()

25 motephat.show()

26returnTrue

27

28defget_status():

29global status

30for channel inrange(4):

31for pixel inrange(16):

32if motephat.get_pixel(channel +1, pixel)!=(0,0,0):

33 status =1

34return status

35

36@app.route('/')

37defhello():

38return'hello'

39

40@app.route('/mote/api/v1.0/<string:st>', methods=['GET'])

41defset_status(st):

42global status, colour

43if st =='on':

44 status =1

45 mote_on(colour)

46elif st =='off':

47 status =0

48 mote_off()

49elif st =='status':

50 status = get_status()

51return jsonify({'status': status,'colour': colour})

52

53@app.errorhandler(404)

54defnot_found(error):

55return make_response(jsonify({'error':'Not found'}),404)

56

57if __name__ =='__main__':

58 mote_off()

59 app.run(debug='true', host='0.0.0.0')

Now when you are about to go into a meeting your lights should light up telling everyone concerned that you are otherwise engaged.

Conclusion

I hope this was of some interest. I really enjoy these little projects that have limited time and scope. Obviously, there are so many ways that this could be done and some many improvements that could be made but this was only meant to be a little bit of fun on a Sunday night.

Free download for your phone or tablet

Lots to see

Follow and read AlanGardenMaster’s articles as he develops his new one-acre plot. PimlicoDan shows city gardening in a whole new light, or follow DaisyDays on her adventures in the allotment and as a professional gardener. Just a few of the many personalities you’ll meet in our app.
Free download for your phone or tablet.