External Connection ASCII protocol

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
edgar
Member
Posts: 95
Joined: Tue Mar 24, 2009 11:14 pm
Location: Springfield, VA

External Connection ASCII protocol

Post by edgar »

Hi All,

I am working on a little project to try to interface HB with XBMC using a python TCP client script. I developed a simple Server script and client script to test it out and I am able to open a socket connection and send data from the client to the server and vice versa.

I then redirected the client to the HB External Control device hoping I could use the External Control device with ASCII protocol but I am not having any luck.

My code is below (for any Python scripters out there). It is pretty simple and can send a basic string to a Python Server script. I am not sure why HB does not respond to it. When I do run the client script it appears the socket is connecting....but nothing happens. (I know this because if I change ports on the script...the script fails...and also if i uncheck the ASCII check box on the HB Control Device the script hangs.

The help documentation indicates that anything that can establish a TCP socket connection should be able to send commands to HB using the ASCII protocol.....I tried using Telnet and that works fine so i know things are working....I have also confirmed that firewalls are open. In my code example below the Password is HB and the port is 5050- trying to change the power state of the Foyer Light to On.

Any help would be greatly appreciated- thanks in advance!

Kevin

Here is the code in the Python Script:

##client.py
from socket import *
HOST = '_._._._' #HB IP address
PORT = 5050 #our port from before
ADDR = (HOST,PORT)
BUFSIZE = 4096
cli = socket( AF_INET,SOCK_STREAM)
cli.connect((ADDR))
cli.send('/S HB /C SPV /D Foyer Light /P Power State /V On')
cli.close()
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Re: External Connection ASCII protocol

Post by Osler »

Try adding a carriage return/line feed at the end of you send data.

Osler
edgar
Member
Posts: 95
Joined: Tue Mar 24, 2009 11:14 pm
Location: Springfield, VA

Re: External Connection ASCII protocol

Post by edgar »

Osler,

Thank You! Thank You!

That did it....!!!!

Just had to at a \n at the end and it worked!

full line of code just for anyone else interested was changed:

cli.send('/S HB /C SPV /D Foyer Light /P Power State /V On\n')


v/r

Kevin
Post Reply