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.
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
[CODE] ##Deprecated Example! #Import the XBMC/XBMCGUI modules. import xbmc, xbmcgui, time, urllib #inherit from WindowDialog instead of Window so that it's shown on top of #what's onscreen instead of replacing it entirely class CamView(xbmcgui.WindowDialog): def __init__(self): #Define image location and size self.image = xbmcgui.ControlImage(870, 438, 380, 253, "") self.addControl(self.image) viewer = CamView() viewer.show() start_time = time.time() while(time.time() - start_time <= 14): #set url to ip cam image, password auth not supported urllib.urlretrieve("http://asdf.com/camera/", '/tmp/bell.jpg') viewer.image.setImage("") viewer.image.setImage("/tmp/bell.jpg") #Define image transparency viewer.image.setAnimations([('conditional', 'effect=fade start=90 end=90 time=0 condition=true',)]) xbmc.sleep(500) viewer.close() del viewer [/CODE]
What I’ve created is a regular XBMC script like all other addons. You can get my script in ZIP format from github here, https://github.com/ssshake/xbmc-scripts/blob/master/script.doorbell.zip?raw=true
The thread on XBMC forums for this project can be seen here: http://forum.xbmc.org/showthread.php?tid=156665
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¶meter=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¶meter=XBMC.RunScript(/PATH/TO/SCRIPTS/DIR/script.doorbell/doorbell.py)"; or you can just paste this into a regular webbrowser to test.