Need Help from Python Guru... - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: Need Help from Python Guru... (/showthread.php?tid=17208) |
- Livin - 2006-01-06 the goal is to be able to send http post to a homeseer web server (home automation software which is very popular). according to the homeseer documentation a simple http command should be accepted directly. if i'm reading it correctly? here's the page in the online manual for homeseer with the info: homeseer info on controlling devices from html i simplified my .py to only 2 lines... Quote:import urllib error on xbmc log... Quote:file "q:\python\python23.zlib\urllib.py", line 78, in urlopen i've taken the commands i'm using from working http & asp pages. here's actual code from an html page i'm using for the same device i'm trying in my .py... Quote:<form method="post"> - Asteron - 2006-01-06 the post statement looks fine but it seems like it can't connect. i think you need to specify the specific asp page in that url (the page that the submit goes to. try looking at that submitform() javascript function that gets called to see if your url is ok. - Livin - 2006-01-06 asteron, i found the script code: Quote:<script> here's what i caputred from my browser... bookmark=83274&ref_page=stat&control_device=kitchen+lights&action_on=on&selectdim=0 ... i believe the only items necessary are starting with control_device. i have some custom asp pages that i built and the stream looks like this... action=image&commandimage=hs.execx10byname+%22kitchen+lights%22%2c+%22off%22%2c+100&x=4&y=6 ... i'm not sure that anything is needed except the built-in homeseer function hs.execx10byname plus the params after it. i get the same error no matter which of these commands i try: Quote:urllib.urlopen('http://192.168.1.11/hact/kitchen.asp', urllib.urlencode({'action': 'hs.execx10byname+kitchen+lights%2c+on %2c+100&x=4&y=6'})) Quote:urllib.urlopen('http://192.168.1.11/hact/kitchen.asp', urllib.urlencode({'commandimage': 'hs.execx10byname+kitchen+lights%2c+on %2c+100&x=4&y=6'})) Quote:urllib.urlopen('http://192.168.1.11', 'control_device=kitchen+lights&action_on=on&selectdim=0') Quote:urllib.urlopen('http://192.168.1.11', urllib.urlencode({'control_device': 'kitchen+lights&action_on=on&selectdim=0'})) log: Quote:info urllib.urlopen('http://192.168.1.11/hact/kitchen.asp', if i use this code i get 'operation timed out'... Quote:import urllib log: Quote:file "q:\python\python23.zlib\urllib.py", line 78, in urlopen any thoughts? - Asteron - 2006-01-07 those two asp lines look to be of different formats... the first one in python i think would be {'bookmark' : '83274', 'ref_page' : 'stat', 'control_device' : 'kitchen lights', 'action_on' : 'on', 'selectdim' : '0'} and the second mapping looks like {'action':'image','commandimage':'hs.execx10byname "kitchen lights", "off", 100','x':'4','y':'6'} i think the urlencode thing will turn it into & delimted %escapes and turn space into +. this is if i am reading the post right which i dont know but you should try these above. - Livin - 2006-01-07 i update my previous post to be more "complete" with my current testing. i tried your new suggested params line. i get the same error: [errno socket error] (10060, 'operation timed out') |