Skip to content

Commit

Permalink
### 0.5.5: Maintenance Release
Browse files Browse the repository at this point in the history
**Fixes**

- Grid first and Battery first setting on MIX may not work
  • Loading branch information
PLCHome committed Jul 3, 2023
1 parent 5938d91 commit e7f5f2e
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 74 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
### 0.5.5: Maintenance Release

**Fixes**

- Grid first and Battery first setting on MIX may not work

### 0.5.4: Maintenance Release

**Fixes**

- time setting on TLX may not work #14
- time setting on TLX may not work #14

### 0.5.3: Maintenance Release

Expand Down
52 changes: 32 additions & 20 deletions lib/growatttype.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,41 +52,53 @@ module.exports = {
},
gridFirst: {
name: 'Grid first',
type: 'setGridFirst',
type: 'mix_ac_discharge_time_period',
paramId: 'MIX_AC_DISCHARGE_TIME_MULTI',
parseRet: PARSERET.parseGritFirst,
param: {
param1: { name: 'Discharge power rate', type: 'INUM_0_100', unit: '%' },
param2: { name: 'Discharge stopped soc', type: 'INUM_0_100', unit: '%' },
param3: { name: 'Time slot 1 start', type: 'STIME_H_MIN' },
param4: { name: 'Time slot 1 end', type: 'STIME_H_MIN' },
param5: { name: 'Time slot 1 on', type: 'BOOL' },
param6: { name: 'Time slot 2 start', type: 'STIME_H_MIN' },
param7: { name: 'Time slot 2 end', type: 'STIME_H_MIN' },
param8: { name: 'Time slot 2 on', type: 'BOOL' },
param9: { name: 'Time slot 3 start', type: 'STIME_H_MIN' },
param10: { name: 'Time slot 3 end', type: 'STIME_H_MIN' },
param11: { name: 'Time Slot 3 on', type: 'BOOL' },
param3: { name: 'Time slot 1 start HH', type: 'INUM_0_24' },
param4: { name: 'Time slot 1 start MI', type: 'INUM_0_60' },
param5: { name: 'Time slot 1 end HH', type: 'INUM_0_24' },
param6: { name: 'Time slot 1 end MI', type: 'INUM_0_60' },
param7: { name: 'Time slot 1 on', type: 'BOOL' },
param8: { name: 'Time slot 2 start HH', type: 'INUM_0_24' },
param9: { name: 'Time slot 2 start MI', type: 'INUM_0_60' },
param10: { name: 'Time slot 2 end HH', type: 'INUM_0_24' },
param11: { name: 'Time slot 2 end MI', type: 'INUM_0_60' },
param12: { name: 'Time slot 2 on', type: 'BOOL' },
param13: { name: 'Time slot 3 start HH', type: 'INUM_0_24' },
param14: { name: 'Time slot 3 start MI', type: 'INUM_0_60' },
param15: { name: 'Time slot 3 end HH', type: 'INUM_0_24' },
param16: { name: 'Time slot 3 end MI', type: 'INUM_0_60' },
param17: { name: 'Time Slot 3 on', type: 'BOOL' },
},
},
batteryFirst: {
name: 'Battery first',
type: 'setBatteryFirst',
type: 'mix_ac_charge_time_period',
paramId: 'mix_ac_charge_time_multi',
parseRet: PARSERET.parseBatteryFirst,
param: {
param1: { name: 'Charge power rate', type: 'INUM_0_100', unit: '%' },
param2: { name: 'Charge stopped soc', type: 'INUM_0_100', unit: '%' },
param3: { name: 'AC Charge on', type: 'BOOL' },
param4: { name: 'Time Slot 1 start', type: 'STIME_H_MIN' },
param5: { name: 'Time Slot 1 end', type: 'STIME_H_MIN' },
param6: { name: 'Time Slot 1 on', type: 'BOOL' },
param7: { name: 'Time Slot 2 start', type: 'STIME_H_MIN' },
param8: { name: 'Time Slot 2 end', type: 'STIME_H_MIN' },
param9: { name: 'Time Slot 2 on', type: 'BOOL' },
param10: { name: 'Time Slot 3 start', type: 'STIME_H_MIN' },
param11: { name: 'Time Slot 3 end', type: 'STIME_H_MIN' },
param12: { name: 'Time Slot 3 on', type: 'BOOL' },
param4: { name: 'Time slot 1 start HH', type: 'INUM_0_24' },
param5: { name: 'Time slot 1 start MI', type: 'INUM_0_60' },
param6: { name: 'Time slot 1 end HH', type: 'INUM_0_24' },
param7: { name: 'Time slot 1 end MI', type: 'INUM_0_60' },
param8: { name: 'Time slot 1 on', type: 'BOOL' },
param9: { name: 'Time slot 2 start HH', type: 'INUM_0_24' },
param10: { name: 'Time slot 2 start MI', type: 'INUM_0_60' },
param11: { name: 'Time slot 2 end HH', type: 'INUM_0_24' },
param12: { name: 'Time slot 2 end MI', type: 'INUM_0_60' },
param13: { name: 'Time slot 2 on', type: 'BOOL' },
param14: { name: 'Time slot 3 start HH', type: 'INUM_0_24' },
param15: { name: 'Time slot 3 start MI', type: 'INUM_0_60' },
param16: { name: 'Time slot 3 end HH', type: 'INUM_0_24' },
param17: { name: 'Time slot 3 end MI', type: 'INUM_0_60' },
param18: { name: 'Time Slot 3 on', type: 'BOOL' },
},
},
loadFirst: {
Expand Down
10 changes: 10 additions & 0 deletions lib/parsein.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ module.exports = class {
return [val, Number.isInteger(val) && val >= 0 && val <= 100];
}

static INUM_0_24(val) {
debugApi('INUM_0_24:', val);
return [val, Number.isInteger(val) && val >= 0 && val <= 24];
}

static INUM_0_60(val) {
debugApi('INUM_0_60:', val);
return [val, Number.isInteger(val) && val >= 0 && val <= 60];
}

static INUM_0_1(val) {
debugApi('INUM_0_1:', val);
return [val, Number.isInteger(val) && val >= 0 && val <= 1];
Expand Down
65 changes: 46 additions & 19 deletions lib/parseret.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ function fBool(val, ok) {

function fNum(val, min, max, ok) {
debugApi('fNum:', 'val', val, 'min', min, 'max', max, 'ok', ok);
return [val, ok && val >= min && val <= max];
const r = parseInt(val, 10);
return [r, ok && r >= min && r <= max];
}

function fDate(val, ok) {
Expand Down Expand Up @@ -73,18 +74,31 @@ module.exports = class {
.split('-')
.map(n => parseInt(n, 10));
if (ar.length > 18) {
let time = '';
[val.param1, val.success] = fNum(ar[0], 0, 100, val.success);
[val.param2, val.success] = fNum(ar[1], 0, 100, val.success);
[val.param3, val.success] = fBool(ar[2], val.success);
[val.param4, val.success] = fTime(ar[10], val.success);
[val.param5, val.success] = fTime(ar[11], val.success);
[val.param6, val.success] = fBool(ar[12], val.success);
[val.param7, val.success] = fTime(ar[13], val.success);
[val.param8, val.success] = fTime(ar[14], val.success);
[val.param9, val.success] = fBool(ar[15], val.success);
[val.param10, val.success] = fTime(ar[16], val.success);
[val.param11, val.success] = fTime(ar[17], val.success);
[val.param12, val.success] = fBool(ar[18], val.success);
[time, val.success] = fTime(ar[10], val.success);
[val.param4, val.success] = fNum(time.substring(0, 2), 0, 24, val.success);
[val.param5, val.success] = fNum(time.substring(3, 6), 0, 60, val.success);
[time, val.success] = fTime(ar[11], val.success);
[val.param6, val.success] = fNum(time.substring(0, 2), 0, 24, val.success);
[val.param7, val.success] = fNum(time.substring(3, 6), 0, 60, val.success);
[val.param8, val.success] = fBool(ar[12], val.success);
[time, val.success] = fTime(ar[13], val.success);
[val.param9, val.success] = fNum(time.substring(0, 2), 0, 24, val.success);
[val.param10, val.success] = fNum(time.substring(3, 6), 0, 60, val.success);
[time, val.success] = fTime(ar[14], val.success);
[val.param11, val.success] = fNum(time.substring(0, 2), 0, 24, val.success);
[val.param12, val.success] = fNum(time.substring(3, 6), 0, 60, val.success);
[val.param13, val.success] = fBool(ar[15], val.success);
[time, val.success] = fTime(ar[16], val.success);
[val.param14, val.success] = fNum(time.substring(0, 2), 0, 24, val.success);
[val.param15, val.success] = fNum(time.substring(3, 6), 0, 60, val.success);
[time, val.success] = fTime(ar[17], val.success);
[val.param16, val.success] = fNum(time.substring(0, 2), 0, 24, val.success);
[val.param17, val.success] = fNum(time.substring(3, 6), 0, 60, val.success);
[val.param18, val.success] = fBool(ar[18], val.success);
} else {
val.success = false;
}
Expand All @@ -103,17 +117,30 @@ module.exports = class {
.split('-')
.map(n => parseInt(n, 10));
if (ar.length > 18) {
let time = '';
[val.param1, val.success] = fNum(ar[0], 0, 100, val.success);
[val.param2, val.success] = fNum(ar[1], 0, 100, val.success);
[val.param3, val.success] = fTime(ar[10], val.success);
[val.param4, val.success] = fTime(ar[11], val.success);
[val.param5, val.success] = fBool(ar[12], val.success);
[val.param6, val.success] = fTime(ar[13], val.success);
[val.param7, val.success] = fTime(ar[14], val.success);
[val.param8, val.success] = fBool(ar[15], val.success);
[val.param9, val.success] = fTime(ar[16], val.success);
[val.param10, val.success] = fTime(ar[17], val.success);
[val.param11, val.success] = fBool(ar[18], val.success);
[time, val.success] = fTime(ar[10], val.success);
[val.param3, val.success] = fNum(time.substring(0, 2), 0, 24, val.success);
[val.param4, val.success] = fNum(time.substring(3, 6), 0, 60, val.success);
[time, val.success] = fTime(ar[11], val.success);
[val.param5, val.success] = fNum(time.substring(0, 2), 0, 24, val.success);
[val.param6, val.success] = fNum(time.substring(3, 6), 0, 60, val.success);
[val.param7, val.success] = fBool(ar[12], val.success);
[time, val.success] = fTime(ar[13], val.success);
[val.param8, val.success] = fNum(time.substring(0, 2), 0, 24, val.success);
[val.param9, val.success] = fNum(time.substring(3, 6), 0, 60, val.success);
[time, val.success] = fTime(ar[14], val.success);
[val.param10, val.success] = fNum(time.substring(0, 2), 0, 24, val.success);
[val.param11, val.success] = fNum(time.substring(3, 6), 0, 60, val.success);
[val.param12, val.success] = fBool(ar[15], val.success);
[time, val.success] = fTime(ar[16], val.success);
[val.param13, val.success] = fNum(time.substring(0, 2), 0, 24, val.success);
[val.param14, val.success] = fNum(time.substring(3, 6), 0, 60, val.success);
[time, val.success] = fTime(ar[17], val.success);
[val.param15, val.success] = fNum(time.substring(0, 2), 0, 24, val.success);
[val.param16, val.success] = fNum(time.substring(3, 6), 0, 60, val.success);
[val.param17, val.success] = fBool(ar[18], val.success);
} else {
val.success = false;
}
Expand Down
66 changes: 33 additions & 33 deletions 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
Expand Up @@ -12,7 +12,7 @@
},
"devDependencies": {
"chai": "^4.3.7",
"eslint": "^8.43.0",
"eslint": "^8.44.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
Expand Down

0 comments on commit e7f5f2e

Please sign in to comment.