Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bcontrol2mqtt

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bcontrol2mqtt - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

26

index.js

@@ -17,4 +17,13 @@ #!/usr/bin/env node

const mqtt = Mqtt.connect(config.url, {will: {topic: config.name + '/connected', payload: '0', retain: true}});
mqtt.publish(config.name + '/connected', '1');
function mqttPub(topic, payload, options) {
if (typeof payload !== 'string') {
payload = JSON.stringify(payload);
}
log.debug('mqtt >', topic, payload);
mqtt.publish(topic, payload, options);
}
mqttPub(config.name + '/connected', '1');
let connected;

@@ -54,3 +63,3 @@

log.info('auth successful');
mqtt.publish(config.name + '/connected', '2', {retain: true});
mqttPub(config.name + '/connected', '2', {retain: true});
callback();

@@ -73,3 +82,3 @@ }

log.error('auth failure');
mqtt.publish(config.name + '/connected', '1', {retain: true});
mqttPub(config.name + '/connected', '1', {retain: true});
setTimeout(() => {

@@ -124,4 +133,5 @@ getAuthCookie(getMeters);

}
log.debug('<', JSON.stringify(data));
if (!data.authentication) {
mqtt.publish(config.name + '/connected', '1', {retain: true});
mqttPub(config.name + '/connected', '1', {retain: true});
log.error('auth failure');

@@ -132,9 +142,5 @@ getAuthCookie(getMeters);

const idx = ('0' + (meterId + 1)).slice(-2);
mqttPub(config.name + '/status/' + names[meterId], {val: parseFloat((data.sum_power * 1000).toFixed(1))}, {retain: true});
mqttPub(config.name + '/status/' + names[meterId] + '/energy', {val: parseFloat((data.sum_energy).toFixed(3))}, {retain: true});
const topic = config.name + '/status/' + names[meterId];
const payload = JSON.stringify({val: parseFloat((data[idx + '_power'] * 1000).toFixed(1))});
log.debug('mqtt publish', topic, payload);
mqtt.publish(topic, payload, {retain: true});
callback();

@@ -141,0 +147,0 @@ });

{
"name": "bcontrol2mqtt",
"description": "Publish Measurements from B-Control Energy Manager Smart Meters on MQTT",
"version": "1.0.0",
"version": "1.1.0",
"preferGlobal": true,

@@ -16,3 +16,3 @@ "main": "index.js",

},
"author": "Sebastian 'hobbyquaker' Raff <hq@ccu.io>",
"author": "Sebastian 'hobbyquaker' Raff <hobbyquaker@gmail.com>",
"license": "MIT",

@@ -19,0 +19,0 @@ "dependencies": {

# bcontrol2mqtt
[![mqtt-smarthome](https://img.shields.io/badge/mqtt-smarthome-blue.svg)](https://github.com/mqtt-smarthome/mqtt-smarthome)
[![NPM version](https://badge.fury.io/js/bcontrol2mqtt.svg)](http://badge.fury.io/js/bcontrol2mqtt)
[![Dependency Status](https://img.shields.io/gemnasium/hobbyquaker/bcontrol2mqtt.svg?maxAge=2592000)](https://gemnasium.com/github.com/hobbyquaker/bcontrol2mqtt)
[![Build Status](https://travis-ci.org/hobbyquaker/bcontrol2mqtt.svg?branch=master)](https://travis-ci.org/hobbyquaker/bcontrol2mqtt)
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)

@@ -21,3 +23,3 @@ [![License][mit-badge]][mit-url]

I suggest to use [pm2](http://pm2.keymetrics.io/) to manage the hm2mqtt process (start on system boot, manage log files,
I suggest to use [pm2](http://pm2.keymetrics.io/) to manage the bcontrol2mqtt process (start on system boot, manage log files,
...)

@@ -33,5 +35,5 @@

MIT (c) 2015-2017 [Sebastian Raff](https://github.com/hobbyquaker)
MIT (c) 2015-2018 [Sebastian Raff](https://github.com/hobbyquaker)
[mit-badge]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat
[mit-url]: LICENSE
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc