BaseInterface.pm


Insteon::BaseInterface

SYNOPSIS

Provides support for the Insteon Interface.

INHERITS

Class::Singleton

METHODS

check_for_data

Locates the active_interface from the main Insteon class and calls check_for_data on it. Called once per loop to get data from the PLM.

poll_all

Called on startup or reload. Will always request and print the plm_info, which contains the PLM revision number, to the log on startup.

If Insteon_PLM_scan_at_startup is set to 1 in the ini file, this routine will poll all insteon devices and request their current state. Useful for making sure that no devices changed their state while MisterHouse was off. Will also call Insteon::BaseObject::get_engine_version on each device to ensure that the proper ALDB object is created for them.

new()

Instantiate a new object.

equals([object])

Returns 1 if object is the same as $self, otherwise returns 0.

debuglevel([level])

Returns 1 if Insteon or this device is at least debug level 'level', otherwise returns 0.

_is_duplicate(cmd)

Returns true if cmd already exists in the command stack.

has_link(link_details)

If a device has an ALDB, passes link_details onto one of the has_link() routines within Insteon::AllLinkDatabase. Generally called as part of delete_orphan_links().

add_link(link_params)

If a device has an ALDB, passes link_details onto one of the add_link() routines within Insteon::AllLinkDatabase. Generally called from the "sync links" or "link to interface" voice commands.

delete_link([link details])

If a device has an ALDB, passes link_details onto one of the delete_link() routines within Insteon::AllLinkDatabase. Generally called by delete_orphan_links().

active_message([msg])

Optionally stores, and returns the message currently being processed by the interface.

clear_active_message()

Clears the message currently being processed by the interface, and sets the transmit in progress flag to false.

retry_active_message()

Sets the transmit in progress flag to false.

transmit_in_progress([xmit_flag])

Sets the transmit in progress flag to xmit_flag, returns true if xmit_flag true or xmit timout has not elapsed.

queue_message([msg])

If no msg is passed, returns the queue length.

Msg is optionally a message, if sent is added to the message queue. process_queue() is then called.

process_queue()

If transmit_in_progress() is true returns queue size.

If there is a pending message, will leave it as active_message. If retries are exceeded, will log an error, clear the message, and call the message failure_callback.

Else, will pull a message from the queue and place it as the active_message.

device_id([id])

Used to store and return the associated device_id of a device.

If provided, stores id as the device's id.

Returns device id without any delimiters.

restore_string()

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

restore_linktable()

Used to reload the link table of a device on restart.

log_alllink_table()

Prints a human readable form of MisterHouse's cached version of a device's ALDB to the print log. Called as part of the "scan links" voice command or in response to the "log links" voice command.

delete_orphan_links(audit_mode)

Reviews the cached version of all of the ALDBs and based on this review removes links from this device which are not present in the mht file, not defined in the code, or links which are only half-links.

If audit_mode is true, prints the actions that would be taken to the log, but does nothing.

on_interface_info_received

Called to process the plm_info request sent by the poll_all() command. Prints output to log.

on_standard_insteon_received

Called to process standard length insteon messages. The routine is rather complex some messsages are processed right here. The majority are passed off to the _is_info_request() and _process_message() routines for each device.

on_standard_insteon_received

Called to process extended length insteon messages. The majority of messages are passed off to the _process_message() routines for each device.

_set_timeout(timeout_name, timeout_millis)

Sets an internal variable, timeout_name, the current time plus the number of milliseconds specified by timeout_millis.

_check_timeout(timeout_name)

Checks to see if the current number of milliseconds has exceeded the number of milliseconds defined in timeout_name, which was set by _set_timeout().

return -1 if timeout_name does not match an existing timer return 0 if timer has not expired return 1 if timer has expired

_check_timeout(timeout_name)

Erases timeout_name, which was set by _set_timeout().

_aldb()

Returns the ALDB object associated with the device.

_is_duplicate_received()

This function attempts to identify erroneous duplicative incoming messages while still permitting identical messages to arrive in close proximity. For example, a valid identical message is the ACK of an extended aldb read which is always 2F00.

Messages are deemed to be identical if, excluding the max_hops and hops_left bits, they are otherwise the same. Identical messages are deemed to be erroneous if they are received within a calculated message window, $delay.

The message window is calculated based on the amount of time that should have elapsed before a subsequent identical message could have been received..

Returns 1 if the received message is an erroneous duplicate message

See discussion at: https://github.com/hollie/misterhouse/issues/169

get_voice_cmds

Returns a hash of voice commands where the key is the voice command name and the value is the perl code to run when the voice command name is called.

Higher classes which inherit this object may add to this list of voice commands by redefining this routine while inheriting this routine using the SUPER function.

This routine is called by the Insteon::generate_voice_commands manpage to generate the necessary voice commands.

is_deaf()

Returns false.

is_controller()

Returns true.

is_responder()

Returns true.

INI PARAMETERS

Insteon_PLM_scan_at_startup

By default, MisterHouse will scan all devices at startup. This scan involves asking each device for its current state and asking each device for its engine version. In a larger network this can take a few seconds to complete and it does send a lot of messages all at once, but polling at startup is a good way to make sure that MisterHouse has an accurate understanding of the network.

If set to false, will disable the scan at startup.

AUTHOR

Gregg Liming / gregg@limings.net, Kevin Robert Keegan, Michael Stovenour

LICENSE

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.

 BaseInterface.pm