smartmeter2mqtt
Version:
Publish data from your Smartmeter with a P1 interface to your MQTT server.
54 lines • 2.42 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var output_1 = __importDefault(require("./output"));
var p1_reader_events_1 = __importDefault(require("../p1-reader-events"));
/**
* DebugOutput is a sample output.
* You'll have to at least implement the 'start(p1Reader)' method.
* It will receive the P1Reader and in the start method,
* you can start listening to events from the reader.
* You should also implement the 'stop()' method to stop any started server.
*/
var DebugOutput = /** @class */ (function (_super) {
__extends(DebugOutput, _super);
function DebugOutput() {
return _super !== null && _super.apply(this, arguments) || this;
}
DebugOutput.prototype.start = function (p1Reader) {
p1Reader.on(p1_reader_events_1.default.ParsedResult, function (result) {
console.log(' - new reading %s', JSON.stringify(result, null, 2));
});
p1Reader.on(p1_reader_events_1.default.UsageChanged, function (result) {
console.log(' - usageChange %s', result.message);
});
p1Reader.on(p1_reader_events_1.default.GasUsageChanged, function (result) {
console.log(' - gasUsageChange %s', result.message);
});
p1Reader.on(p1_reader_events_1.default.ErrorMessage, function (message) {
console.log(' - errorMessage %s', message);
});
};
DebugOutput.prototype.close = function () {
// You should stop the started servers here, when building your own output.
return Promise.resolve();
};
return DebugOutput;
}(output_1.default));
exports.default = DebugOutput;
//# sourceMappingURL=debug-output.js.map