smappee-nodejs

1.0.1 • Public • Published

Smappee-NodeJS

Smappee nodejs project to read smappee data.

Based on https://support.smappee.com/hc/en-us/articles/202153935-Where-can-I-find-the-API-documentation-

Installation

npm install smappee-nodejs --save

Usage

Create a new file 'my-smappee.js'

var SmappeeAPI = require('smappee-nodejs');

var smappee = new SmappeeAPI({
    debug: false,

    clientId: "xxx",
    clientSecret: "xxx",

    username: "xxx",
    password: "xxx"
});

module.exports = smappee;

In another nodejs file

var smappee = require('./my-smappee');

smappee.getServiceLocations(function(output) {
    console.log(output);
})

The following functions are available: getServiceLocations(callback), getServiceLocationInfo(serviceLocationId, callback), ...

API

getServiceLocations(callback)

This method will get all smappee devices configured on the account. See https://smappee.atlassian.net/wiki/display/DEVAPI/Get+Servicelocations

smappee.getServiceLocations(function(output) {
    console.log(output);
})

getServiceLocationInfo(serviceLocationId, callback)

Get the details about 1 service location (list of appliances, list of actuators, ...). See https://smappee.atlassian.net/wiki/display/DEVAPI/Get+Servicelocation+Info

smappee.getServiceLocationInfo("0000", function(output) {
    console.log(output);
})

getConsumptions(serviceLocationId,aggregation, from, to, callback)

Get a list of all consumptions for the specified period and interval. The aggregation can be selected from one of the values of smappee.AGGREGATION_TYPES. See https://smappee.atlassian.net/wiki/display/DEVAPI/Get+Consumption

var moment = require('moment');

//This will get the consumptions for the last year til now.
var from = moment().subtract(1, 'year').utc().valueOf();
var to = moment().utc().valueOf();

smappee.getConsumptions("0000", smappee.AGGREGATION_TYPES.MONTHLY, from, to, function(output) {
    console.log(output);
})

Package Sidebar

Install

npm i smappee-nodejs

Weekly Downloads

1

Version

1.0.1

License

none

Last publish

Collaborators

  • adeptive