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!

ip

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})
        self._do_post_request(payload)

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


xbmc_client = xbmc.XbmcClient(host, port)
xbmc_client.execute_addon("script.frontdoorcam")

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.

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

  1. I love your idea here and hope to emulate it. We use Kodi (OSMC) as our house jukebox playing our mp3s in party mode. I would like to use my driveway alarm to trigger an event (maybe in my Home Assistant hub running on a raspberry pi). I would like to have the event PAUSE the jukebox, perhaps play a small Alert tone and display the driveway camera for 20-40 seconds then return to the jukebox party mode again. Is that something that is easy to modify into your existing code? (I guess it is 3 different triggers? Pause party mode, play chime, display camera, un pause party mode). Thanks for sharing & appreciate any insight you may have into the above thoughts.

    Calvin

    • Hi Calvin,

      Your requirements are very similar to mine, except for the additional chime, so the existing code will get you 90% there. The problem is that the Pause API call to Kodi no longer works in the last few releases! I have been unable to find a suitable workaround at this point. When the API call is made, Kodi seems to hang and the request to the API never completes.

      The Kodi client code can be found here:
      https://github.com/nbroers/hal/blob/master/lib/xbmc.py

      Let me know if you can get Pause working on your side or find a work around.

      Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *