Skip to content

Startup Process

Tom Harris edited this page Jun 12, 2018 · 11 revisions

To startup up the insteonplm module create a call to insteonplm.Connection.create. This must be wrapped in an asyncio loop. A simple startup example would be:

import asyncio
import insteonplm


@asyncio.coroutine
def start_insteonplm(loop):
    connection = yield from insteonplm.Connection.create(
            device='/dev/some_device',
            loop=loop)


loop = asyncio.get_event_loop()
asyncio.ensure_future(start_insteonplm(loop))
loop.run_forever()

insteonplm.Connection.create returns a Connection class and accepts the following parameters:

  • auto_reconnect: Boolean value to tell the Connection class to reconnect if the connection is lost
  • device: path to the USB or serial port where the PLM device is attached. The default is '/dev/ttyUSB0'
  • host: Host name or IP address of a Hub. If this parameter is set, the module assumes the Insteon Modem is a hub even if the device parameter is set above.
  • loop: asyncio loop.
  • password: Password of the local Hub connection.
  • port: IP port number for the Hub connection. Default is 25105.
  • username: Username of the local Hub connection.
  • workdir: Working director to store the device information found during startup. If this value is set a file will be saved in this directory called insteon_plm_device_info.dat. This file will be read on subsequent startups to improve startup time.
  • poll_devices: Boolean value to tell the Insteon Modem to poll the device status.

Once the connection to the Insteon Modem is made, the IM class method connection_made is called. connection_made is a standard callback require by the asyncio.protocol interface and it receives a transport object as a parameter. The connection_made method starts the device setup process which includes the following processes:

  • add saved devices: Read the insteon_plm_device_info.dat file for saved devices from prior startups. These saved devices are loaded into the IM.devices list of linked devices.
  • device overrides: Reads the device_override values which can optionally be passed to the IM prior to startup. A device_override is used to tell the Insteon Modem the device category and subcategory in the event that the device information record is not returned by the device. It is most useful for battery operated devices that do not respond to requests. To add a device_override, see the LinkedDevices.add_device_override method. These devices are loaded into the IM.devices list of linked devices.
  • load the IM All-Link database: The IM All-Link database is scanned for all records. This is loaded into the IM.aldb list.
  • device info: Queary each device for its device info (cmd1: 0x10). If a device responds with a device info record, and the device type is in the Insteon Product Database (IPDB), it is added to the IM.devices list. This is attempted 5 times. If a device does not respond after 5 attempts, the request is canceled and the device is not added to the IM.devices list.
  • save device info: Save the device information to the insteon_plm_device_info.dat file. This requires that the workdir parameter has been set.
  • device status: This is an optional step to query each device that can return status (i.e. some devices are only controllers, such as the motion sensor, and so no status is possible).

At this point, the startup is complete.

Startup Process

IM Class

  • PLM Class

  • Hub Class

Clone this wiki locally