1.0.12 • Published 6 years ago

alexa-iot-helper v1.0.12

Weekly downloads
11
License
ISC
Repository
-
Last release
6 years ago

alexa-iot-helper

Work with aws-iot-client. The alexa-iot-helper is used to simply update device state on thing shadow.
Currently, support monitor on\off, media player control, system shutdown

Installation

npm install alexa-iot-helper

API

var alexaIotHelper = require('alexa-iot-helper');

ctrMonitor(iotdata)

Create a new ctrMonitor object by the given iotdata. For example, assume we want to create an iot-helper object to control our monitor, we can use the following code

var alexaIotHelper = require('alexa-iot-helper').ctrMonitor;
var monitor = new alexaIotHelper(iotdata);

ctrMediaPlayer(iotdata)

Create a new ctrMediaPlayer object by the given iotdata. For example, assume we want to create an iot-helper object to control our music player, we can use the following code

var alexaIotHelper = require('alexa-iot-helper').ctrMediaPlayer;
var player = new alexaIotHelper(iotdata);

.ctrMonitor.turnOff(clientId, callback)

Update thingshadow by clientId for monitor off and process callback function.

.ctrMonitor.turnOn(clientId, callback) {

Update thingshadow by clientId for monitor on and process callback function.

.ctrMediaPlayer.play(clientId, callback) {

Update thingshadow by clientId for passing play message to the media player and process callback function.

.ctrMediaPlayer.pause(clientId, callback) {

Update thingshadow by clientId for passing pause message to the media player and process callback function.

.ctrMediaPlayer.next(clientId, callback) {

Update thingshadow by clientId for passing next message to the media player and process callback function.

.ctrMediaPlayer.pre(clientId, callback) {

Update thingshadow by clientId for passing pre message to the media player and process callback function.

ctrSystem(iotdata)

.ctrSystem.shutdown(clientId, callback)

Update thingshadow by clientId for system shutdown and process callback function.

.ctrSystem.shutdownAsync(clientId, callback)

Update thingshadow by clientId for system shutdown asynchronizely

Examples

This simple example shows how to use alexa-iot-helper to change device status on the cloud. First, we create the object of the iotdata via aws-sdk with particular endpoint loaded from iotConfig.json

//iotConfig.json
{
    "endpoint": "ef3423d1pm93tna.iot.us-east-1.amazonaws.com"
}

After that, inject iotdata into alexaIotHelper.

Here is the sample code.

/*  Initialize   */
//require aws sdk
var AWS = require("aws-sdk");
AWS.config.update({ region: 'us-east-1' });

//create iotdata object
const endpoint = require('./iotConfig');
var iotdata= new AWS.IotData(endpoint);

//require alexa-iot-helper 
// and create an object for monitor control
var alexaIotHelper = require('alexa-iot-helper').ctrMonitor;
var monitor = new alexaIotHelper(iotdata);


//monitor control, update device status on cloud
monitor.turnOn("clientId", function () {
  //Do something
}); 

Release Note:

v1.0.12

Support Shutdown system asynchronizely

1.0.12

6 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago