Skip to content

Commit

Permalink
Merge pull request #38 from kickouille/external_trigger
Browse files Browse the repository at this point in the history
External trigger
  • Loading branch information
coolchip authored Apr 13, 2022
2 parents ec8ff1c + a307ad9 commit 67ef8b6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion smartmeter.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
required: false
}
},
inputs: 0,
inputs: 1,
outputs: 1,
icon: "gauge.png",
label: function () {
Expand Down
19 changes: 18 additions & 1 deletion smartmeter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,28 @@ module.exports = function (RED) {
}

var smTransport = smartmeterObis.init(options, sendData);
smTransport.process();
var firstRun = true;

if (config.requestInterval >= 0 ) {
smTransport.process();
firstRun = false;
}

node.on('close', function () {
smTransport.stop();
});

node.on('input', function() {
if (!firstRun && !smTransport.protocol.isProcessComplete()) {
node.warn("Previous process hasn't finished yet");
return;
}
smTransport.process();
if (config.requestInterval < 0 ) {
smTransport = smartmeterObis.init(options, sendData);
firstRun = true;
}
});
}
}
RED.nodes.registerType('smartmeter', SmartmeterNode);
Expand Down

0 comments on commit 67ef8b6

Please sign in to comment.