Skip to content

Commit

Permalink
v0.3.3 add debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
DutchmanNL committed Oct 30, 2023
1 parent 944fd88 commit 0a83b8b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"common": {
"name": "vedirect",
"version": "0.3.1",
"version": "0.3.3",
"news": {
"0.3.2": {
"en": "Message buffer implemented to avoid system overload",
Expand Down
11 changes: 8 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,21 @@ class Vedirect extends utils.Adapter {
const parser = port.pipe(new ReadlineParser({delimiter: '\r\n'}));

parser.on('data', (data) => {

this.log.debug(`[Serial data received] ${data}`)
if (!bufferMessage) {
this.log.debug(`Message buffer inactive, processing data`);
this.parse_serial(data);
if (this.config.messageBuffer > 0) {
this.log.debug(`Activate Message buffer with delay of ${this.config.messageBuffer * 1000}`);
bufferMessage = true;
if (timeouts['mesageBuffer']) {clearTimeout(timeouts['mesageBuffer']); timeouts['mesageBuffer'] = null;}
timeouts['mesageBuffer'] = setTimeout(()=> {
bufferMessage = false;
this.log.debug(`Message buffer timeout reached, will process data`);
}, this.config.messageBuffer * 1000);
}
} else {
this.log.debug(`Message buffer active, message ignored`);
}

// Indicate connection status
Expand Down Expand Up @@ -253,7 +258,7 @@ class Vedirect extends utils.Adapter {
case 'MON':
this.stateSetCreate(res[0], res[0], await this.get_monitor_type(res[1]));
break;

case 'DC_IN_V':
this.stateSetCreate(res[0], res[0], Math.floor(res[1]) / 100);
break;
Expand All @@ -265,7 +270,7 @@ class Vedirect extends utils.Adapter {
case 'DC_IN_P':
this.stateSetCreate(res[0], res[0], Math.floor(res[1]));
break;

default: // Used for all other measure points with no required special handling
this.stateSetCreate(res[0], res[0], res[1]);
break;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.vedirect",
"version": "0.3.2",
"version": "0.3.3",
"description": "Read VE.direct data from Victron devices",
"author": {
"name": "DutchmanNL",
Expand Down

0 comments on commit 0a83b8b

Please sign in to comment.