Misterhouse
From LinuxMCE
Revision as of 10:16, 19 March 2007 by Jerry finn (Talk | contribs)
Misterhouse is a great integrated Home automation program and much more.
Here's a dirty code snippet for LinuxMCE's listener script under Misterhouse. Be careful since it intercepts all messages and that could become quite greedy...
Before using this script you have to add listener as device under LinuxMCE as explained in LinuxMCE's docs... You have to follow first few steps from LinuxMCE's text message intercepting tutorial (create logic handler device) and then add this script to your Misterhouse setup :
# Category=LinuxMCE # #@ Connection with LinuxMCE DCE Router via TCP port localhost:3450 (mh.ini -> pluto_DCE_router). # use strict; ############################################################################## $pluto_event_receiver = new Socket_Item(undef, undef, '193.77.90.224:3450','event_receiver','tcp','record'); $pluto_command_sender = new Socket_Item(undef, undef, '193.77.90.224:3450','command_sender','tcp','record'); if ($Startup) { start $pluto_event_receiver; set $pluto_event_receiver "COMMAND 6778"; start $pluto_command_sender; set $pluto_command_sender "EVENT 6778"; set $pluto_command_sender "PLAIN_TEXT"; # purge other interceptors on same device ID # set $pluto_command_sender "MESSAGET 13"; # set $pluto_command_sender "6778 -1000 13"; send_command_to_pluto("6778 -1000 13"); # intercepts all messages, I guess it's better to be selective here !!!! # set $pluto_command_sender "MESSAGET 22"; # set $pluto_command_sender "6778 -1000 8 0 0 0 0 0"; send_command_to_pluto("6778 -1000 8 0 0 0 0 0"); } sub send_command_to_pluto { my ($message) = @_; set $pluto_command_sender "MESSAGET " . length ($message); set $pluto_command_sender $message; print_log "Sending Command to Pluto DCE : $message\n"; print "Sending Command to Pluto DCE : $message\n"; } if (my $msg = said $pluto_event_receiver) { print_log "Pluto Event received: $msg\n"; print "Pluto Event received: $msg\n"; }