npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

insteon-api

v1.0.0

Published

a node package for the Insteon REST API

Downloads

14

Readme

insteon-api Build Status

a node package for the Insteon REST API


Overview

insteon-api is a node package for the Insteon REST API. The goal of this package is to mirror our existing home-controller package. This will reduce the effort of moving your existing code to the new Hub.

Only the new Insteon Hub (2245) is supported.

Table of Contents

Features

  • Device and Gateway Info
  • Linking and Group Control
  • Scene Control
  • Lighting Control
  • Thermostat Control
  • Sensor Control

Getting Started

Install

Install via npm:

npm install insteon-api

Example

Here is a simple example to turn on your light.

var InsteonAPI = require('insteon-api');

var api = new InsteonAPI({key: process.env.INSTEON_API_KEY});

api.on('connect', function() {
  api.light(12345).turnOn()
  .then(function(rsp) {
    console.log('Turned On: ', rsp);
  });
});

api.on('error', function(err) {
  console.log('Error: ', err);
});

api.connect({
 username: process.env.INSTEON_USERNAME,
 password: process.env.INSTEON_PASSWORD
});

API

InsteonAPI

require('insteon-api')(options)

Add require statement to the app to access the InsteonAPI class. You provide your API key to create an api object for your developer account.

Options

  • key the Insteon API key (required)
  • secret the Insteon API secret (required for auth code only)

Example

var InsteonAPI = require('insteon-api');

var api = new InsteonAPI({
  key: process.env.INSTEON_API_KEY,
  secret: process.env.INSTEON_API_SECRET // Optional
});

The InsteonAPI class inherits EventEmitter

api.connect(options) or api.auth(options)

Connects the api object to a user account. There are three ways to authenticate: user credentials, an authorization code, or refresh token. The authorization code and refreshing an authorization code token requires the secret option be set on the api object.

User Credential Options

  • username the Insteon App user name
  • password the Insteon App password

Authorization Code Options

  • code the authorization code received from Insteon.

Refresh Option

  • refreshToken the refresh token for a Insteon App user.

When the 'connect' event is emitted the connection is established. If there is a problem connecting, the 'connect' event will not be emitted, the 'error' event will be emitted with the exception.

Event: 'connect'

Emitted when user authentication is complete.

Event: 'command'

Emitted when an command is received. The argument command will be the command object.

Callback arguments

  • command received from gateway

Event: 'error'

Emitted when an error occurs.

Callback arguments

  • error the error that occurred

api.accessToken

The access token received from the auth request

api.refreshToken

The refresh token received from the auth request

House

api.house(id, [callback])

api.house(properties, [callback])

house.save([callback])

house.del([callback])

Device

api.device(id, [callback])

api.device(properties, [callback])

device.save([callback])

device.del([callback])

Room

TODO

Scene

TODO

Camera

TODO

Alert

TODO

Light

api.light(id)

Get the light object for the device id

The id is the Insteon API device ID. It is not the Insteon Hex ID.

light.turnOn(level, [callback])

Turn the device on at ramp rate to level

light.turnOn([callback])

Turn the device on at ramp rate to on level

light.turnOnFast([callback])

Turn the device on instantly

light.turnOff([callback])

Turn the device off at ramp rate

light.turnOffFast([callback])

Turn the device off instantly

light.brighten([callback])

Brighten the device by one step (approximately 4%)

light.dim([callback])

Dims the device by on step (approximately 4%)

light.level([callback])

Returns the current device level.

The level returned is a percentage from 0 to 100.

light.level(level, [callback])

Set the device level instantly

Valid level values are 0 to 100.

light.info([callback])

Returns an info object for the device.

Info Object

{
  onLevel: 100,  // percentage 1-100
  rampRate: 500, // milliseconds
  ledBrightness: 32
}

light.rampRate([callback])

Returns the configured ramp rate for the device

The returned rate is in milliseconds.

light.rampRate(rate, [callback])

Set the ramp rate for the device

The rate is in milliseconds and will be rounded to the nearest supported value.

light.onLevel([callback])

Return the configured on level for the device

The level returned is a percentage from 1 to 100.

light.onLevel(level, [callback])

Set the on level for the device

Valid level values are 1 to 100.

Light Events

Event: trunOn

Event emitted when the device is turned on

Event: trunOff

Event emitted when the device is turned off

Testing

To test the package run:

grunt test

References