         @log 'debug', "Will check all device status at #{scInterval}s interval"
         @_statusCheck = setInterval(
           _.bind(@requestAllDevicesStatus, this), scInterval * 1000)
+      reconnectInterval = @get('reconnectInterval')
+      if reconnectInterval?
+        @log 'debug', "Will reconnect at #{reconnectInterval}s interval"
+        @_statusCheck = setInterval(_.bind(@connect, this),
+          reconnectInterval * 1000)
 
   requestAllDevicesStatus: ->
     # TODO don't request status on devices that won't reply (e.g. leak sensors)

      @_resetStreamCycle()
    @_api.on 'error', (e) => @log 'warn', "An Insteon error occurred: #{JSON.stringify(e)}"
    @_api.on 'command', (cmd) => @_handleCommandReceived(cmd)

  discoverDevices: ->
    @_api.house().then (houses) => @_house = houses[0]

module.exports = class InsteonAdapter extends Adapter
  name: "Insteon Cloud"
  defaults:
    initialStatusCheck:   true  # Check status on all devices upon connection?
    statusCheckInterval:  900   # Time between automatic status refreshes
                                # in seconds. Set null to disable.
    streamCycleInterval:  600   # How long (sec) after receiving a message to
                                # close and reopen the stream to ensure it is
                                # working. Set null to disable.
    reconnectInterval:    86400 # How long (sec) between reauthorizations to
                                # avoid expiration of credentials.
    batchCommandInterval: 2000  # How long to wait between commands (ms)
    devices:              {}    # Provide options for individual devices by ID.
                                # - forwardTo: redirects all status messages
                                #   from the device to a specified device.
                                #   Useful for controllers. Also excludes the
                                #   forwarded device from bulk status checks.
                                # - classify: Specify the device class for an
                                #   IOLinc device, which determines its behavior
                                #   and the aspects it exposes.

  initialize: ->
    super
