133 comments on “Doorbell + IPcam + XBMC

  1. 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?

    Thanks for sharing all your info…

  2. Take a look at the post again, I’ve updated it with more info.

    When I say I use XBMC all over the house, I think I’d qualify that as what machines have dedicated XBMC instances running.

    So for my TV’s I have mediapc’s connected. I personally use zotac zbox’s.

    For my fitness room I have a laptop that predominantly runs XBMC full screen, unless I break out to do some web browsing.

    In my office I have 3 screens and one is dedicated to XBMC. So currently I have 4 dedicated XBMC instances in total.

    • Thanks for the explanation, I am new to XBMC but learning more about it daily. Now I know about the add-ons and programs :)

      Going to give it a shot even though I don’t have a camera yet I do have a relay that triggers the computer to do whatever so sending a command will be cake!

  3. 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.

  4. 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.

    • Hey one thing, how does it pop-up on any screen? Doesn’t it just pop-up on the screen you send the get command to? Does the command sync across all XBMC machines on your lan?

  5. 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.

    http://forum.xbmc.org/showthread.php?tid=110392

    • 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 :)

      Something in the form http://localhost:8080/jsonrpc?request={ “jsonrpc”: “2.0”, “method”: “Addons.ExecuteAddon”, “params”: { “addonid”: “Doorbell” }}

      Going to have a look at the addon for X10, thanks for sharing…

  6. You should just be able to execute the script manually in the programs menu on XBMC. Does it error out there?

    With the arguments I use in wget, it only tries once per host and fails if the host is down. It block or anything.

    Thanks the json line, I’ll try to get that working.

      • Hey, you might want to check xbmc.log on your system to see why. What version are you running?

        Also it’s probably failing because of a missing directory. My current script requires you to create c:tmp and have it writable by your user account.

        This is poor coding on my part, stay tuned on git hub as I will be posting an updated version soon.

  7. 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 =)

  8. 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.

    • Hey there.

      I haven’t tested it on XBMC 12 but it should work. I’ve been told that some of the animation code for python is broken currently in 12.

      You NEED to make a c:tmp directory on windows. I’ll fix this script soon. I wrote it on linux initially and didn’t notice that issue until then.

      You can open and close it by remote using keymap.xml AND you can invoke it by json network call in xbmc12.

      To install it you just copy it to your addons folder like a regular script. Thanks.

  9. Hello.
    Ok, now using IPcam , work fine as video source.
    I place my link/file as follow:

    C:Program Files (x86)XBMCTestcamFabcam.strm

    I use XBMC 12.

    Doorbell addon instaled.

    When i run it truw the Wbmc Program launcher, then it give directly a SCIPT PY error.

    Any idear ?

    is it becose Wbmc12 ?

    I’m also wondering if the location ad name of my Cam file is rigth ? is there any issues with this ?

    Thanks

    • 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.

  10. Hi
    I am using windows 7 created a folder on my d drive gave it full permission. But when i try to launch the add on after installation it gives me the following error

    IOError: (22, “invalid mode (‘wb’) or filename”, ‘d:temptest.jpg’)

    Please help me out here.

    Thanks
    Rosh

    • Did you modify the source code? yours is erring on temp but my script uses tmp, specifically on c:

      urllib.urlretrieve(“http://asdf.com/camera/”, ‘/tmp/bell.jpg’)
      viewer.image.setImage(“”)
      viewer.image.setImage(“/tmp/bell.jpg”)

      I will be posting a new version in the next couple weeks, sorry I’ve been swamped

    • I want to help you so that others can use the script I put effort into, but I really need you to post the error from xbmc.log so I know why it’s failing. Can you do that please?

  11. i can give you access to my pc so you can check it out
    i am using a windows xp pc , can you give your skype id

  12. 23:16:55 T:5024 NOTICE: –>Python Interpreter InitializedPython Interpreter Initialized<–
    23:17:02 T:3988 ERROR: Error Type:
    23:17:02 T:3988 ERROR: Error Contents: (“Non-ASCII character ‘\xd7’ in file C:\Documents and Settings\Dre\Application Data\XBMC\addons\script.doorbell\doorbell.py on line 6, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details”, (‘C:\Documents and Settings\Dre\Application Data\XBMC\addons\script.doorbell\doorbell.py’, 6, 0, None))
    23:17:02 T:3988 ERROR: SyntaxError: (“Non-ASCII character ‘\xd7’ in file C:\Documents and Settings\Dre\Application Data\XBMC\addons\script.doorbell\doorbell.py on line 6, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details”, (‘C:\Documents and Settings\Dre\Application Data\XBMC\addons\script.doorbell\doorbell.py’, 6, 0, None))

  13. It should work period on both versions, thats why the log is important to me, it probably has some silly error that I can correct easily. It’s likely my fault for not coding it well.

    Click start and go to run and paste this in without quotes “%APPDATA%XBMCxbmc.log”, the file will open, save it somewhere and email it to isshu483@doobiest.net

  14. Cool. Can you copy and paste the url line that you modified? Line 6 in the file:

    url=’https://asdf.com/camera/’

    This is the breakdown of the error I see in the logs. Take a look, I’ve stripped out some details to make it easier to learn from:

    —————–
    Non-ASCII character ‘\xd7’

    in file C:\Documents and Settings\Dre\Application Data\XBMC\addons\script.doorbell\doorbell.py

    on line 6

    but no encoding declared;
    see http://www.python.org/peps/pep-0263.html for details
    —————–

    For fun, I took the non ascii character of \xd7 and googled it, take a look, maybe that helps explain the issue. That character is apparently a multiplication symbol? http://www.charbase.com/00d7-unicode-multiplication-sign

  15. url=http://192.168.1.6/axis-cgi/mjpg/video.cgi?camera=&resolution=320×240

    this is what i use to view axis 207w without password i can view the cam like that

  16. Perfect sense, since the link I posted references the multiplication symbol in 320×240

    use ‘320%D7240′ instead so,

    url=’http://192.168.1.6/axis-cgi/mjpg/video.cgi?camera=&resolution=320%D7240’

    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.

  17. Sorry thats a fault of wordpress, it’s supposed to be single quotes, but you can see that last quote in my line is an apostrophe instead. You need to remove the ‘ and make is a ‘

  18. 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.

  19. 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.

    • This is true. I haven’t figured out how to reference the image from the script directory. You can move it to the media folder for the xbmc program and point the script there instead.

  20. 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

  21. Please take a look :
    10:33:25 T:4272 NOTICE: CJoystick::EnumJoysticksCallback : Enabled Joystick: Sweex Wireless Gamepad Vibration
    10:33:25 T:4272 NOTICE: CJoystick::EnumJoysticksCallback : Total Axis: 5 Total Hats: 1 Total Buttons: 12
    10:33:32 T:3712 NOTICE: Thread Background Loader start, auto delete: false
    10:33:32 T:4740 NOTICE: Thread XBPyThread start, auto delete: false
    10:33:32 T:4808 NOTICE: Thread Jobworker start, auto delete: true
    10:33:32 T:4740 NOTICE: –>Python Interpreter InitializedPython Interpreter InitializedPython Interpreter Initialized<–
    10:34:34 T:3000 WARNING: CRenderManager::FlipPage – timeout waiting for flip to complete
    10:34:34 T:3000 WARNING: CRenderManager::FlipPage – timeout waiting for previous frame

  22. 10:33:32 T:4740 NOTICE: –>Python Interpreter Initialized<–
    10:33:34 T:1736 NOTICE: Thread Jobworker start, auto delete: true
    10:33:42 T:4036 NOTICE: Thread Background Loader start, auto delete: false
    10:33:42 T:4036 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://enabled/folder.jpg
    10:33:42 T:4036 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://disabled/folder.jpg
    10:33:42 T:4036 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://install/folder.jpg
    10:33:42 T:4036 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://search/folder.jpg
    10:33:42 T:4036 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://repos/folder.jpg
    10:33:45 T:4468 NOTICE: Thread Background Loader start, auto delete: false
    10:33:45 T:4468 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://enabled/xbmc.addon.executable/folder.jpg
    10:33:45 T:4468 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://enabled/xbmc.ui.screensaver/folder.jpg
    10:33:45 T:4468 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://enabled/xbmc.metadata.scraper.albums/folder.jpg
    10:33:45 T:4468 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://enabled/xbmc.metadata.scraper.artists/folder.jpg
    10:33:45 T:4468 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://enabled/xbmc.metadata.scraper.tvshows/folder.jpg
    10:33:45 T:4468 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://enabled/xbmc.metadata.scraper.musicvideos/folder.jpg
    10:33:45 T:4468 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://enabled/xbmc.metadata.scraper.movies/folder.jpg
    10:33:45 T:4468 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://enabled/xbmc.gui.webinterface/folder.jpg
    10:33:45 T:4468 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://enabled/xbmc.python.weather/folder.jpg
    10:33:45 T:4468 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://enabled/xbmc.service/folder.jpg
    10:33:45 T:4468 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://enabled/xbmc.gui.skin/folder.jpg
    10:33:45 T:4468 WARNING: XFILE::CFileFactory::CreateLoader – Unsupported protocol(addons) in addons://enabled/xbmc.player.musicviz/folder.jpg
    10:33:48 T:3952 NOTICE: Thread Background Loader start, auto delete: false

      • 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 realy want make it run, not know what to do ..

    • 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.

  23. That it is a good job, but I can’t got it work. I am using W7 and download your script from github, I create the c:/tmp and have the jpg inside. In the log I have no error.

  24. Hey can you help me with writing the script , I would like when I press a button on a keyboard the addon would run on all my xbmc

  25. Very very good . . . not working at first time on FRODO but it’s ok now . . .

    just one thing . . what happen if camera is off ???

    Maybe using “try” will be good thing .

    • Thanks,

      I dont know what try is. Can you tell me a use case whent he camera is off? Mine is always on so I’m not a good test subject for that kind of situation.

  26. 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)

    Thanks in Advance
    Great Job
    Herbie

    • 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.

  27. 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.

    16:07:00 T:4678410240 NOTICE: 13.0
    16:07:00 T:140735084313792 WARNING: JpegIO: Error 55: Not a JPEG file: starts with 0x%02x 0x%02x
    16:07:00 T:140735084313792 ERROR: Texture manager unable to load file: /Users/armando/Library/Application Support/XBMC/userdata/addon_data/script.doorbell/cam_2.jpg
    16:07:00 T:4678410240 NOTICE: catch
    16:07:00 T:140735084313792 WARNING: JpegIO: Error 55: Not a JPEG file: starts with 0x%02x 0x%02x
    16:07:00 T:140735084313792 ERROR: Texture manager unable to load file: /Users/armando/Library/Application Support/XBMC/userdata/addon_data/script.doorbell/cam_2.jpg
    16:07:12 T:4678410240 NOTICE: Thread XBPyThread start, auto delete: false
    16:07:12 T:4678410240 NOTICE: –>Python Interpreter Initialized<–
    16:07:12 T:140735084313792 ERROR: Texture manager unable to load file: special://masterprofile/media/bell1.png
    16:07:12 T:140735084313792 WARNING: JpegIO: Error 55: Not a JPEG file: starts with 0x%02x 0x%02x
    16:07:12 T:140735084313792 ERROR: Texture manager unable to load file: /Users/armando/Library/Application Support/XBMC/userdata/addon_data/script.doorbell/cam_2.jpg
    16:07:13 T:4678410240 NOTICE: 1.0
    16:07:13 T:140735084313792 WARNING: JpegIO: Error 55: Not a JPEG file: starts with 0x%02x 0x%02x
    16:07:13 T:140735084313792 ERROR: Texture manager unable to load file: /Users/armando/Library/Application Support/XBMC/userdata/addon_data/script.doorbell/cam_2.jpg
    16:07:13 T:4678410240 NOTICE: 1.0
    16:07:13 T:140735084313792 WARNING: JpegIO: Error 55: Not a JPEG file: starts with 0x%02x 0x%02x
    16:07:13 T:140735084313792 ERROR: Texture manager unable to load file: /Users/armando/Library/Application Support/XBMC/userdata/addon_data/script.doorbell/cam_2.jpg
    16:07:14 T:4678410240 NOTICE: 2.0
    16:07:14 T:140735084313792 WARNING: JpegIO: Error 55: Not a JPEG file: starts with 0x%02x 0x%02x
    16:07:14 T:140735084313792 ERROR: Texture manager unable to load file: /Users/armando/Library/Application Support/XBMC/userdata/addon_data/script.doorbell/cam_2.jpg
    16:07:14 T:4678410240 NOTICE: 2.0
    16:07:14 T:140735084313792 WARNING: JpegIO: Error 55: Not a JPEG file: starts with 0x%02x 0x%02x
    16:07:14 T:140735084313792 ERROR: Texture manager unable to load file: /Users/armando/Library/Application Support/XBMC/userdata/addon_data/script.doorbell/cam_2.jpg
    16:07:15 T:4678410240 NOTICE: 3.0
    16:07:15 T:140735084313792 WARNING: JpegIO: Error 55: Not a JPEG file: starts with 0x%02x 0x%02x
    16:07:15 T:140735084313792 ERROR: Texture manager unable to load file: /Users/armando/Library/Application Support/XBMC/userdata/addon_data/script.doorbell/cam_2.jpg
    16:07:15 T:4678410240 NOTICE: 3.0
    16:07:15 T:140735084313792 WARNING: JpegIO: Error 55: Not a JPEG file: starts with 0x%02x 0x%02x
    16:07:15 T:140735084313792 ERROR: Texture manager unable to load file: /Users/armando/Library/Application Support/XBMC/userdata/addon_data/script.doorbell/cam_2.jpg

    • 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.

  28. @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.

  29. Hello, does it possible to use and modify your code to add it in my script for fibaro’s box??
    I only add the possibility to have more than one camera.
    Thanks

  30. Yes, you can, you can dupicate the code
    # Import the XBMC/XBMCGUI modules.
    import xbmc, xbmcgui, time, urllib, xbmcvfs, xbmcaddon, os
    __addon__ = xbmcaddon.Addon()
    __addonid__ = __addon__.getAddonInfo(‘id’)

    url=’http://canino2.dyndns-server.com:8081/snapshot.cgi’
    url1=’http://canino2.dyndns-server.comYCX:8082/snapshot.cgi’
    url2=’http://canino2.dyndns-server.com:8083/snapshot.cgi’
    url3=’http://canino2.dyndns-server.com:8080/snapshot.cgi’

    #path = xbmc.translatePath(‘/media/usb0/’)
    path = xbmc.translatePath(‘special://profile/addon_data/%s’ % __addonid__)

    if not xbmcvfs.exists(path):
    xbmcvfs.mkdir(path)

    imagefile = os.path.join(path, ‘cam1.png’)
    imagefile1 = os.path.join(path, ‘cam2.png’)
    imagefile2 = os.path.join(path, ‘cam3.png’)
    imagefile3 = os.path.join(path, ‘cam4.png’)

    #xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER).play(url+path)
    #xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER).play(‘/media/usb0/videos/Nissan/0_Nissan Mexico_0.flv’)
    # /media/usb0/videos/Nissan/0_Nissan Mexico_0.flv

    #========================================================================
    # Class – Set the initial image
    #========================================================================

    class CamView(xbmcgui.WindowDialog):
    #class CamView(xbmcgui.Window):

    def __init__(self):
    #
    #set the initial image before the window is shown
    #aspectRatio : [opt] integer – (values
    # 0 = stretch (default),
    # 1 = scale up (crops),
    # 2 = scale down (black bars)
    # colorDiffuse : hexString – (example, ‘0xC0FF0000’ (red tint))

    urllib.urlretrieve(url, imagefile)
    self.image = xbmcgui.ControlImage(0, 0, 640, 360, imagefile, aspectRatio=2) # Arriba-Izquierda
    self.addControl(self.image)

    urllib.urlretrieve(url1, imagefile1)
    self.image1 = xbmcgui.ControlImage(640, 0, 640, 360, imagefile1, aspectRatio=2) # Arriba-Derecha
    self.addControl(self.image1)

    urllib.urlretrieve(url2, imagefile2)
    self.image2 = xbmcgui.ControlImage(0, 360, 640, 360, imagefile2, aspectRatio=2) # Abajo-Izquierda
    self.addControl(self.image2)

    urllib.urlretrieve(url3, imagefile3)
    self.image3 = xbmcgui.ControlImage(640, 360, 640, 360, imagefile3, aspectRatio=2) # Abajo-Derecha
    self.addControl(self.image3)
    #========================================================================
    # Programa
    #========================================================================
    viewer = CamView()
    viewer.show()

    start_time = time.time()
    firstimage = True

    while(time.time() – start_time <= 59): # Durante 1 minuto

    urllib.urlretrieve(url, imagefile)
    viewer.image.setImage("")
    viewer.image.setImage(imagefile)

    urllib.urlretrieve(url1, imagefile1)
    viewer.image1.setImage("")
    viewer.image1.setImage(imagefile1)

    urllib.urlretrieve(url2, imagefile2)
    viewer.image2.setImage("")
    viewer.image2.setImage(imagefile2)

    urllib.urlretrieve(url3, imagefile3)
    viewer.image3.setImage("")
    viewer.image3.setImage(imagefile3)

    # curr_time = round(time.time() – start_time, 0)
    # if firstimage:
    # nowtime=time.strftime("%I:%M %p")
    # xoptions="Notification("Doorbell",%s, 13800, special://masterprofile/media/bell1.png)" % (nowtime)
    # xbmc.executebuiltin(xoptions)
    # viewer.image.setAnimations([('conditional', 'effect=fade start=0 end=90 time=250 delay=125 condition=true',), ('conditional', 'effect=slide start=0,400 end=0,0 time=250 condition=true',)])
    # viewer.image1.setAnimations([('conditional', 'effect=fade start=0 end=90 time=250 delay=125 condition=true',), ('conditional', 'effect=slide start=0,400 end=0,0 time=250 condition=true',)])
    # viewer.image2.setAnimations([('conditional', 'effect=fade start=0 end=90 time=250 delay=125 condition=true',), ('conditional', 'effect=slide start=0,400 end=0,0 time=250 condition=true',)])
    # viewer.image3.setAnimations([('conditional', 'effect=fade start=0 end=90 time=250 delay=125 condition=true',), ('conditional', 'effect=slide start=0,400 end=0,0 time=250 condition=true',)])
    # firstimage = False
    # elif curr_time == 59:
    # viewer.image.setAnimations([('conditional', 'effect=fade start=90 end=90 time=0 condition=true',), ('conditional', 'effect=slide start=0,0 end=0,400 time=250 condition=true',)])
    # viewer.image1.setAnimations([('conditional', 'effect=fade start=90 end=90 time=0 condition=true',), ('conditional', 'effect=slide start=0,0 end=0,400 time=250 condition=true',)])
    # viewer.image2.setAnimations([('conditional', 'effect=fade start=90 end=90 time=0 condition=true',), ('conditional', 'effect=slide start=0,0 end=0,400 time=250 condition=true',)])
    # viewer.image3.setAnimations([('conditional', 'effect=fade start=90 end=90 time=0 condition=true',), ('conditional', 'effect=slide start=0,0 end=0,400 time=250 condition=true',)])
    # print "catch"
    # else:
    # viewer.image.setAnimations([('conditional', 'effect=fade start=90 end=90 time=0 condition=true',)])
    # viewer.image1.setAnimations([('conditional', 'effect=fade start=90 end=90 time=0 condition=true',)])
    # viewer.image2.setAnimations([('conditional', 'effect=fade start=90 end=90 time=0 condition=true',)])
    # viewer.image3.setAnimations([('conditional', 'effect=fade start=90 end=90 time=0 condition=true',)])
    # print curr_time
    xbmc.sleep(500)

    #xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER).play('/media/usb0/videos/Nissan/0_Nissan Mexico_0.flv')
    #the_player = xbmc.Player(xbmc.PLAYER_CORE_AUTO)
    #the_player.play(url)
    #while the_player.isplaying():
    # xbmc.sleep(250)
    #the_player.stop()

    viewer.close()
    del viewer

    • Thanks, have you tested this? Can you check it into my repo if you would like access. Or arrange to email me the file so that any character encoding issues in the browser doesn’t screw it up.

  31. Great script, thanks for sharing. I thought I would give back by adding some comments.

    For those of you who are looking for the json call:

    From a browser:

    http://ip:port/jsonrpc?request={“jsonrpc”:”2.0″,”id”:1,”method”:”Addons.ExecuteAddon”,”params”:{“addonid”:”script.doorbell”}}

    where:
    ip = ip address or name of xbmc pc
    port: xbmc port number

    From a linux shell:

    wget –user=xbmc –password=’xbmc’ ‘http://ip:port/jsonrpc?request={“jsonrpc”:”2.0″,”id”:1,”method”:”Addons.ExecuteAddon”,”params”:{“addonid”:”script.doorbell”}}’

    where:
    xbmc = username
    xbmc = password
    ip = ip address or name of xbmc pc
    port: xbmc port number

    Also you must make sure that the url used in this script pulls and image from your camera.

    For Foscam IP camera owners you can utilize the following url in this script:

    http://ip:port/snapshot.cgi?user=cam&pwd=pass

    where:
    ip = ip address of camera
    port: camera port number
    cam = username
    pass = password

    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.

    Hope this helps someone.

  32. 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.

  33. Excellent script! I interfaced it with ZoneMinder and decided to add a way to see motion from multiple cameras, as well as display them on all XBMC installations simultaneously. Here are my changes:

    doorbell.py_________________________________________
    import sys
    args = [‘CamID’,’CamName’]
    dbvar = {‘CamID’: 1,
    ‘CamName’: ‘Default Camera’}

    for item in sys.argv:
    arg = item.split(‘=’)
    i = arg[0]
    if arg[0] in args:
    j = arg[1]
    dbvar.update({arg[0]:arg[1]})

    url=’http://zoneminderserver/cgi-bin/nph-zms?mode=single&monitor=’+str(dbvar[‘CamID’])+’&scale=100&user=myuname&pass=mypass’

    xoptions=”Notification(“Motion on “+str(dbvar[‘CamName’])+” camera detected”,%s, 13800, special://masterprofile/media/bell1.png)” % (nowtime)
    _________________________________________

    For anyone else attempting to do this, I used the trigger script found in the ZM wiki:
    http://www.zoneminder.com/wiki/index.php/FAQ#How_can_I_use_ZoneMinder_to_trigger_something_else_when_there_is_an_alarm.3F

    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:

    system(“/sbin/ZoneMinderTrigger CamID=”.$monitor->{Id}.” CamName=”.$monitor->{Name});
    sleep(12)

    I’m more familiar with Python, so that’s why it’s not all confined in the ZM perl script
    ZoneMinderTrigger_________________________________________
    #!/usr/bin/python

    # This script is called by the ZoneMinderAlarm daemon/script and notifies
    # all XBMC installations to overlay pictures on the screen
    # It requires the doorbell xbmc plugin
    # http://homeawesomation.wordpress.com/2013/02/18/doorbell-ipcam-xbmc-update/
    # Credit for send_json_command to u/sffjunkie
    # http://forum.xbmc.org/showthread.php?tid=92196

    import json, httplib, base64, sys

    xbmc_host=[‘myHTPC’,’192.168.1.102′] #List of XBMC HTPCs to send notification to
    xbmc_port=’8080′
    username=’uname’
    password=’pword’

    args = [‘CamID’,’CamName’]
    dbvar = {‘CamID’: 1,
    ‘CamName’: ‘Default’}
    for item in sys.argv:
    arg = item.split(‘=’)
    i = arg[0]
    if arg[0] in args:
    j = arg[1]
    dbvar.update({arg[0]:arg[1]})

    def send_json_command(xbmc_host, xbmc_port, method, params=None, id=1, username=username, password=password):
    command = {‘jsonrpc’: ‘2.0’, ‘id’: id, ‘method’: method}
    if params is not None: command[‘params’] = params
    payload = json.dumps(command, ensure_ascii=False, sort_keys=True)
    payload.encode(‘utf-8’)
    headers = {‘Content-Type’: ‘application/json’}
    if password != ”:
    userpass = base64.encodestring(‘%s:%s’ % (username, password))[:-1]
    headers[‘Authorization’] = ‘Basic %s’ % userpass
    conn = httplib.HTTPConnection(xbmc_host, xbmc_port)
    data = None
    try:
    conn.request(‘POST’, ‘/jsonrpc’, payload, headers)
    response = conn.getresponse()
    if response.status == 200: data = json.loads(response.read())[‘result’]
    else: data = ‘Response Error’
    except:
    data = ‘Connection Error’
    conn.close()
    return data

    def xbmc_doorbell(xbmc_host, xbmc_port=xbmc_port):
    for x in range(0, len(xbmc_host)):
    result = send_json_command(xbmc_host[x], xbmc_port, ‘Addons.ExecuteAddon’,{‘addonid’:’script.doorbell’,’params’:{‘CamID’:str(dbvar[‘CamID’]),’CamName’:str(dbvar[‘CamName’])}})
    print xbmc_host[x]+”: “+result

    xbmc_doorbell(xbmc_host)
    _________________________________________

    There’s probably better ways to do this (I’m a shadetree programmer), but it seems to work well for me.

  34. I get a parse error on the Json call are you sure you code is correct I can get the picture to show from running the addon in xbmc but cant make it pop up by the trigger. XBMC gotham alpha 7

    • I’ve never tried it with that version. It’s not an issue with the script since you can run it. It’s an issue with the json call. You’ll probably have to look at XBMC’s wiki for that version.

    • 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.

  35. to jrock,

    when I put the Jsonrpc request on chrome browser as follow

    http://ip:port/jsonrpc?request={“jsonrpc”:”2.0″,”id”:1,”method”:”Addons.ExecuteAddon”,”params”:{“addonid”:”script.doorbell”}}

    it showed this error
    {“error”:{“code”:-32700,”message”:”Parse error.”},”id”:null,”jsonrpc”:”2.0″}

    and the xmbc log showed the following
    22:50:03 T:2795217984 ERROR: JSONRPC: Failed to parse ‘{? sonrpc? id?

    Thanks

    • 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.

  36. Great script! The path to the icon of the bell is not correct in the version i got to download. Only as info for you. Good job

  37. Pingback: An Intelligent Doorbell with IP Camera | Vitt Nexia Home Automation Installer

      • Thanks for the reply, I have looked at a lot of tutorials and have modified some code as per below but I get no response.
        I am testing by sending a popup message. This works from a browser;

        http://10.0.0.24:8082/jsonrpc?request={%22jsonrpc%22:%222.0%22,%22method%22:%22GUI.ShowNotification%22,%22params%22:{%22title%22:%22Motion%20Detected%22,%22message%22:%22Front%20Door%22},%22id%22:1}

        Im sure its connecting to xbmc as when I change the port it wont connect.
        Im thinking its a syntax problem.

        #include
        #include

        /////////////////
        // MODIFY HERE //
        /////////////////
        byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 }; // Be sure this address is unique in your network

        //Numeric Pin where you connect your switch
        #define pinDevid1 3 // Example : the mailbox switch is connect to the Pin 3

        // Debug mode
        #define DEBUG true
        ///////
        //End//
        ///////

        char serverName[] = “10.0.0.24”;
        boolean pinDevid1State = false;

        char buffer [256];
        int offtime = 100;
        int ontime = 10;

        // Initialize the Ethernet client library
        // with the IP address and port of the server
        // that you want to connect to (port 80 is default for HTTP):
        EthernetClient client;

        void setup() {
        Serial.begin(9600);
        pinMode(pinDevid1, INPUT);

        // start the Ethernet connection:
        if (Ethernet.begin(mac) == 0) {
        Serial.println(“Failed to configure Ethernet using DHCP”);
        // no point in carrying on, so do nothing forevermore:
        while(true);
        }
        else{
        Serial.println(“Ethernet ready”);
        }
        // give the Ethernet shield time to initialize:
        delay(500);
        }

        void loop()
        {
        ////
        // Listening for the pinDevid1 state
        ////
        if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON
        {
        if(DEBUG){Serial.println(“pinDevid1 is HIGH”);}
        pinDevid1State = true;
        //Sending message to xbmc when the pin is HIGHT
        sendToXBMC();
        }
        if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF
        {
        if(DEBUG){Serial.println(“pinDevid1 is LOW”);}
        pinDevid1State = false;
        //Sending message to xbmc when the pin is LOW
        //sendToXBMC(DEVID1);
        }
        }

        //Function for sending the message to xbmc
        void sendToXBMC()
        {
        if(DEBUG){Serial.println(“connecting…”);}

        if (client.connect(serverName, 8082)) {
        if(DEBUG){Serial.println(“connected”);}

        if(DEBUG){Serial.print(“sendind request”);}
        //NONE OF THESE WORK
        client.println(“/jsonrpc?request={ jsonrpc : 2.0 , method : GUI.ShowNotification , params :{ title : Motion Detected , message : Front%20Door }, id :1}”);
        client.println(“GET /jsonrpc?request={ jsonrpc : 2.0 , method : GUI.ShowNotification , params :{ title : Motion Detected , message : Front%20Door }, id :1}”);
        client.println(“/jsonrpc?request={%22jsonrpc%22:%222.0%22,%22method%22:%22GUI.ShowNotification%22,%22params%22:{%22title%22:%22Motion%20Detected%22,%22message%22:%22Front%20Door%22},%22id%22:1}”);
        client.println(“GET /jsonrpc?request={%22jsonrpc%22:%222.0%22,%22method%22:%22GUI.ShowNotification%22,%22params%22:{%22title%22:%22Motion%20Detected%22,%22message%22:%22Front%20Door%22},%22id%22:1}”);
        }
        else {
        if(DEBUG){Serial.println(“connection failed”);}
        }

        // if there are incoming bytes available
        // from the server, read them and print them:
        if(DEBUG){
        if (client.available()) {
        char c = client.read();
        Serial.print(c);
        }
        }

        if(DEBUG){Serial.println();}
        if(DEBUG){Serial.println(“disconnecting.”);}
        client.stop();
        }

  38. In simple terms could you tell me how to set this up? I have a doorbell, would like to buy a Pi as the “doorbell server” and an ip camera to hook it up.

    No idea what I’d need to put on the Pi or how to set it up to trigger the call to the XBMC machines around the house?

    • 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.

    • could you please give me more information on the error? You’ll probably have to check your xbmc.log file. Does the script run manually or are you having issues with the pop-up notification?

      • Hey
        I have attempted to fix it for you and was hoping to post the results here.. anyway..
        heres what happens:

        Fresh install of XBMC Gotham or Openelec Gotham (Any nightly)

        Go the install from a zip and get this on screen:
        http://s27.postimg.org/aa2jxxrlf/screenshot004.png

        LOG:
        11:01:40 T:15476 NOTICE: Thread JobWorker start, auto delete: true
        11:02:42 T:10408 NOTICE: Previous line repeats 1 times.
        11:02:42 T:10408 NOTICE: Thread BackgroundLoader start, auto delete: false

        ============================
        So this is what I did following this: –
        http://xbmc.org/xbmc-13-gotham-note-to-add-on-developers/

        I edited the addon.xml to include this line

        but got the not correct structure.

        ==============================

        Anyway, after more digging, the issue is caused by editing the file in the zip instead of creating a NEW zip of the plugin..

  39. Friend, I have doubts that the product use x10 to call it, could describe what you used in x10? ?

  40. 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)

    any help appreciated, thank you !

Leave a Reply