It all started when I wanted to turn my fireplace on from my TV remote…

Doorbell + IPcam + XBMC

Well it’s been a couple months since I installed my IPcamera and linked it to my x10 door bell. It’s been pretty great. I plan to show a new refreshed video and a full introduction to the software features I use in some backend scripts and a web as well as a smartphone app that I’ve been working on.

For now I’m interested in showing my IPcamera/doorbell script I wrote for XBMC just this evening. I use XBMC on all TV’s and computer systems in my house.

This slideshow requires JavaScript.

It’s been pretty great so far at automating my media across the network and integrating my home automation notifications. I decided to write a script to send a notification to all XBMC instances when my doorbell rings and to display a live video feed of the IPcam at my porch for 10 seconds.

My particular use case was I realized when in my exercise room I will not be able to hear my doorbell over my treadmill motor and music/video playing, AND I’m probably going to be spending most of my time in that room looking at an XBMC screen. It works great, it’s very simple and it’s very cool since it pops up on any screen I have running in the house

This script can be run in the Programs menu or ideally for what I’m demonstrating here, it’s called by a command line script when it sees that my doorbell has been pressed. This is just a regular HTTP GET to your XBMC machine telling it to run the script.

Please note I’m using HTTP GET’s on XBMC 11, XBMC 12 requires an equivalent command over a json call. I’m pretty sure it’s not hard, I just don’t have that information right now.

http://XBMCHOSTNAME:PORT/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.RunScript(/PATH/TO/SCRIPTS/DIR/script.doorbell/doorbell.py)
From a linux shell you'd execute this as:
wget "http://XBMCHOSTNAME:PORT/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.RunScript(/PATH/TO/SCRIPTS/DIR/script.doorbell/doorbell.py)";
or you can just paste this into a regular webbrowser to test.

Related

Posts navigation

133 comments on “Doorbell + IPcam + XBMC”

That looks great, but where is this script located? Is it within XBMC?
Also you said you have XBMC on all screens in your house, what are you using to get XBMC on your TV’s? A media PC? If so what type?

I made a custom board right now using an Arduino and is sending the responses by serial port. Not sure if I will continue to do it that way or not… Although I just found a website to make my own Arduino with ethernet for about $20 or so… At that price it is worth it to use for controllers. I currently am designing an 8 relay controller to turn speakers on and off around the house for MajorDoMo announcements. I am using MajorDoMo for now but not to sure if I will keep it. However I will surely integrate voice announcements into any system I use or create.

You should see a test notification pop up in xbmc. What version are you using? I wrote this for XBMC 11. If you’re using 12, I haven’t written the json api parts yet. They dropped the legacy api I used.

I’ll be changing it soon enough since I won’t be on 11 forever, unless you want to learn how and make a working copy to ship back to me. If you can get a notification working you can probably figure out the rest from there. Looks like you can’t use a webbrowser because commands are HTTP POST where as this is HTTP GET.

Nope you have to write a basic script on the back end. I wrote a bash script, you could probably write a batch script on windows. I have a list of IP addresses, I loop through that.

Also you may be interested in this, I just installed it, but it doesn’t work with mochad, it does work with many windows apps. This is for x10 lighting, not cam, but figured you’re want to check it anyway.

Ok, I kind of figured you had to ping each box directly. What happens if a box is not on, will your script fail?
I figured out how to send a message with the new JSON API today, just not sure how to run your script yet 🙂

Nice work! I’m looking to accomplish this same feat soon, so this is very inspiring and helpful for those of us who aren’t expert coders. Right now I’m using Blue Iris Security Cam software to manage my IP cameras, but it has the ability to run programs/sound/etc when a motion is triggered. I’m hoping to integrate this to save an image snapshot on motion detect along with your script to have that oh so handy pop up image occur in XBMC.

Looking forward to more updates on this project and your other/future ones. Awesome stuff indeed =)

Hello everybody
That system look realy cool.
I was looking for this from long time.
By the way, as my english is not so good, especialy for technical stuff, i have some problems to understand how to instal all .
First i use XBMC 12. can i install the cam viewer even i no instal the automatic pop up ?
I see on the youtube movie that you open and close it from your remote.

Can you also help and explain the procedure to instal, i try to do but i have maybe not enougth experience on xbmc.

The script itself should work on XBMC12, I never tested it tough. The notifications I provided wont work, but you should be able to run the script. IF you’re getting a script error you should look in xbmc.log located at C:Users\AppDataRoamingXBMCxbmc.log on Windows 7.

My script isn’t designed to work with .strm files. I never did that because my camera doesn’t support it. You should be able to just launch the strm file by using a notification to play it as a video file, but my script would have to be a complete rewrite I assume to get it to work like yours. If you want my script to work just point it at the location of a still image on your ip cam’s web server.

Lastly I’m concerned even though that URL will now be valid, it’s video.cgi which makes me thing it’s a stream. You might have to find an actual JPG file on your webcam’s server. If you can give me the exact model number I might be able to find that information.

I’m sorry but if you look at the logs you sent me it clearly says “Non-ASCII character ‘\x92” and if you google x92 it’s an apostrophe. Thats why I’m saying that’s the error. It’s supposed to be a single quote not an apostrophe. Once again the xbmc version shouldn’t matter it’s a python syntax error. I’m using xbmc 11.

Retype the quotation instead of using what is copy and pasted. It’s a copy and paste issue, delete both ‘ ‘ around the url and retype ‘ ‘. If it fails then something new is wrong in the logs. Both times it’s been character issues (same in nature), if it doesnt work past then we might have encountered a new real issue and I’m still interested in correcting this.

Hey
last script update instaled succesfully on x12 after add the rigth cam URL in the sript/
No more script error or else
addon activated
but now , how to make it work ?
how to see the pop up window ?
when i launch the script from Install / extention /dorrbell … nothing happen .
Thanks

Well, i not know if the script is running or not, that’s the problem.
WHen i launch the script manually truw xbmc (in the add on window) then nothing happend.
Not know if somthing run in the back ground.As i never seen it work , i also not know if it pop up when the “add on ” menu is open.

I can’t/won’t but I’m sure it’s possible. I’d like to see people contribute to my source code. The XBMC forums thread I posted in the blog is a good start. Maybe ask the question there and see what sort of response you get. It’s a good community.

Hi I have just seen your video on Youtube, be for coming here, I have to say that i am very impressed. Great Job. My problem is that I am a total NOOB at scripting any language. I Have XBMC running on 2 android mini pc sticks Imito MX2 and the Measy U2C as well as on my Windows 8 pc in my living room. I also have a Foscam IP Camera that I use as a Baby Cam.

The Script you wrote is awesome. The unfortunate part is that I have no use for and X10 device. I don’t use a door bell on my apartment building.

If it were possible (let me know if i am reaching to far) to have the pop up video of the IP camera be triggered by motion sensor of the camera or by an alternative event generated by the IP Camera. Most IP cameras are able to send an email triggered by an event. (My Foscam IP Cam FI8916W does not have aux contacts)

I think if you posted your question on the forum I mention in the post, on xbmc.org people might be willing to help with that.

When a motion sensor is enabled on a webcam it can usually send the photos to a folder on your computer. I think you could write a script to watch that folder for new images, and if so, then pop up the screen. It doesnt sound hard but unfortunately I wont have time soon to help with this, but it might even be something I want for myself in the future since a lot of people tend to knock instead of ring the bell.

This is awesome but I’ve been trying for hours without success, I cant get this to work. Im running this on xbmc 12 on a mac and i get the message that say’s “doorbell TIME” but no image this is what my log file says, i hope you can help me.

I’m going to trust the logs and suggest whatever you’re getting is not a JPEG file. Have you tried hitting the URL manually, what does it present you with? I can help you test this if you want to open up your firewall to that cam temporarily.

@a1a2a – Were you able to get this working? I have RaspXBMC running throughout our house and would love to have a live image display on screen when motion is detected. Blue iris can serve the stream and can run a script or batch file if needed. Anyone else know how to accomplish this?
Awesome job on all this! I have been hoping for someone to figure out this type of integration.
Any help would be greatly appreciated! RaspXBMC runs XBMC version 12.

If you would like to increase the frames per second (makes it look more like a video) then decrease the amount of time the while loop sleeps by decreasing the value in the ‘xbmc.sleep(500)’ line. I decreased to 10, which leads to the popup box actually looking like a streaming video.

Is it possible to open a .strm file instead of a static image? I would love to be able to stream 10 seconds of video instead of just a static image. Would make a great security monitor/screen saver too.

It’s actually not a static image, it’s a stream of images. One frame per second, configurable. XBMC supports strm files but based on other forum posts i’ve read it will interrupt whatever is currently playing.

I have this as an upstart job on my Ubuntu server named ZoneMinderAlarm. In the “Do Your Stuff Here” section, I had it call a python script with the specific camera ID and Name, then pause for a bit instead of continually retriggering during the event:

Also consider uploading the code somewhere, or I could maintain it in my github repository and if you’re interested in helping maintain this and/or the xbmc plugin, I can give you access and that would be helpful to me.

I just created a similar post in the xbmc thread and it looks like the formatting is kept a bit better. You’re more than welcome to host these scripts in your github if you’d like, I don’t have any repository anywhere.

Thanks, got your script and that’s working exactly as described but I am trying to integrate with ZoneMinder and it is Tuff’s script I am interested in to pop up a particular camera when there is an alert.

I had some issues with the json call as well. I think there was a typo or a formatting issue using the command from above. It has smart quotes instead of plain quotes. I’m not sure if there was anything else.

I was able to use the following command (all on one line) from a shell prompt:
wget –user=xbmc –password=’xbmc’ ‘http://zbox-xbmc:8080/jsonrpc?request={“jsonrpc”: “2.0”, “method”:”Addons.ExecuteAddon”,”params”:{“addonid”:”script.doorbell”}}’

I am successfully using my Elk M1 security system to trigger my ISY/Insteon controller to make a http call to all of my XBMC boxes. It is using the following (same) parameters, minus the URL & credentials:
/jsonrpc?request={“jsonrpc”: “2.0”, “method”:”Addons.ExecuteAddon”,”params”:{“addonid”:”script.doorbell”}}

I have my camera mounted upside down so I had to modify the script using image.rotate, but it works very well. Next step will be multiple cameras at once using Manuel’s code from above.

Thanks for posting the logs instead of just begging for help like most people do 🙂

“Parse error” most certainly means that it’s an issue with quoting. Which is the issue with copying and pasting stuff like this from a browser. Go through you command and replace all “, ‘ and `’s manually. I can tell just by looking at your pasted line that it’s using the wrong characters for the quotes so xbmc doesn’t know how to parse that line properly.

You’ll have to write a script to handle this. My script won’t work as it was designed with X10. But you could simply hook your doorbell wires up to the pin, have a script monitor it. And then fire off requests when the button is pushed.

For email notifications, you’ll have to rip images off the camera, and then fire off an email about it. I will put my web/email code up sometime but I don’t have the time right now. There’s a lot of work involved like configuring postfix email from the command line, so if you aren’t familiar with linux you have to learn about that stuff first.

The XBMC trigger is simple, it’s been described in the comments on the post. And in the post itself.

wow, I’ve been searching and messing around with python scripts for days and stumbled upon this place, great work, I finally see the light.

I’m trying to get Manuel’s version of your script running on XBMC (v12) … I’m trying to get 4 IP cameras to show on the screen… I just cant get his script to work (I only copied and pasted it from here so im not sure if that even works)