Danal Estes
April 18th, 2004, 05:59 AM
I run MisterHouse (see http://www.misterhouse.net) for general home automation. When installing NetRemote, I desired to interface to MH for lighting control. While I plan to work up a two-way interface, and document better at some point, here's enough to get started:
1) In your MisterHouse mh.private.ini file:
server_NetRemote_port=4997
2) Create a NetRemote.pl with at least:
$NetRemote = new Socket_Item("Status\n\r", 'Status', 'server_NetRemote');
Suggested code for NetRemote.pl:
# Diagnostic Code
if (active_now $NetRemote) {
my $client = $Socket_Ports{'server_NetRemote'}{client_ip_addres s};
print_log "NetRemote session opened for $client";
}
if (inactive_now $NetRemote) {
my $client = $Socket_Ports{'server_NetRemote'}{client_ip_addres s};
print_log "NetRemote session closed for $client";
}
And, an example of how to take an action based on a remote button:
# Handle input from the remote
my $data;
if (defined($data = said $NetRemote)) {
print_log "Netremote data $data";
$data =~ s/ *\r\n?$//;
set $Kitchen_Island_Light ON if $data eq 'Kitchen ON';
set $Kitchen_Island_Light OFF if $data eq 'Kitchen OFF';
}
3) In NetRemote File->Properties->Plugins, create a "Generic" instance. This will default to -20.Be sure and set the IP address to your MisterHouse machine (NOT your Girder or HTPC).
Set the port number to whatever you picked above in (1), and set timout to 100 or so.
No 'msg' file is required, but you could use one if you desire.
4) Create buttons that have an IR action. The IR action must:Have an IR code of 5001 0000 0000 0002 ffec 0000 0000 0000
Note: 'ffec' maps to instance -20. If you change the instance number, change this to the signed 16 bit equivalent.
Have a name that is passed to MH.
Note: The name is returned by MH 'said' method; it is case sensitive.
Given the example code snippet above, valid IR action names would be 'Kitchen ON' and 'Kitchen OFF'.
There are MANY variants of this; just for two examples: I'm ignoring MH state support that's built in to the object... this could be used for hooked/triggered behaviors; ditto for the NR side and the MSG file.
That's it for now...
Danal
P.S. There is a known bug in NR 0.995 RC7. When exit & restart NR, the IP address in the generic plugin is truncated. Reset it to the correct address of the MH machine, and all works again...
1) In your MisterHouse mh.private.ini file:
server_NetRemote_port=4997
2) Create a NetRemote.pl with at least:
$NetRemote = new Socket_Item("Status\n\r", 'Status', 'server_NetRemote');
Suggested code for NetRemote.pl:
# Diagnostic Code
if (active_now $NetRemote) {
my $client = $Socket_Ports{'server_NetRemote'}{client_ip_addres s};
print_log "NetRemote session opened for $client";
}
if (inactive_now $NetRemote) {
my $client = $Socket_Ports{'server_NetRemote'}{client_ip_addres s};
print_log "NetRemote session closed for $client";
}
And, an example of how to take an action based on a remote button:
# Handle input from the remote
my $data;
if (defined($data = said $NetRemote)) {
print_log "Netremote data $data";
$data =~ s/ *\r\n?$//;
set $Kitchen_Island_Light ON if $data eq 'Kitchen ON';
set $Kitchen_Island_Light OFF if $data eq 'Kitchen OFF';
}
3) In NetRemote File->Properties->Plugins, create a "Generic" instance. This will default to -20.Be sure and set the IP address to your MisterHouse machine (NOT your Girder or HTPC).
Set the port number to whatever you picked above in (1), and set timout to 100 or so.
No 'msg' file is required, but you could use one if you desire.
4) Create buttons that have an IR action. The IR action must:Have an IR code of 5001 0000 0000 0002 ffec 0000 0000 0000
Note: 'ffec' maps to instance -20. If you change the instance number, change this to the signed 16 bit equivalent.
Have a name that is passed to MH.
Note: The name is returned by MH 'said' method; it is case sensitive.
Given the example code snippet above, valid IR action names would be 'Kitchen ON' and 'Kitchen OFF'.
There are MANY variants of this; just for two examples: I'm ignoring MH state support that's built in to the object... this could be used for hooked/triggered behaviors; ditto for the NR side and the MSG file.
That's it for now...
Danal
P.S. There is a known bug in NR 0.995 RC7. When exit & restart NR, the IP address in the generic plugin is truncated. Reset it to the correct address of the MH machine, and all works again...