Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Topic:
Insteon control with PowerHome (TCP/IP)
This thread has 6 replies. Displaying all posts.
Post 1 made on Wednesday February 11, 2009 at 11:26
raven77m
Lurking Member
Joined:
Posts:
February 2009
8
Hello,
I just recently bought a TSU9400 (nice remote but horrible build quality!). I am working on learning the ins-N-outs. I took and passed both the level one and level two "certified installer" exams and I also read through the Developers Guide. I got all my components working the way I want, now I need to get my lights working!
I am using insteon devices and PowerHome Software. I really dont want to use an IR converter so I am trying to figure out a way to control my PowerHome devices over wifi. Does anyone else use this software that could maybe give me some hints where to start?
Below is an example of HTML to turn a light on.

function sk(value)
{document.evalformula.formula.value = value; document.evalformula.submit();}
onclick="sk('ph_rtne( ph_insteon( \'<%"DBATHROOMLIGHT"%>\', ion, int(255)) )')"

Also the PowerHome webserver is password protected, I am not to sure how to use the socket.connect with a username/password (although that probably wont be to hard to figure out). My biggest problem is I am not sure how to convert the above code to work in Prontoscript. I am sure it's possible, I just don't know where to start!
:(
Any suggestions?
Thanks A LOT in advance!!
PS I already did lots of searching on this forum and others....

Last edited by raven77m on February 11, 2009 12:17.
Post 2 made on Wednesday February 11, 2009 at 16:53
Cineman
Long Time Member
Joined:
Posts:
October 2008
13
I´m not a programmer. But my light also works with HTML codes TCP/IP.
Perhaps you can use this code .
After GET put your command.

var socket = new TCPSocket(false);
socket.onConnect = function()
{
socket.write("GET /preset?switch=1&value=off HTTP/1.0\r\n\r\n")
socket.close();
};
socket.onClose = function()
{
};
socket.onIOError = function(e)
{
label = "Error: " + e;
};
socket.connect('192.168.1.42', 80, 3000);
OP | Post 3 made on Wednesday February 11, 2009 at 17:29
raven77m
Lurking Member
Joined:
Posts:
February 2009
8
Thanks for the reply!!
I think I am on the right track. if I type this
[Link: raven77.no-ip.info]("WALKLIGHTS", ion, int(255))
in my browser and hit enter it turns on my lights.
I have a few questions though, it only works if I authenticate it first with a user name and password. How do I get that data in the above code?
Is this close to what it should look like?
socket.write("GET /ph-cgi/evalformula?formula=ph_insteon("WALKLIGHTS", ion, int(255)) HTTP/1.0\r\n\r\n")
and last can I just put the above code in the action area for a button and have it turn the light on?
Sorry for all the dumb questions, I am getting it slowly but surely!
:)
thanks again!!
Post 4 made on Thursday February 12, 2009 at 00:17
Barry Gordon
Founding Member
Joined:
Posts:
August 2001
2,157
Password Authorization:

I just added the code to SlimPronto to submit userid and password on http requets. It was actually quite trivial after some pointers from Lyndel and some web searching. In my case I submit on every request as I close the socket down on each request . I do not believe the server cares if it comes in on each transaction.

Basically I add the Authorization sequence in the portion of the message after the http/1.0. How to do it and what it looks like is well documented on the web. Search for http and Authorization. You will find various modes. I am using basic authorization and I just plug it in after the http/1.0\r\n so it looks like
"http: GET . . . / http/1.0\r\n"+"Authorization: Basic "+base64(LOGIN.Userid +":"+ LOGIN.Password)+"\r\n\r\n"

Login.userid is the userid string and login.password is the password string. I made sure my userid and password did not need to be URI encoded, but in the general case it should be URI encoded prior to applying the base64 function. You will also need the function to convert to base 64 which is also well documented on the web but looks like: (written to be understood, not to be efficient)


function base64(inp) { // this program converts the string to base 64 notation.
var password=""; var a=inp.length; var b=Math.floor(a/3); var c=a%3;
var d=0; var e=0; var f=0; var g=0; var trailer=""; var result=""; var i=0;
var LUT="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
for(i=0; i < a-c; i=i+3)
{
d=(inp[i].charCodeAt(0) & 0x00FC)/4;
e=(inp[i].charCodeAt(0) & 0x0003)*16 + (inp[i+1].charCodeAt(0) & 0X00F0)/16;
f=(inp[i+1].charCodeAt(0) & 0X000F)*4+(inp[i+2].charCodeAt(0) & 0X00C0)/64;
g=(inp[i+2].charCodeAt(0) & 0X003F);
result=LUT.charAt(d)+LUT.charAt(e)+LUT.charAt(f)+LUT.charAt(g)
password=password+result
}
switch(c)
{
case 0: break;
case 1: d=(inp[i].charCodeAt(0) & 0X00FC)/4;
e=(inp[i].charCodeAt(0) & 0x0003)*16 +0;
trailer=LUT.charAt(d)+LUT.charAt(e)+"=="; break;
case 2: d=(inp[i].charCodeAt(0) & 0x00FC)/4;
e=(inp[i].charCodeAt(0) & 0x0003)*16 + (inp[i+1].charCodeAt(0) & 0X00F0)/16;
f=(inp[i+1].charCodeAt(0) & 0X000F)*4+0;
trailer=LUT.charAt(d)+LUT.charAt(e)+LUT.charAt(f)+"="; break
}
return password+trailer
}

Last edited by Barry Gordon on February 12, 2009 00:27.
OP | Post 5 made on Thursday February 12, 2009 at 07:04
raven77m
Lurking Member
Joined:
Posts:
February 2009
8
I think I got the password thing figured out (I added the static IP of my remote to the trusted address in the PowerHome webserver). But I still can't seem to get this to work. I ran the debug script and found a few problems, but I fixed those and now I get no errors and it still doesn't work. Below is two of the MANY variations I tried, any idea's?

var socket = new TCPSocket(false);
socket.onConnect = function()
{
socket.write("GET /ph-cgi/evalformula?formula=ph_insteon('LROOMLIGHTS', ion, int(255)) HTTP/1.0\r\n\r\n");
socket.close();
};
socket.onClose = function()
{
};
socket.onIOError = function(e)
{
label = "Error: " + e;
};
socket.connect("192.168.1.2", 88, 3000);

Here is another one I tired...

var socket = new TCPSocket(true);
socket.connect('192.168.1.2', 88, 3000);
socket.write("GET /ph-cgi/evalformula?formula=ph_insteon('LROOMLIGHTS', ion, int(255)) HTTP/1.0\r\n\r\n");
socket.close();

If I enter the address below in IE or Firefox it turns the light on every time.

192.168.1.2:88/ph-cgi/evalformula?formula=ph_insteon('LAMPDIM', ion, int(255))

Thanks again for any input, I am starting to get a little frustrated.
:)
Post 6 made on Thursday February 12, 2009 at 11:49
Barry Gordon
Founding Member
Joined:
Posts:
August 2001
2,157
The only thing I see a little different is the missing HTTP in the front of the string written to the socket. Try socket.write("http: GET / . . . "

You may not need it but I am not sure and since it is not working without it.
OP | Post 7 made on Thursday February 12, 2009 at 17:49
raven77m
Lurking Member
Joined:
Posts:
February 2009
8
Thanks for the suggestions, I tried it but now luck!
It seems so easy to do but I just cant get it to work.


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse