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

smappee2mqtt

v1.0.6

Published

Connect to the Smappee API and push the data into your MQTT server

Downloads

134

Readme

Please note : this fork is just sending the last 5 min consumption and current charging session to mqtt at this stage. I did never code in Node JS so I'll see what I can do... Todo list :

  • Store token in file ✅
  • Read token from file ✅
  • Request new token if token is expired ✅
  • Implement EV line API requests ✅ (read current session only)
  • Send data to MQTT server : partial
  • Remove deprecated dependency : https://github.com/request/request/issues/3142

Smappee2MQTT (with NodeJS)

This nodejs project allows to read data from the smappee API and send it to an MQTT server. Tested with Mosquitto MQTT server and openHab to import Electric Car (EV) charging session status and house consumption.

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

Installation

npm install smappee2mqtt --save

Usage

Create a new file 'my-smappee.js'

var SmappeeAPI = require('smappee2mqtt');

var smappee = new SmappeeAPI({
    debug: false,
	noAPIcall: false,

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

    username: "xxx",
    password: "xxx",

    mqtt_server: "xxx",
    mqtt_port: "xxx",
    mqtt_baseTopic : "smappee/"
});

module.exports = smappee;

In another nodejs file : test.js

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

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

To run your test.js file type :

node test.js

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);
})

getLatestConsumption(serviceLocationId, callback)

Get a list of latest consumptions

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

smappee.getLatestConsumption(serviceLocationId, function(output) {
	console.log("getLatestConsumption (multiply WH by 12 if aggregate by 5 minutes since 5*12 = one hour to get Watts) : ",output);
})

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

Get a list of current charging session (will return -1 if no car is charging)

var smappee = require('./my-smappee');
smappee.getCurrentChargingSession(chargingStationSN, function(output){
	console.log(output);
})

TIP: To convert the 5 minute interval from Energy [Wh] to Power [W], like the Smappee Dashboard reports these, you have to do these values times 12 as there are 12 x 5 minute intervals in an hour.