[REQUEST] X10 (Home Automation Control) Script for XBMC
#46
hi affini

i'm not working on it but i am watching this thread for any developments. it would be great to be able to control homeseer in xbmc

keep up the hard work
e
Reply
#47
folks,

sorry for my absence.... had to travel for a week... but am back now for a bit.

affini,
i have also seen the homeseer documentation to control devices via a webpage, but i think it comes down to this....

can you create a simple .html page that turns on a light just by pulling the page up in the browser. it is the same thing as is shown in the homeseer reference you pointed to earlier, except we don't want to have to hit a button to "submit" the command. if you are successful in doing that i think we can make it work.

also, the version i am working on works perfectly with .asp pages, but the drawback is that you have to have a separate .asp for each and every command (this is ok if you don't have to dim anything).

it reads in the device status from homeseer and displays it on the xbox where you can control the devices and have real time status updates on the xbox.

i will post it in a separate post... but would love to totally fix it by getting the post command so that dedicated asp pages are not needed.
Reply
#48
i definitely want to only create the .py and not need any further html/asp pages need to be "supporting" the script.

i've spend tons of time on this... i think i'm close... i just get the 'connection tine out'. if you can help figure out a fix/workaround for that we should be good to go!
I'm not an expert but I play one at work.
Reply
#49
urlib.urlopen is the same as the get command in html not put. mayb thats ur problem, search google for how to post its something todo with addheaders() can't remember the search i dun.
read the xbmc online-manual, faq and search the forums before posting! do not e-mail the xbmc-team asking for support!
read/follow the forum rules! note! team-xbmc never have and never will host or distribute ms-xdk binaries/executables!
Reply
#50
http://effbot.org/librarybook/httplib.htm

if u cnt wrk it out do a google search to find the differnce between put n get
read the xbmc online-manual, faq and search the forums before posting! do not e-mail the xbmc-team asking for support!
read/follow the forum rules! note! team-xbmc never have and never will host or distribute ms-xdk binaries/executables!
Reply
#51
i was following the python library...
http://www.python.org/doc/current/lib/mo...rllib.html

Quote:if the url uses the http: scheme identifier, the optional data argument may be given to specify a post request (normally the request type is get). the data argument must be in standard application/x-www-form-urlencoded format; see the urlencode() function below.

Quote:urlencode( query[, doseq])

convert a mapping object or a sequence of two-element tuples to a ``url-encoded'' string, suitable to pass to urlopen() above as the optional data argument. this is useful to pass a dictionary of form fields to a post request. the resulting string is a series of key=value pairs separated by "&" characters, where both key and value are quoted using quote_plus() above. if the optional parameter doseq is present and evaluates to true, individual key=value pairs are generated for each element of the sequence. when a sequence of two-element tuples is used as the query argument, the first element of each tuple is a key and the second is a value. the order of parameters in the encoded string will match the order of parameter tuples in the sequence. the cgi module provides the functions parse_qs() and parse_qsl() which are used to parse query strings into python data structures.

Quote:the following example uses the "post" method instead:

>>> import urllib
>>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
>>> f = urllib.urlopen("[url]http://www.musi-cal.com/cgi-bin/query"[/url], params)
>>> print f.read()

... it looks like the url i'm sending is a post?
I'm not an expert but I play one at work.
Reply
#52
i figured it out...

it comes down to sending very specific commands to homeseer. otherwise, the hs web server just ignores the commands and the time out occurs. pay close attention to the commands in my script, you'll see what i mean. hint: it is one in the urlencode line.

so without further ado... working home control script

notes:

a) the homeseer commands are 100% working... wahoo!

b) the error trapping/logging is not 100%.
if you try to view the error log on screen it locks up.
if you can fix it please let me know how.

script to do...
a) streamline the creation of the buttons based on a user defined list
b) figure out a way to set dim levels directly in as few steps as possible for dimmable lights
c) create all on/off devices as toggles
d) figure out how to read device status upon screen refreshes

python to-do...
learn how to use a python ide!
learn how to use the xbmc emulator!



I'm not an expert but I play one at work.
Reply
#53
good job
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#54
affini, good work in getting "post" to work!  i just changed a couple of lines in my x10.py script to do the post command instead of calling .asp pages and it works (universally).

it looks like you are about at the point i was last month in creating buttons, reading in data, updating status, etc...so, to save you some time and frustration.....here is a link to my script which has matured a good bit (thx to nuka and asteron) since the early posts in this thread:
x10 script

better yet - here is the whole package:
buzzster's xbmc x10 package

this is a ready to go package that does not care how many devices you have or what the names are - it reads all the data in to lists/arrays.  once you get familiar with how it works, you can see it would be very easy to add dimming functionality if you so desire.  if you study the script carefully, you should find answers to all your questions (a, b, c, and d).

i decided to go with a controllist instead of buttons to make it more universal (as pointed out by asteron in another x-10 thread, you can do things with checkboxes to make them look like a list like his xstocks script).  see the screenshot below - the user just simply clicks on an item in the list and the light comes on or goes off and the status and lightbulb icon are updated automagically (so is homeseer).


Image

the area to the left will have buttons on it to move through different functions.  i am currently working on a webcam button that will control my webcam switching and make the video available to any of my xboxes (sure will be better than running a/v cable to all my tv's).   anyway - once i get the buffering delay worked out on that, i will be updating the script again.
Reply
#55
buzz,
great work my friend! lets work together on this and make is amazing!

i have an idea about automatically updating the current status of devices...

i've been looking at triggering events via python.

if we have the script automatically trigger the homeseer event that runs your update script, it will always have the latest update upon each refresh.

we can actually get more fancy and request status directly from hs (i do this on my asp pages) for each device, no need to a script and reading a text file. we can tackle that later. i do think auto-triggering the current status file update is a must do in the short term.

another thought i had is to create an ini file (i already have much of the format outlined) that the python reads and then will allow for total customization of the screen. i already have tons of transparent gifs i created and use on my asp that will work fine in xbmc (see screenshot, plus i have much more!Wink

i have a few reasons for this...

a) i have several events i want buttons on the screen for.

b) i want 'status only' information on the screen.
- when my hs events run, they set text infomation (strings in hs speak) on some 'status only' devices. i want to display this information on the screen... tells the status of the security system, lighting on the aquarium, etc...

c) i don't want all my devices on the screen, only my most used.


my goal is to mimic my asp screens in functionality...

Image
I'm not an expert but I play one at work.
Reply
#56
affini,

will do.  your thoughts gave me other ideas.... you can define virtual codes that trigger events so you wouldn't have to trigger events, but i bet there is a way anyhoo...

i'll contact you offline as this is turning into more of a homeseer discussion than python.   will report back here with questions for all regarding python or updated scripts....

buzz
Reply

Logout Mark Read Team Forum Stats Members Help
[REQUEST] X10 (Home Automation Control) Script for XBMC0