Skip to content

Commit

Permalink
Job FIX
Browse files Browse the repository at this point in the history
  • Loading branch information
PLCHome committed Jul 3, 2024
1 parent cc0e3a6 commit ccc1843
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 149 deletions.
9 changes: 9 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
docs
test
lib/env/tools.js
gulpfile.js
test.json
test.js
test2.js
test_plants.json
testSharePlant.json
19 changes: 3 additions & 16 deletions eslint.config.js → .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@

module.exports = {
files: ["**/*.js"],
/*env: {
env: {
browser: true,
es2017: true,
node: true,
mocha: true,
},
},
extends: ['eslint:recommended', 'airbnb-base', 'plugin:prettier/recommended'],
parserOptions: {
ecmaVersion: 2018,
ecmaFeatures: {
impliedStrict: true,
},
sourceType: 'module',
},*/
},
rules: {
'no-use-before-define': ['error', { functions: false }],
'no-continue': 'off',
'no-param-reassign': ['error', { props: false }],
},
ignores: ["docs",
"test",
"lib/env/tools.js",
"gulpfile.js",
"test.json",
"test.js",
"test2.js",
"test_plants.json",
"testSharePlant.json"
],

};
4 changes: 2 additions & 2 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
if: contains(github.event.head_commit.message, '[skip ci]') == false

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]

steps:
- name: Checkout source Code
uses: actions/checkout@v4
Expand Down
36 changes: 18 additions & 18 deletions lib/growatt.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const https = require('https');
const debugApi = require('debug')('growatt:api');
const debugVerbose = require('debug')('growatt:verbose');
const Axios = require('axios');
const md5 = require('md5');
const MD5 = require('md5');
const QUEUE = require('./queue');
const GROWATTTYPE = require('./growatttype');
const PARSEIN = require('./parsein');
Expand Down Expand Up @@ -133,7 +133,7 @@ module.exports = class growatt {
login(user, password) {
return new Promise((resolve, reject) => {
debugApi('login:', 'user:', user, 'password:', '*no*');
const params = new Url.URLSearchParams({ account: user, password: '', validateCode: '', isReadPact: 0, passwordCrc: md5(password) });
const params = new Url.URLSearchParams({ account: user, password: '', validateCode: '', isReadPact: 0, passwordCrc: MD5(password) });
this.connected = false;
if (this.lifeSignCallback) this.lifeSignCallback();
this.axios
Expand Down Expand Up @@ -598,7 +598,7 @@ module.exports = class growatt {
});
}

// eslint-disable-next-line class-methods-use-this
getInverterCommunication(type) {
debugApi('getInverterCommunication:', 'type', type);
const ret = {};
Expand Down Expand Up @@ -631,7 +631,7 @@ module.exports = class growatt {
}

comInverter(type, paramorgi) {
// eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve, reject) => {
debugApi('comInverter:', 'type', type, 'paramorgi', paramorgi);
let checkRet = null;
Expand Down Expand Up @@ -735,13 +735,13 @@ module.exports = class growatt {
reject(e);
});
if (plants) {
// eslint-disable-next-line no-restricted-syntax
for (const plant of plants) {
let res = {};
let curPage = 0;
do {
curPage += 1;
// eslint-disable-next-line no-await-in-loop
res = await this.getDataLogger(plant.id, curPage).catch(e => {
debugApi('getDataLoggers getDataLogger err:', e);
reject(e);
Expand Down Expand Up @@ -790,7 +790,7 @@ module.exports = class growatt {
});
}

/* eslint-disable-next-line class-methods-use-this */
correctTime(struct) {
function makeTime(time) {
if (
Expand Down Expand Up @@ -853,7 +853,7 @@ module.exports = class growatt {
}

getAllPlantData(opt) {
/* eslint-disable-next-line no-async-promise-executor */
return new Promise(async (resolve, reject) => {
let options = opt;
debugApi('getAllPlantData', 'options:', options);
Expand Down Expand Up @@ -891,7 +891,7 @@ module.exports = class growatt {
result[plant.id] = plant;
if (options.plantData) {
result[plant.id].plantData = {};
/* eslint-disable-next-line no-await-in-loop */
const plantData = await this.getPlantData(plant.id).catch(e => {
debugApi('getAllPlantData getPlantData err:', e);
reject(e);
Expand All @@ -902,7 +902,7 @@ module.exports = class growatt {
}
if (options.weather) {
result[plant.id].weather = {};
/* eslint-disable-next-line no-await-in-loop */
const weather = await this.getWeatherByPlantId(plant.id).catch(e => {
debugApi('getAllPlantData getWeatherByPlantId err:', e);
reject(e);
Expand All @@ -913,7 +913,7 @@ module.exports = class growatt {
}
if (options.faultlog) {
result[plant.id].faultlog = {};
/* eslint-disable-next-line no-await-in-loop */
const faultlog = await this.getNewPlantFaultLog(plant.id, options.faultlogdate).catch(e => {
debugApi('getAllPlantData getNewPlantFaultLog err:', e);
reject(e);
Expand All @@ -939,22 +939,22 @@ module.exports = class growatt {
}
}
}
/* eslint-disable-next-line no-await-in-loop */
result[plant.id].devices = await this.getAllPlantDeviceData(plant.id, options).catch(e => {
debugApi('getAllPlantData getAllPlantDeviceData err:', e);
reject(e);
});

if (options.deviceData) {
/* eslint-disable-next-line no-await-in-loop */
const devices = await this.getDevicesByPlantList(plant.id, 1).catch(e => {
debugApi('getAllPlantData getDevicesByPlantList err:', e);
reject(e);
});
if (devices && devices.obj && devices.obj.datas) {
if (devices.obj.pages && devices.obj.pages > 1) {
for (let p = 1; p < devices.obj.pages; p += 1) {
/* eslint-disable-next-line no-await-in-loop */
const devicesPlus = await this.getDevicesByPlantList(plant.id, p).catch(e => {
debugApi('getAllPlantData getDevicesByPlantList err:', e);
reject(e);
Expand All @@ -968,7 +968,7 @@ module.exports = class growatt {
result[plant.id].devices = {};
}
if (!result[plant.id].devices[devData.sn] && devData.plantId) {
/* eslint-disable-next-line no-await-in-loop */
result[plant.id].devices[devData.sn] = await this.getPlantDeviceData(
devData.plantId,
devData.deviceTypeName,
Expand Down Expand Up @@ -996,7 +996,7 @@ module.exports = class growatt {
}

getAllPlantDeviceData(plantId, opt) {
/* eslint-disable-next-line no-async-promise-executor */
return new Promise(async (resolve, reject) => {
let options = opt;
debugApi('getAllPlantDeviceData:', 'plantId:', plantId, 'options:', options);
Expand Down Expand Up @@ -1025,7 +1025,7 @@ module.exports = class growatt {
if (GROWATTTYPE[growattType].atIndex) {
serialNr += `@${device.obj[growattType][a][GROWATTTYPE[growattType].atIndex]}`;
}
/* eslint-disable-next-line no-await-in-loop */
result[serialNr] = await this.getPlantDeviceData(plantId, growattType, serialNr, invId, options).catch(e => {
debugApi(`getAllPlantDeviceData getPlantDeviceData ${growattType} err:`, e);
reject(e);
Expand All @@ -1044,7 +1044,7 @@ module.exports = class growatt {
}

getPlantDeviceData(plantId, growattType, serialNr, invId, opt) {
/* eslint-disable-next-line no-async-promise-executor */
return new Promise(async (resolve, reject) => {
let options = opt;
debugApi('getPlantDeviceData:', 'plantId', plantId, 'growattType', growattType, 'serialNr', serialNr, 'invId', invId, 'options:', options);
Expand Down
4 changes: 2 additions & 2 deletions lib/parseret.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const debugApi = require('debug')('growatt:api');

function fTime(val, ok) {
debugApi('fTime:', 'val', val, 'ok', ok);
// eslint-disable-next-line no-bitwise
const H = val >> 8;
// eslint-disable-next-line no-bitwise
const M = val & 255;

return [`${`00${H}`.slice(-2)}:${`00${M}`.slice(-2)}`, ok && ((H >= 0 && H <= 23) || M >= 0 || M <= 59)];
Expand Down
Loading

0 comments on commit ccc1843

Please sign in to comment.