Home Automation Help needed with Sockets, using Mister House...

Bookmark this page:  YahooMyWeb Yahoo!  Google Google  Windows Live Favorites Windows Live  del.icio.us del.icio.us  digg digg  Add to Netscape Netscape
Subject Author Date
Help needed with Sockets, using Mister House... Jack Edin 09-15-05
Posted by Jack Edin on September 15, 2005, 10:15 pm
Please log in for more thread options


Hello,

Please excuse the newbie question...

I want to send the word "Mail", followed by a CR over the Ethernet to IP
address 192.168.1.123 on Port 2101.

I searched the MH Docs to no avail...

I looked at various code examples, and tried many things.
I can't get it right!

The code I use now looks like this:

# Window/Door sensor items

if ($state = state_now $Mailbox_sensor) {
$state = "open" if ($state =~ /^alert/i);
$state = "closed" if ($state =~ /^normal/i);
print_log "Mailbox's front door is now $state";

if ($state eq "open"){play(`file` => "GOTMAIL.wav")}
}

I'm using an X10 DS10A embedded into the door of my new plastic mailbox.

Here is a picture:

http://www.logicunlimited.com/images/sModdedDoor-Front&Back+.jpg

I have an Elk M1 panel. It can listen to port 2101 on the Ethernet...

I want Mister House to trigger the mighty M1, via Ethernet in this manor.

Can anybody help?

I'm such a newbie I may need you to show me where to insert it into my
code, too.

Just get one "(" in the wrong place, or forget a "}" and you're not
getting there!

Been doing alot of head scratchin. Please help!

Thankx, in advance!

Jack
:)

Posted by rlsusenet@NOSPAMPUHLEEZschnapp on September 16, 2005, 4:26 pm
Please log in for more thread options


Jack Edin wrote:
> Hello,
>
> Please excuse the newbie question...
>
> I want to send the word "Mail", followed by a CR over the Ethernet to IP
> address 192.168.1.123 on Port 2101.
>
> I searched the MH Docs to no avail...
>
> I looked at various code examples, and tried many things.
> I can't get it right!
>
> The code I use now looks like this:
>
> # Window/Door sensor items
>
> if ($state = state_now $Mailbox_sensor) {
> $state = "open" if ($state =~ /^alert/i);
> $state = "closed" if ($state =~ /^normal/i);
> print_log "Mailbox's front door is now $state";
>
> if ($state eq "open"){play(`file` => "GOTMAIL.wav")}
> }
>
> I'm using an X10 DS10A embedded into the door of my new plastic mailbox.
>
> Here is a picture:
>
> http://www.logicunlimited.com/images/sModdedDoor-Front&Back+.jpg
>
> I have an Elk M1 panel. It can listen to port 2101 on the Ethernet...
>
> I want Mister House to trigger the mighty M1, via Ethernet in this manor.
>
> Can anybody help?
>
> I'm such a newbie I may need you to show me where to insert it into my
> code, too.
>
> Just get one "(" in the wrong place, or forget a "}" and you're not
> getting there!
>
> Been doing alot of head scratchin. Please help!
>
> Thankx, in advance!
>
> Jack
> :)

You need to open and print to a socket. I haven't actually tried this,
but adapting from some code in "Programming Perl", it might go something
like this...

require 5.002;
use strict;
use Socket;
my $remote = "192.168.1.123";        # can be a domain name
my $port = 2101;
my $iaddr = inet_aton($remote);
my $paddr = sockaddr_in($port, $iaddr);
my $proto = getprotobyname('tcp');        # unless your device takes 'udp'
socket(MYSOCK, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
connect(SOCK, $paddr);
print SOCK "Mail\n";
close(SOCK);

Posted by Jack Edin on September 18, 2005, 10:51 am
Please log in for more thread options


Hello,

And thank you for making the effort!

You've written in Perl, and I need it in Mister House... Similar..?

In MH there is a "Socket_Item" and it has Parameters O'plenty, separated
by commas - very much like your "socket" command, maybe more...

I suspect much of your code example will work. The definition of your
variables, etc. I tried putting them in quotes within the Socket_item
statement. Wasn't certain if I wanted Single (') or double (") quotes.

I found an example (earlier - for the RF portion) which I copied and
pasted into my code file. Bruce was kind enough to correct it for me.
The example used a "=" and it should have been an "eq". Who knew?!!

Currently Bruce is too busy to reply. I understand, but now I'm high and
dry!

Again; thanks for all of your efforts...

Sincerely,

Jack
;-)


rlsusenet@NOSPAMPUHLEEZschnapp.org wrote:
> You need to open and print to a socket. I haven't actually tried
> this, but adapting from some code in "Programming Perl", it might
> go something like this...
>
> require 5.002;
> use strict;
> use Socket;
> my $remote = "192.168.1.123"; # can be a domain name
> my $port = 2101;
> my $iaddr = inet_aton($remote);
> my $paddr = sockaddr_in($port, $iaddr);
> my $proto = getprotobyname('tcp'); # unless your device takes 'udp'
> socket(MYSOCK, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
> connect(SOCK, $paddr);
> print SOCK "Mail\n";
> close(SOCK);


> Jack Edin wrote:
>
>> Hello,
>>
>> Please excuse the newbie question...
>>
>> I want to send the word "Mail", followed by a CR over the Ethernet to
>> IP address 192.168.1.123 on Port 2101.
>>
>> I searched the MH Docs to no avail...
>>
>> I looked at various code examples, and tried many things.
>> I can't get it right!
>>
>> The code I use now looks like this:
>>
>> # Window/Door sensor items
>>
>> if ($state = state_now $Mailbox_sensor) {
>> $state = "open" if ($state =~ /^alert/i);
>> $state = "closed" if ($state =~ /^normal/i);
>> print_log "Mailbox's front door is now $state";
>>
>> if ($state eq "open"){play(`file` => "GOTMAIL.wav")}
>> }
>>
>> I'm using an X10 DS10A embedded into the door of my new plastic mailbox.
>>
>> Here is a picture:
>>
>> http://www.logicunlimited.com/images/sModdedDoor-Front&Back+.jpg
>>
>> I have an Elk M1 panel. It can listen to port 2101 on the Ethernet...
>>
>> I want Mister House to trigger the mighty M1, via Ethernet in this manor.
>>
>> Can anybody help?
>>
>> I'm such a newbie I may need you to show me where to insert it into my
>> code, too.
>>
>> Just get one "(" in the wrong place, or forget a "}" and you're not
>> getting there!
>>
>> Been doing alot of head scratchin. Please help!
>>
>> Thankx, in advance!
>>
>> Jack
>> :)

Posted by rlsusenet@NOSPAMPUHLEEZschnapp on September 19, 2005, 4:49 pm
Please log in for more thread options


Jack Edin wrote:
> Hello,
>
> And thank you for making the effort!
>
> You've written in Perl, and I need it in Mister House... Similar..?

Mister House is WRITTEN IN Perl. You're running a Perl program. I
know, 'cause I gutted MH to use in my (MUCH simplified, customize) home
automation system. The code I suggested could be incorporated into MH.
You would move the "use" statements out of any subs, ahead of where
you're using the socket stuff. In fact, for MH, you should drop the "use
strict;" statement entirely. And MH might already use Sockets. You can
search for it.

> In MH there is a "Socket_Item" and it has Parameters O'plenty, separated
> by commas - very much like your "socket" command, maybe more...

Probably, but that doesn't mean you HAVE to use it if you don't have
time to figure it out.

> I suspect much of your code example will work. The definition of your
> variables, etc. I tried putting them in quotes within the Socket_item
> statement. Wasn't certain if I wanted Single (') or double (") quotes.

The only difference between single and double quotes is interpolation of
variables contained within the string. Single quoted strings will not
have variables replaced with their content, while double-quoted strings
will.

> I found an example (earlier - for the RF portion) which I copied and
> pasted into my code file. Bruce was kind enough to correct it for me.
> The example used a "=" and it should have been an "eq". Who knew?!!
>
> Currently Bruce is too busy to reply. I understand, but now I'm high and
> dry!
>
> Again; thanks for all of your efforts...
>
> Sincerely,
>
> Jack
> ;-)
>
>
> rlsusenet@NOSPAMPUHLEEZschnapp.org wrote:
> > You need to open and print to a socket. I haven't actually tried
> > this, but adapting from some code in "Programming Perl", it might
> > go something like this...
> >
> > require 5.002;
> > use strict;
> > use Socket;
> > my $remote = "192.168.1.123"; # can be a domain name
> > my $port = 2101;
> > my $iaddr = inet_aton($remote);
> > my $paddr = sockaddr_in($port, $iaddr);
> > my $proto = getprotobyname('tcp'); # unless your device takes 'udp'
> > socket(MYSOCK, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
> > connect(SOCK, $paddr);
> > print SOCK "Mail\n";
> > close(SOCK);
>
>
>> Jack Edin wrote:
>>
>>> Hello,
>>>
>>> Please excuse the newbie question...
>>>
>>> I want to send the word "Mail", followed by a CR over the Ethernet to
>>> IP address 192.168.1.123 on Port 2101.
>>>
>>> I searched the MH Docs to no avail...
>>>
>>> I looked at various code examples, and tried many things.
>>> I can't get it right!
>>>
>>> The code I use now looks like this:
>>>
>>> # Window/Door sensor items
>>>
>>> if ($state = state_now $Mailbox_sensor) {
>>> $state = "open" if ($state =~ /^alert/i);
>>> $state = "closed" if ($state =~ /^normal/i);
>>> print_log "Mailbox's front door is now $state";
>>>
>>> if ($state eq "open"){play(`file` => "GOTMAIL.wav")}
>>> }
>>>
>>> I'm using an X10 DS10A embedded into the door of my new plastic mailbox.
>>>
>>> Here is a picture:
>>>
>>> http://www.logicunlimited.com/images/sModdedDoor-Front&Back+.jpg
>>>
>>> I have an Elk M1 panel. It can listen to port 2101 on the Ethernet...
>>>
>>> I want Mister House to trigger the mighty M1, via Ethernet in this
>>> manor.
>>>
>>> Can anybody help?
>>>
>>> I'm such a newbie I may need you to show me where to insert it into
>>> my code, too.
>>>
>>> Just get one "(" in the wrong place, or forget a "}" and you're not
>>> getting there!
>>>
>>> Been doing alot of head scratchin. Please help!
>>>
>>> Thankx, in advance!
>>>
>>> Jack
>>> :)

Similar ThreadsPosted
Help needed with Sockets, using Mister House... September 15, 2005, 10:15 pm
Whole house audio- 1 receiver for whole house? July 29, 2008, 4:49 pm
Where can I find floor mounted electrical outlets with Continental European sockets ? October 26, 2006, 8:42 am
nightlight solution needed April 20, 2005, 12:57 pm
2 100 amp panel coupler help needed December 11, 2005, 9:08 pm
Dial-up home automation assistance needed June 10, 2006, 1:39 am
Brake method needed for hillside lift October 28, 2006, 3:46 pm
Recommendation needed: Monitor vacation home, detect outages August 21, 2005, 8:25 pm
House Access Help July 29, 2006, 2:05 am
V572AB Whole House Transceiver September 15, 2005, 12:34 pm
Graphic Five Whole House audio October 20, 2006, 1:21 pm
Monitoring whole-house current draw April 21, 2006, 3:22 pm
info on automating my house required April 25, 2006, 12:39 am
Interior Of House Gas Shut Off Valves Question March 20, 2005, 10:52 am
Green House remote wireless thermometer September 8, 2008, 3:28 am