---Example Code and Usage---


This is the base interface class for Insteon Power Line Modem (PLM)


Serial_Item, Insteon::BaseInterface



Creates a new serial port connection.


Attempt to restart/reconnect the serial port connection.


Instantiates a new object.


Sets or gets the number of corrupt message that have arrived that could not be associated with any device since the last time reset_message_stats was called. These are generally instances in which the from device ID is corrupt.

If type is set, to any value, will increment corrupt count by one.

Returns: current corrupt count.


Resets the retry, fail, outgoing, incoming, and corrupt message counters.


This is called by mh on exit to save the cached ALDB of a device to persistant data.


Called once per loop. This checks for any data waiting on the serial port, if data exists it is sent to _parse_data. If there is no data waiting, then this checks to see if the timers for any previous commands have expired, if they have, it calls retry_active_message(). Else, this checks to see if there is any timeout preventing a transmission right now, if there is no timeout it calles process_queue().


Used to send X10 messages, generates an X10 command and queues it.


Puts the PLM into linking mode as a responder.

Causes MisterHouse to dump its cache of the PLM link table to the log.

Causes MisterHouse to scan the link table of the PLM only.


Puts the PLM into linking mode as a controller, if p_group is specified the controller will be added for this group, otherwise it will be for group 00.


Puts the PLM into unlinking mode, if p_group is specified the PLM will try to unlink any devices linked to that group that identify themselves with a set button press.


Cancels any pending linking session that has not completed.


Returns the PLM's aldb object.


Causes a message to be sent to the serial port.


This routine parses data comming in from the serial port. In many cases multiple messages or fragments of messages may arrive at once. This routine attempts to parse this string of data into individual messages, unfortunately the PLM does not have a unique message delimiter. Instead, all PLM messages start with 02XX where XX is a two digit code corresponding to the message type.

The one caveat, is that the PLM may send simple 15 to indicate that it is busy.

This routine uses a First-In-First-Out (FIFO) style for processing the data stream by following this procedure:

        1. Prepend any prior data fragment left over from the last run
        2. Trim off any PLM busy messages
        3. Locate the first valid PLM prefix in the message
        4. Look for PLM ACK, NACK and BadCmd Responses
        5. Look for known Insteon message types
        6. Dispose of stale data that doesn't match known message types
        7. Save whatever data fragments remain for the next pass

Based on the type of message, it is then passed off to higher level message handling routines.


Looks for the first instance of a valid PLM prefix is a string of data and returns that prefix and all subsequent data.


Dummy sub required to support the X10 integrtion, does nothing.


Stores and returns the firmware version of the PLM.

Returns the data3 value that should be used when creating a link for this device. This sub was modivated by the need to return unique values for data3 on responder links for group 01. The PLM will store the responder's devcat data for controller entries. That's fundamentally hard so just do the same as for other devices for now. Can make this smarter in the future if needed.



Identifies the port on which the PLM is attached. Example:


Setting this to 1, will enable MisterHouse to use a networked PLM such as the Insteon Hub. This functionality seems fairly stable, but has not been extensively tested.

You will also need to set values for Insteon_PLM_TCP_host and Insteon_PLM_TCP_port.

There are a few quirks when using a networked PLM, they include:

The communication may be slightly slower with the network PLM. In order to prevent MisterHouse from clobbering the device it is recommended that you set the Insteon_PLM_xmit_delay to 1 second. Testing may reveal that slightly lower delays are also acceptable.

Changes made using the hub's web interface will not be understood by MisterHouse. Device states may become out of sync. (It is possible that future coding may be able to overcome this limiation)


If using a network PLM, set this to the IP address of the PLM. See Insteon_PLM_use_TCP.


If using a network PLM, set this to the port address of the PLM. Generally, the port number is 9761. See Insteon_PLM_use_TCP.


Sets the minimum amount of seconds that must elapse between sending Insteon messages to the PLM. Defaults to 0.25.


Sets the minimum amount of seconds that must elapse between sending X10 messages to the PLM. Defaults to 0.50.


Periodically, the PLM will report that it is too busy to accept a message from MisterHouse. When this happens, MisterHouse will wait 1 second before trying to send a message to the PLM. If this is set to 1, downgrades the delay to only .3 seconds. Most of the issues which caused the PLM to overload have been handled it is unlikely that you would need to set this.


The PLM acknowledges the receipt of a command from MisterHouse with an ACK message. It is very rare for a well functioning PLM to fail to send the ACK message. In many cases, the failure to receive an ACK message from the PLM is a sign that the connection between MisterHouse and the PLM (Serial or USB) has died.

This setting defines the number of missed ACK messages that must occur for MisterHouse to deem the PLM connection lost. The number of missed ACK messages must all occur while sending a single Insteon command. So if you want this to do anything, this number needs to be less than or equal to the Insteon_retry_count. Once the number of missed ACK messages occurs, MisterHouse will attempt to reconnect the PLM. For some people, the reconnect routine causes errors, so you may want to test this out by manually pulling the connection cable to the PLM to see how your system will react.

By default, this is set to 99, essentially disabling an automatic restart.

Note the ACK messages discussed here refer to PLM ACK messages not the ACK messages received from an Insteon device in response to a command.


Special Thanks to:

Brian Warren for significant testing and patches

Bruce Winter - MH


Jason Sharpee /, Gregg Liming /, Kevin Robert Keegan, Michael Stovenour


For more information regarding the technical details of the PLM: Insteon PLM Dev Guide


This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.