Author Topic: Misterhouse as Pluto parent device....  (Read 4825 times)

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
Misterhouse as Pluto parent device....
« on: October 24, 2005, 12:44:13 am »
Hi,

based on code for Misterhouse as message interceptor :

http://plutohome.com/support/phpbb2/viewtopic.php?t=389

I've created further step. Now Misterhouse registers as normal Pluto devices and plays role of being parent device for his few internal devices. In this manner, MH devices can be controlled from Pluto (in below example this is not yet functional - need to parse incoming messages from Pluto) - that also displays their status (sensors, etc..)....

for this to work, you need to create Misterhouse device and add few generic non DCE devices as its children. Then you customize example below and put it in MH code directory (code is not pretty, but I hope understandable)....

HTH,

regards,

Rob.



pluto_parent_device.pl :

Code: [Select]
# Category=Pluto
#
#@ Connection with Pluto DCE Router via TCP port localhost:3450 (mh.ini -> pluto_DCE_router).
#
use strict;

##############################################################################
$pluto_device_event_receiver = new  Socket_Item(undef, undef, IP:PORT','device_event_receiver','tcp','record');

$pluto_device_command_sender = new  Socket_Item(undef, undef, 'IP:PORT','device_command_sender','tcp','record');

my $motion=0;

if ($Startup) {
# 6779 is ID of Misterhouse parent device

start $pluto_device_event_receiver;
        set $pluto_device_event_receiver "COMMAND 6779";
       
start $pluto_device_command_sender;
set $pluto_device_command_sender "EVENT 6779";
set $pluto_device_command_sender "PLAIN_TEXT";

}
     

if (my $msg = said $pluto_device_event_receiver) {
        print_log "Pluto Device Message received: $msg\n";
        print      "Pluto Device Message received: $msg\n";
}


if (new_second 20) {
# 6780=Detector ID, 2=event, 9=event ID (tripped), 25=tripped value, 1=value (tripped ON)
my $message = "6780 -1000 2 9 25 1";
set $pluto_device_command_sender "MESSAGET " . length ($message);
set $pluto_device_command_sender $message;
}


if (new_second 7) {
# 6780=Detector ID, 2=event, 9=event ID (tripped), 25=tripped value, 0=value (tripped OFF)
my $message = "6780 -1000 2 9 25 0";
set $pluto_device_command_sender "MESSAGET " . length ($message);
set $pluto_device_command_sender $message;
}


if (new_second 30) {
my $random_number = rand(32.0);
# 6783=temp sensor ID, 2=event, 25=event ID (temp changed), 30=value, temperature (string)
my $message = sprintf("6783 -1000 2 25 30 %d.2",$random_number);
set $pluto_device_command_sender "MESSAGET " . length ($message);
set $pluto_device_command_sender $message;

}

if (new_second 30) {
my $random_number = rand(100.0);
# 6784=brightness sensor ID, 2=event, 25=event ID (temp changed), 30=value, brightness  (string)
my $message = sprintf("6784 -1000 2 25 30 \"%d.2%\"",$random_number);
set $pluto_device_command_sender "MESSAGET " . length ($message);
set $pluto_device_command_sender $message;

}