The Raspberry Pi Powered Speaking Doorbell – Part 2: Kodi Camera Overlay

In Part 1, we looked at building a simple input circuit to electrically isolate and protect our Raspberry Pi from damage when connecting it to our doorbell switch. Next, we’ll look at displaying a camera overlay directly in Kodi / XBMC and triggering the display from a Python script.

IP cameras have become really cheap and easy to come by, giving us many options to integrate video into our home automation systems. The front door is a great place to install a camera!


The Digital Lifestyle has a very good write up on how to install and configure an add-on to display the camera overlay (especially if you have more than one camera) directly in Kodi itself.

We can then use some Python code to trigger the add-on using Kodi’s API.

Prerequisites: In Kodi, make sure “Allow control of Kodi via HTTP” is set to ON in Settings -> Services -> Webserver.

I wrote a small XBMC / Kodi client to make it easier to make calls to the API. Here is the method for triggering an add-on:

    def execute_addon(self, addon_id):
        payload = self._get_payload("Addons.ExecuteAddon",
{'addonid': addon_id})

And here is the code for instantiating the client and executing the add-on:

xbmc_client = xbmc.XbmcClient(host, port)

On line 1, we instantiate the XBMC client by specifying the host and port. The port is configured in Kodi’s Settings -> Services -> Webserver -> Port.

The only parameter we are passing to the execute_addon method is the ID of the add-on we wish to run. Set it to the add-on ID that you specified in the addon.xml file.

That’s it. Next, we’ll look at how to build a text to speech server using Tornado.

Syncing TomTom GPS watch activities to Discovery Vitality

Edit 2016-04-01 – As far as I know, Discovery have disabled integration with MapMyFitness and Strava for all new TomTom watches since April 1st, 2016. Existing TomTom watch users that had MapMyFitness or Strava integrations added on their Vitality profile before 1 April will still have their workouts synced with Vitality. Apparently, TomTom is busy working on a integration which will allow TomTom watch users to sync their workouts directly with Vitality. There should be a announcement from Discovery as soon as this integration goes live.

If you are a member of Discovery Health medical aid and use its Vitality service, it is possible to link your TomTom GPS watch (TomTom Runner, Cardio or Multisport watches) so that your activities are uploaded automatically to the Living Vitality exercise tracker.


The Vitality workout tracker uses MapMyFitness, which is an activity tracking website similar to Strava or Endomondo, to log any workouts added to the Vitality site. This means that if we can export our TomTom activities to the correct MapMyFitness account, it will appear automatically in the Vitality workout tracker. Luckily for us, TomTom has added the ability to export to MapMyFitness from the MySports Connect software, allowing us to automate the upload of activities to Vitality as well.

Note – Vitality creates a MapMyFitness account for you using an auto-generated username and password. If you already had a MapMyFitness account before starting to use Vitality to log workouts, it is important to know that Vitality will not use your existing account, even if your usernames and passwords are the same for Vitality and MapMyFitness.

So, let’s get started…

Step 1 – Head over to the Living Vitality website, click the “Login” button and log in to your vitality account

Step 2 – From the top-right navigation menu, hover your mouse cursor over the “Vitality” heading which should open up a very large navigation menu. Look for the “Your Profile” link under the “Vitality Community” subheading. If you can’t find it, use your browser’s built in search function (Press Ctrl and F together which opens the search dialog – now type “Profile” and click search). Click on the “Your Profile” link.

Step 3 – Scroll down until you see the section titled “Change your MapMyFitness password”. Look for the “Username” field – there should be a username filled in – save this username somewhere safe. (If you do not see this information, please see *disclaimer at the bottom of this post). Change the password now so that it is set to something that you can remember – enter the new password and confirm password fields and press “Update”.

Step 4 – Next, we need to configure TomTom’s MySports Connect software to upload any new activities to MapMyFitness. To do this you need to make sure your software is up to date – usually when your PC is started up, it pops up a notification if your software is out of date – as long as you have updated the software recently, you’ll be good to go. Make sure your watch is connected to the PC and open the MySports Connect application.

Step 5 – On the main application window, select “Settings” and click on the “Upload & Export” tab. Click on the “Add” button. Select “MapMyFitness” from the export options and click “Add”. This will open a browser window that will open the MapMyFitness website. Log in using the username obtained in Step 3 and the new password you entered on the Vitality site. If you were already logged in, make sure the account you are logged into is the same as the one configured in Vitality. Next, the site will ask you to confirm if you want to connect the TomTom MySports software – go ahead and confirm – you should be all set.

Step 6 – Once you have logged at least one workout and the MySports Connect software has finished uploading and exporting your activity, log into the Vitality website again (see step 1) to see that the workouts are being synced correctly. In the Vitality navigation menu, look for the “Workout tracker” link under the “Gym and Fitness” subheading and click it. Now scroll down until you see the graph – it should show your activities plotted for the last week.

If you had any trouble setting up the automatic syncing, please drop me a comment below and I’ll see if I can help out.

*Disclaimerif you do not see a MapMyFitness username on the Vitality website, or the option to change your MapMyFitness does not appear on the site, it is possible that it only creates the MapMyFitness account once you log at least one workout (You will have to have set your MySports Connect software to export to .FIT or .GPX files before so that you have something to upload). Upload a single workout to the Vitality workout tracker and see if the MapMyFitness account details appear. If so, please drop me a comment so I can amend this guide.

*Disclaimer 2 – I do not work for Discovery Health and am not affiliated with them in any way.

The Raspberry Pi Powered Speaking Doorbell – Part 1: The Input Circuit

<< Previous post – The Raspberry Pi Powered Speaking Doorbell – Video

The first step of building the Raspberry Pi-powered speaking doorbell is building a simple input circuit. The purpose of the input circuit is to protect the Pi from damage by electrically isolating the doorbell and its power supply from the Raspberry Pi itself.

The circuit design and a full description of how it works can be found here. The power supply I used is rated at 12V, but the LTV-847 optocoupler used in the design copes just fine with an input voltage of 12V. It is a 4 channel optocoupler, so you can read 4 different inputs using the same optocoupler. I like using veroboard / stripboard for my circuits because the soldered connections are a bit more robust than a breadboard setup.

Input Circuit

Input Circuit – Top view

On the left are the 2 single-core cables that are connected to my doorbell and its 12V power supply. The + (anode) of the 12V power supply is wired to my doorbell button which in turn is connected to the input circuit (top left cable). The bottom-left cable on the input circuit is then connected to the – (cathode) of the power supply.

On the right-hand side, you’ll notice a ribbon cable. I have a model B Raspberry Pi, which has a 26 pin P1 header. I bought a 26pin IDC crimp connector and some ribbon cable, which fits perfectly on the P1 header.


The red cable indicates Pin 1 on the Raspberry Pi, so in the input circuit picture, the top right cable is connected to the 22nd cable of the ribbon cable (which corresponds to pin 22 on the Raspberry Pi) and the bottom-right cable is connected to the 20th cable (pin 20 on the Pi).


(Diagram from

As you can see from the pin mapping diagram, pin 22 is GPIO 25 and pin 20 is Ground.

Input Circuit - Bottom view

Input Circuit – Bottom view

You’ll notice on the bottom view of the input circuit that the tracks on the stripboard is scratched off between the input and output sides of the optocoupler. It is a good idea to test with a multimeter to make sure there is no continuity when measuring on either side of the “break” in the track to be sure that the connection is properly broken.

If you are like me and your soldering skills are not great, I would recommend testing the circuit before connecting it to your Pi. Get a friend to press your doorbell button while you measure continuity on the output side of the optocoupler – when the doorbell is pressed, the output side should be closed. When it is not pressed, it should be open.

I also like to test to make sure there is no continuity between consecutive tracks on the stripboard to make sure I didn’t accidentally solder a connection between tracks.

In the next post – how to display the camera overlay in Kodi.