@@ -23,7 +23,7 @@ const https = require('https');
23
23
const debugApi = require ( 'debug' ) ( 'growatt:api' ) ;
24
24
const debugVerbose = require ( 'debug' ) ( 'growatt:verbose' ) ;
25
25
const Axios = require ( 'axios' ) ;
26
- const md5 = require ( 'md5' ) ;
26
+ const MD5 = require ( 'md5' ) ;
27
27
const QUEUE = require ( './queue' ) ;
28
28
const GROWATTTYPE = require ( './growatttype' ) ;
29
29
const PARSEIN = require ( './parsein' ) ;
@@ -133,7 +133,7 @@ module.exports = class growatt {
133
133
login ( user , password ) {
134
134
return new Promise ( ( resolve , reject ) => {
135
135
debugApi ( 'login:' , 'user:' , user , 'password:' , '*no*' ) ;
136
- const params = new Url . URLSearchParams ( { account : user , password : '' , validateCode : '' , isReadPact : 0 , passwordCrc : md5 ( password ) } ) ;
136
+ const params = new Url . URLSearchParams ( { account : user , password : '' , validateCode : '' , isReadPact : 0 , passwordCrc : MD5 ( password ) } ) ;
137
137
this . connected = false ;
138
138
if ( this . lifeSignCallback ) this . lifeSignCallback ( ) ;
139
139
this . axios
@@ -598,7 +598,7 @@ module.exports = class growatt {
598
598
} ) ;
599
599
}
600
600
601
-
601
+ // eslint-disable-next-line class-methods-use-this
602
602
getInverterCommunication ( type ) {
603
603
debugApi ( 'getInverterCommunication:' , 'type' , type ) ;
604
604
const ret = { } ;
@@ -631,7 +631,7 @@ module.exports = class growatt {
631
631
}
632
632
633
633
comInverter ( type , paramorgi ) {
634
-
634
+ // eslint-disable-next-line no-async-promise-executor
635
635
return new Promise ( async ( resolve , reject ) => {
636
636
debugApi ( 'comInverter:' , 'type' , type , 'paramorgi' , paramorgi ) ;
637
637
let checkRet = null ;
@@ -735,13 +735,13 @@ module.exports = class growatt {
735
735
reject ( e ) ;
736
736
} ) ;
737
737
if ( plants ) {
738
-
738
+ // eslint-disable-next-line no-restricted-syntax
739
739
for ( const plant of plants ) {
740
740
let res = { } ;
741
741
let curPage = 0 ;
742
742
do {
743
743
curPage += 1 ;
744
-
744
+ // eslint-disable-next-line no-await-in-loop
745
745
res = await this . getDataLogger ( plant . id , curPage ) . catch ( e => {
746
746
debugApi ( 'getDataLoggers getDataLogger err:' , e ) ;
747
747
reject ( e ) ;
@@ -790,7 +790,7 @@ module.exports = class growatt {
790
790
} ) ;
791
791
}
792
792
793
-
793
+ /* eslint-disable-next-line class-methods-use-this */
794
794
correctTime ( struct ) {
795
795
function makeTime ( time ) {
796
796
if (
@@ -853,7 +853,7 @@ module.exports = class growatt {
853
853
}
854
854
855
855
getAllPlantData ( opt ) {
856
-
856
+ /* eslint-disable-next-line no-async-promise-executor */
857
857
return new Promise ( async ( resolve , reject ) => {
858
858
let options = opt ;
859
859
debugApi ( 'getAllPlantData' , 'options:' , options ) ;
@@ -891,7 +891,7 @@ module.exports = class growatt {
891
891
result [ plant . id ] = plant ;
892
892
if ( options . plantData ) {
893
893
result [ plant . id ] . plantData = { } ;
894
-
894
+ /* eslint-disable-next-line no-await-in-loop */
895
895
const plantData = await this . getPlantData ( plant . id ) . catch ( e => {
896
896
debugApi ( 'getAllPlantData getPlantData err:' , e ) ;
897
897
reject ( e ) ;
@@ -902,7 +902,7 @@ module.exports = class growatt {
902
902
}
903
903
if ( options . weather ) {
904
904
result [ plant . id ] . weather = { } ;
905
-
905
+ /* eslint-disable-next-line no-await-in-loop */
906
906
const weather = await this . getWeatherByPlantId ( plant . id ) . catch ( e => {
907
907
debugApi ( 'getAllPlantData getWeatherByPlantId err:' , e ) ;
908
908
reject ( e ) ;
@@ -913,7 +913,7 @@ module.exports = class growatt {
913
913
}
914
914
if ( options . faultlog ) {
915
915
result [ plant . id ] . faultlog = { } ;
916
-
916
+ /* eslint-disable-next-line no-await-in-loop */
917
917
const faultlog = await this . getNewPlantFaultLog ( plant . id , options . faultlogdate ) . catch ( e => {
918
918
debugApi ( 'getAllPlantData getNewPlantFaultLog err:' , e ) ;
919
919
reject ( e ) ;
@@ -939,22 +939,22 @@ module.exports = class growatt {
939
939
}
940
940
}
941
941
}
942
-
942
+ /* eslint-disable-next-line no-await-in-loop */
943
943
result [ plant . id ] . devices = await this . getAllPlantDeviceData ( plant . id , options ) . catch ( e => {
944
944
debugApi ( 'getAllPlantData getAllPlantDeviceData err:' , e ) ;
945
945
reject ( e ) ;
946
946
} ) ;
947
947
948
948
if ( options . deviceData ) {
949
-
949
+ /* eslint-disable-next-line no-await-in-loop */
950
950
const devices = await this . getDevicesByPlantList ( plant . id , 1 ) . catch ( e => {
951
951
debugApi ( 'getAllPlantData getDevicesByPlantList err:' , e ) ;
952
952
reject ( e ) ;
953
953
} ) ;
954
954
if ( devices && devices . obj && devices . obj . datas ) {
955
955
if ( devices . obj . pages && devices . obj . pages > 1 ) {
956
956
for ( let p = 1 ; p < devices . obj . pages ; p += 1 ) {
957
-
957
+ /* eslint-disable-next-line no-await-in-loop */
958
958
const devicesPlus = await this . getDevicesByPlantList ( plant . id , p ) . catch ( e => {
959
959
debugApi ( 'getAllPlantData getDevicesByPlantList err:' , e ) ;
960
960
reject ( e ) ;
@@ -968,7 +968,7 @@ module.exports = class growatt {
968
968
result [ plant . id ] . devices = { } ;
969
969
}
970
970
if ( ! result [ plant . id ] . devices [ devData . sn ] && devData . plantId ) {
971
-
971
+ /* eslint-disable-next-line no-await-in-loop */
972
972
result [ plant . id ] . devices [ devData . sn ] = await this . getPlantDeviceData (
973
973
devData . plantId ,
974
974
devData . deviceTypeName ,
@@ -996,7 +996,7 @@ module.exports = class growatt {
996
996
}
997
997
998
998
getAllPlantDeviceData ( plantId , opt ) {
999
-
999
+ /* eslint-disable-next-line no-async-promise-executor */
1000
1000
return new Promise ( async ( resolve , reject ) => {
1001
1001
let options = opt ;
1002
1002
debugApi ( 'getAllPlantDeviceData:' , 'plantId:' , plantId , 'options:' , options ) ;
@@ -1025,7 +1025,7 @@ module.exports = class growatt {
1025
1025
if ( GROWATTTYPE [ growattType ] . atIndex ) {
1026
1026
serialNr += `@${ device . obj [ growattType ] [ a ] [ GROWATTTYPE [ growattType ] . atIndex ] } ` ;
1027
1027
}
1028
-
1028
+ /* eslint-disable-next-line no-await-in-loop */
1029
1029
result [ serialNr ] = await this . getPlantDeviceData ( plantId , growattType , serialNr , invId , options ) . catch ( e => {
1030
1030
debugApi ( `getAllPlantDeviceData getPlantDeviceData ${ growattType } err:` , e ) ;
1031
1031
reject ( e ) ;
@@ -1044,7 +1044,7 @@ module.exports = class growatt {
1044
1044
}
1045
1045
1046
1046
getPlantDeviceData ( plantId , growattType , serialNr , invId , opt ) {
1047
-
1047
+ /* eslint-disable-next-line no-async-promise-executor */
1048
1048
return new Promise ( async ( resolve , reject ) => {
1049
1049
let options = opt ;
1050
1050
debugApi ( 'getPlantDeviceData:' , 'plantId' , plantId , 'growattType' , growattType , 'serialNr' , serialNr , 'invId' , invId , 'options:' , options ) ;
0 commit comments