Skip to content

Insteon Programming

galiven edited this page Nov 7, 2014 · 2 revisions
  • NOTES
  • This page has not been editted in quite some time and contains some significantly out of date information. If you are new to Misterhouse and Insteon please stick to the rather detailed Insteon page for the time being. It has been significantly revised to make it more accurate

Programming Tips

This section is very incomplete, it is recommended that you look at the examples that ship with misterhouse, and now would be a good time to read the main mh documentation and you'll also find good tips and help in the FAQ page. If you aren't too familiar with perl, you can read about the perl syntax tricks used in mh (they may come handy, even if you are familiar with perl).

To answer the likely most common question for the X10 user, or someone trying to do something outside mh, this is how you toggle a switch from the command line: gargamel:/var/local/src/misterhouse/mh/bin# ./mhsend --run 'fmr mast off' (remove underscores).

If you wonder what voice commands are available, try this on the web interface: Browse MrHome -> List voice commands.

More generally, there are 3 major ways to get mh to do things for you:

  1. add code that is run as part of the main event loop
  2. write a web module/button that only runs code when triggered
  3. write a so called voice command, which is basically a command you can trigger from the command line among other ways (the command above would be run as mhsend --run 'AllDevices Scan).
Code that you put in ~mh/code/foo.pl is part of the big run loop. When you write $kitch_appl_x10->state_now eq ON, the reason things work is that said function only returns ON one time around the loop, which is why you don't get bounces or multiple runs for one button press. This is also why you can check $kitch_appl_x10->state_now multiple times across different code files since it only gets reset at the end of the loop (use use ->state instead of ->state_now to check for status as opposed to toggle).

As a quick sample, for your code directory, you can create ~mh/code/insteon.pl:

     # Category=Insteon
     #@ Jason Sharpee's Insteon PLM interface user code

     # Example use, turn the patio lamp at 10 minutes before sun set
     if(time_now("$Time_Sunset-0:10")) {
         $office_lamp->set('50%');
     }

     # Example use, turn the patio lamp off at midnight
     if(time_now "12:00 AM") {
         $x10_kitchen_light->set(OFF);
     }
Clone this wiki locally