Automated Camera Pop with Kodi

I’ve seen this topic come up quite a bit recently and thought I would give some insights.  How can you automatically pop a camera feed into Kodi on motion?  And how can you have it disappear after a few seconds?

As it turns out this is pretty simple, and should be doable from your home automation platform of choice.  All you need it a way to capture camera motion events and act on them.  I’ve also added a virtual switch so I can disable the alerts.

The build list for the project is pretty simple:

  • A camera or NVR that can pipe motion alert triggers to a home automation platform (I’m using Blue Iris)
  • A home automation platform that can hit the Kodi API (either natively or through a custom script)
  • Kodi and this plugin:

So first things first, configure that plugin for whatever camera(s) you want to pop.  It says Foscam but works with anything that does RTSP or motion JPEG.  Make note of the number of each one as you will need that when you call the camera pop.

Next you need a way to trigger your automation platform on motion.  You can leverage a dedicated motion sensor, or use an API call from your NVR.  In this case I’m using the API call from Blue Iris into Home Assistant.  This can be done simply from Blue Iris like so:

The URL being something like this:

From there all you need to do it is create a trigger on motion.  In Home Assistant that looks something like this:

- alias: 'Pop front walk cam on motion'
    - platform
: state
: binarysensor.blue_iris_frontwalk
: 'off'
: 'on'
: state
: input_boolean.enable_video_pop
: 'on'
: script.turn_on
: script.front_walk_camera_pop

From there you just need to call the script. Here is an example you can use written in bash:

#This script pops up a specific cameras on Kodi
#The input is the number of the camera configured in the addon
#Get the camera number passed in
#Pop the preview
curl -u kodi:hunter2 -i -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"Addons.ExecuteAddon","params":{"wait":false,"addonid":"","params":{"action":"show_preview","camera_number":"'$camera'","id":"1"}},"id":2}'
#Wait 15 seconds
sleep 15
#Close preview
curl -u kodi:hunter2 -i -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "GUI.SetFullscreen", "params": { "fullscreen": "toggle" }, "id": "1"}'

And there you go!  You can tweak the sleep time if needed.  I found 15 seconds to be a pretty good choice though.

Happy Automating!


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.