tn

thing-node

A Kii enabled IoT library for node.js capable Things

Showing:

Popularity

Downloads/wk

2

GitHub Stars

2

Maintenance

Last Commit

3yrs ago

Contributors

0

Package

Dependencies

5

Size (min+gzip)

10.0KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

thing-node NPM version Build Status Dependency status Downloads

A Kii enabled IoT library for node.js capable Things

Installation

$ npm install --save thing-node

Usage

For detailed info see demos and test/index.js

var thingNode = require('thing-node');

const vendorThingId = 'MyThing';
const thingPassword = 'ThingPassword';
const thingType = 'ThingType';

const thingRegistrationFields = {
  _vendorThingID: vendorThingId,
  _password: thingPassword,
  _thingType: thingType,
  _vendor: 'ThingManufacturer'
};

// Initialize with Kii app info (get it at developer.kii.com)
thingNode.initialize(<APP_ID>, <APP_KEY>, <APP_SITE>);

// Register Thing in cloud
thingNode.registerOrLoadThing(thingRegistrationFields, function (error, thing) {
  if (!error) {
    thingId = thing.getThingID();
    thingAccessToken = thing.getAccessToken();
    thingNode.onboardThing(vendorThingId, thingPassword, thingType, thingAccessToken, function (error, onboardInfo) {
      if(!error) {
        var state = {
           'power': true,
           'temperature': 33
        };
        thingNode.registerThingState(thingId, state, thingAccessToken, function (error, stateRegInfo) {
          if (!error)
            console.log('Thing-IF state registration successful: ' + stateRegInfo);
          else
            console.log('Error registering Thing state: ' + error);
        });
      } else {
        console.log('Error onboarding Thing: ' + error);
      }
    });
  } else {
    console.log('Error loading or registering Thing: ' + error);
  }
});

TODO

  • Provide Promises besides a callback based API
  • Provide API documentation (JSDoc)

Development

  • Test: npm test or gulp
  • Node dev version: 4.2.1
  • Npm dev version: 3.5.2
  • Node deploy version: 0.12.17
  • Npm deploy version: 2.15.1

Logging

How to see what's happening on the cloud side (Kii log):

node ../kii-cli/bin/kii-logs.js -t --site us --app-id <KII_APP_ID> --app-key <KII_APP_KEY> --client-id <KII_CLIENT_ID> --client-secret <KII_CLIENT_SECRET>

License

MIT © German Viscuso

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100