homebridge-solaxcloud-api 2.3.2 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +140 -127
- package/LICENSE +175 -175
- package/config.sample +15 -15
- package/config.schema.json +105 -105
- package/dist/batteryAccessory.d.ts +70 -70
- package/dist/batteryAccessory.d.ts.map +1 -1
- package/dist/batteryAccessory.js +124 -123
- package/dist/batteryAccessory.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/lightSensorAccessory.d.ts +34 -34
- package/dist/lightSensorAccessory.js +58 -58
- package/dist/motionAccessory.d.ts +53 -53
- package/dist/motionAccessory.js +93 -93
- package/dist/outletAccessory.d.ts +100 -100
- package/dist/outletAccessory.js +187 -187
- package/dist/platform.d.ts +62 -56
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +294 -265
- package/dist/platform.js.map +1 -1
- package/dist/platformAccessory.d.ts +70 -70
- package/dist/platformAccessory.js +102 -102
- package/dist/platformInverter.d.ts +180 -176
- package/dist/platformInverter.d.ts.map +1 -1
- package/dist/platformInverter.js +348 -343
- package/dist/platformInverter.js.map +1 -1
- package/dist/platformMeters.d.ts +68 -68
- package/dist/platformMeters.js +2 -2
- package/dist/settings.d.ts +8 -8
- package/dist/settings.js +11 -11
- package/dist/solaxcloudfetch.d.ts +1 -1
- package/dist/solaxcloudfetch.js +21 -21
- package/dist/solaxcloudfetch.js.map +1 -1
- package/dist/statistics.d.ts +36 -36
- package/dist/statistics.js +88 -88
- package/dist/util.d.ts +23 -23
- package/dist/util.js +42 -42
- package/package.json +55 -54
- package/config.json +0 -16
- package/dist/solaxcloudapi.d.ts +0 -163
- package/dist/solaxcloudapi.d.ts.map +0 -1
- package/dist/solaxcloudapi.js +0 -226
- package/dist/solaxcloudapi.js.map +0 -1
- package/test/solaxcloudapi.test.ts +0 -164
package/dist/util.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Util = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Utility class.
|
|
6
|
-
*/
|
|
7
|
-
class Util {
|
|
8
|
-
/**
|
|
9
|
-
* Calculates 32 bit hash from a string.
|
|
10
|
-
* @param s {string} String to calculate 32 bit hash from.
|
|
11
|
-
* @returns {number} The 32 bit hash from the string.
|
|
12
|
-
*/
|
|
13
|
-
static hash32(s) {
|
|
14
|
-
let hash = 0;
|
|
15
|
-
if (s.length === 0) {
|
|
16
|
-
return hash;
|
|
17
|
-
}
|
|
18
|
-
for (let i = 0; i < s.length; i++) {
|
|
19
|
-
const chr = s.charCodeAt(i);
|
|
20
|
-
hash = ((hash << 5) - hash) + chr;
|
|
21
|
-
hash |= 0; // Convert to 32bit integer
|
|
22
|
-
}
|
|
23
|
-
return hash;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Removes non-standard alphanumeric characters from string.
|
|
27
|
-
* @param {string} s The original string.
|
|
28
|
-
* @returns {string} Resulting string without any non-standard chars.
|
|
29
|
-
*/
|
|
30
|
-
static normalizeName(s) {
|
|
31
|
-
return s.replace(/[^-_ a-zA-Z0-9]/gi, '');
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Returns whether an array has duplicates or not.
|
|
35
|
-
* @param {unknown[]} array The array to check for duplicates.
|
|
36
|
-
* @returns {boolean} Whether the array has duplicates.
|
|
37
|
-
*/
|
|
38
|
-
static arrayHasDuplicates(array) {
|
|
39
|
-
return (new Set(array)).size !== array.length;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.Util = Util;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Util = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Utility class.
|
|
6
|
+
*/
|
|
7
|
+
class Util {
|
|
8
|
+
/**
|
|
9
|
+
* Calculates 32 bit hash from a string.
|
|
10
|
+
* @param s {string} String to calculate 32 bit hash from.
|
|
11
|
+
* @returns {number} The 32 bit hash from the string.
|
|
12
|
+
*/
|
|
13
|
+
static hash32(s) {
|
|
14
|
+
let hash = 0;
|
|
15
|
+
if (s.length === 0) {
|
|
16
|
+
return hash;
|
|
17
|
+
}
|
|
18
|
+
for (let i = 0; i < s.length; i++) {
|
|
19
|
+
const chr = s.charCodeAt(i);
|
|
20
|
+
hash = ((hash << 5) - hash) + chr;
|
|
21
|
+
hash |= 0; // Convert to 32bit integer
|
|
22
|
+
}
|
|
23
|
+
return hash;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Removes non-standard alphanumeric characters from string.
|
|
27
|
+
* @param {string} s The original string.
|
|
28
|
+
* @returns {string} Resulting string without any non-standard chars.
|
|
29
|
+
*/
|
|
30
|
+
static normalizeName(s) {
|
|
31
|
+
return s.replace(/[^-_ a-zA-Z0-9]/gi, '');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns whether an array has duplicates or not.
|
|
35
|
+
* @param {unknown[]} array The array to check for duplicates.
|
|
36
|
+
* @returns {boolean} Whether the array has duplicates.
|
|
37
|
+
*/
|
|
38
|
+
static arrayHasDuplicates(array) {
|
|
39
|
+
return (new Set(array)).size !== array.length;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.Util = Util;
|
|
43
43
|
//# sourceMappingURL=util.js.map
|
package/package.json
CHANGED
|
@@ -1,54 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
"private": false,
|
|
3
|
-
"displayName": "Homebridge Solax Cloud API",
|
|
4
|
-
"name": "homebridge-solaxcloud-api",
|
|
5
|
-
"version": "2.
|
|
6
|
-
"description": "Integrates solar production info using public Solax/QCells Cloud API into Homebridge accessories.",
|
|
7
|
-
"license": "Apache-2.0",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git://github.com/AllMightySauron/homebride-solaxcloud-api.git"
|
|
11
|
-
},
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/AllMightySauron/homebride-solaxcloud-api/issues"
|
|
14
|
-
},
|
|
15
|
-
"engines": {
|
|
16
|
-
"node": ">=14.18.1",
|
|
17
|
-
"homebridge": ">=1.3.8"
|
|
18
|
-
},
|
|
19
|
-
"main": "dist/index.js",
|
|
20
|
-
"scripts": {
|
|
21
|
-
"test": "mocha --require ts-node/register test/**/*.test.ts",
|
|
22
|
-
"lint": "eslint src/**.ts --max-warnings=0",
|
|
23
|
-
"watch": "npm run build && npm link && nodemon",
|
|
24
|
-
"build": "rimraf ./dist && tsc",
|
|
25
|
-
"prepublishOnly": "npm run lint && npm run build"
|
|
26
|
-
},
|
|
27
|
-
"keywords": [
|
|
28
|
-
"homebridge",
|
|
29
|
-
"homebridge-plugin",
|
|
30
|
-
"solax",
|
|
31
|
-
"qcells",
|
|
32
|
-
"solaxcloud"
|
|
33
|
-
],
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"fakegato-history": "^0.6.4",
|
|
36
|
-
"homebridge-lib": "^5.7.2",
|
|
37
|
-
"jshint": "^2.13.6",
|
|
38
|
-
"string-hash-64": "^1.0.3",
|
|
39
|
-
"sync-fetch": "^0.3.1"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"@types/
|
|
44
|
-
"@
|
|
45
|
-
"@typescript-eslint/
|
|
46
|
-
"eslint": "^
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"private": false,
|
|
3
|
+
"displayName": "Homebridge Solax Cloud API",
|
|
4
|
+
"name": "homebridge-solaxcloud-api",
|
|
5
|
+
"version": "2.4.0",
|
|
6
|
+
"description": "Integrates solar production info using public Solax/QCells Cloud API into Homebridge accessories.",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git://github.com/AllMightySauron/homebride-solaxcloud-api.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/AllMightySauron/homebride-solaxcloud-api/issues"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=14.18.1",
|
|
17
|
+
"homebridge": ">=1.3.8"
|
|
18
|
+
},
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "mocha --require ts-node/register test/**/*.test.ts",
|
|
22
|
+
"lint": "eslint src/**.ts --max-warnings=0",
|
|
23
|
+
"watch": "npm run build && npm link && nodemon",
|
|
24
|
+
"build": "rimraf ./dist && tsc",
|
|
25
|
+
"prepublishOnly": "npm run lint && npm run build"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"homebridge",
|
|
29
|
+
"homebridge-plugin",
|
|
30
|
+
"solax",
|
|
31
|
+
"qcells",
|
|
32
|
+
"solaxcloud"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"fakegato-history": "^0.6.4",
|
|
36
|
+
"homebridge-lib": "^5.7.2",
|
|
37
|
+
"jshint": "^2.13.6",
|
|
38
|
+
"string-hash-64": "^1.0.3",
|
|
39
|
+
"sync-fetch": "^0.3.1",
|
|
40
|
+
"solax-cloud-api": "^0.2.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/mocha": "^9.0.0",
|
|
44
|
+
"@types/node": "^16.10.9",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
46
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
47
|
+
"eslint": "^8.0.1",
|
|
48
|
+
"homebridge": "^1.7.0",
|
|
49
|
+
"mocha": "^11.0.1",
|
|
50
|
+
"nodemon": "^3.1.0",
|
|
51
|
+
"rimraf": "^3.0.2",
|
|
52
|
+
"ts-node": "^10.3.0",
|
|
53
|
+
"typescript": "^4.4.4"
|
|
54
|
+
}
|
|
55
|
+
}
|
package/config.json
DELETED
package/dist/solaxcloudapi.d.ts
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SolaxCloudAPIResult interface for Solax Cloud API Result.
|
|
3
|
-
* */
|
|
4
|
-
export interface SolaxCloudAPIResult {
|
|
5
|
-
/** Unique identifier of inverter (Serial No) */
|
|
6
|
-
inverterSN: string;
|
|
7
|
-
/** Unique identifier of communication module (Registration No) */
|
|
8
|
-
sn: string;
|
|
9
|
-
/** Inverter AC power total (W) */
|
|
10
|
-
acpower: number;
|
|
11
|
-
/** Inverter AC energy out daily (KWh) */
|
|
12
|
-
yieldtoday: number;
|
|
13
|
-
/** Inverter AC energy out total (KWh) */
|
|
14
|
-
yieldtotal: number;
|
|
15
|
-
/** GCP power total (W) */
|
|
16
|
-
feedinpower: number;
|
|
17
|
-
/** GCP energy to grid total (KWh) */
|
|
18
|
-
feedinenergy: number;
|
|
19
|
-
/** GCP energy from grid total (KWh) */
|
|
20
|
-
consumeenergy: number;
|
|
21
|
-
/** Address 2 meter AC power total (W) */
|
|
22
|
-
feedinpowerM2: number;
|
|
23
|
-
/** Inverter DC battery energy SOC (%) */
|
|
24
|
-
soc: number | null;
|
|
25
|
-
/** Inverter AC EPS power R (W) */
|
|
26
|
-
peps1: number | null;
|
|
27
|
-
/** Inverter AC EPS power S (W) */
|
|
28
|
-
peps2: number | null;
|
|
29
|
-
/** Inverter AC EPS power T (W) */
|
|
30
|
-
peps3: number | null;
|
|
31
|
-
/** Inverter type code */
|
|
32
|
-
inverterType: string;
|
|
33
|
-
/** Inverter status code */
|
|
34
|
-
inverterStatus: string;
|
|
35
|
-
/** Update time */
|
|
36
|
-
uploadTime: string;
|
|
37
|
-
/** Inverter DC Battery power total (W) */
|
|
38
|
-
batPower: number;
|
|
39
|
-
/** Inverter DC PV power MPPT1 (W) */
|
|
40
|
-
powerdc1: number | null;
|
|
41
|
-
/** Inverter DC PV power MPPT2 (W) */
|
|
42
|
-
powerdc2: number | null;
|
|
43
|
-
/** Inverter DC PV power MPPT3 (W) */
|
|
44
|
-
powerdc3: number | null;
|
|
45
|
-
/** Inverter DC PV power MPPT4 (W) */
|
|
46
|
-
powerdc4: number | null;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* SolaxCloudAPIResponse interface for responses from Solax Cloud API.
|
|
50
|
-
*/
|
|
51
|
-
export interface SolaxCloudAPIResponse {
|
|
52
|
-
/** Response from server */
|
|
53
|
-
exception: string;
|
|
54
|
-
/** Data returned */
|
|
55
|
-
result: SolaxCloudAPIResult;
|
|
56
|
-
/** Whether the data request was successful */
|
|
57
|
-
success: boolean;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Brand for cloud data fetching.
|
|
61
|
-
*/
|
|
62
|
-
export declare const INVERTER_BRAND: {
|
|
63
|
-
SOLAX: number;
|
|
64
|
-
QCELLS: number;
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Main class to retrieve data from Solax API.
|
|
68
|
-
*/
|
|
69
|
-
export declare class SolaxCloudAPI {
|
|
70
|
-
readonly brand: number;
|
|
71
|
-
readonly tokenId: string;
|
|
72
|
-
readonly sn: string;
|
|
73
|
-
/**
|
|
74
|
-
* Class constructor.
|
|
75
|
-
* @param {number} brand Inverter brand type.
|
|
76
|
-
* @param {string} tokenId Token ID to gather data from Solax Cloud API.
|
|
77
|
-
* @param {string} sn Unique identifier of inverter (Serial No).
|
|
78
|
-
*/
|
|
79
|
-
constructor(brand: number, tokenId: string, sn: string);
|
|
80
|
-
/**
|
|
81
|
-
* Gets the cloud API URL depending on the inverter brand.
|
|
82
|
-
* @returns Cloud API URL.
|
|
83
|
-
*/
|
|
84
|
-
private getCloudURL;
|
|
85
|
-
/**
|
|
86
|
-
* Gets the inverter type description from the corresponding type code.
|
|
87
|
-
* @param {string} typeCode The Solax inverter type code.
|
|
88
|
-
* @returns Corresponding inverter type description.
|
|
89
|
-
*/
|
|
90
|
-
static getInverterType(typeCode: string): string;
|
|
91
|
-
/**
|
|
92
|
-
* Gets the inverter status description from the corresponding status code.
|
|
93
|
-
* @param {string} statusCode The inverter status code.
|
|
94
|
-
* @returns Corresponding inverter status description.
|
|
95
|
-
*/
|
|
96
|
-
static getInverterStatus(statusCode: string): string;
|
|
97
|
-
/**
|
|
98
|
-
* Gets the inverter fed photovoltaic DC power (in W) from the retrieved API results.
|
|
99
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
100
|
-
* @returns {number} The measured inverter photovoltaic input DC power (in W).
|
|
101
|
-
*/
|
|
102
|
-
static getPVPower(data: SolaxCloudAPIResult): number;
|
|
103
|
-
/**
|
|
104
|
-
* Gets the inverter output AC power (in W) from the retrieved API results.
|
|
105
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
106
|
-
* @returns {number} The measured inverter output AC power (in W).
|
|
107
|
-
*/
|
|
108
|
-
static getInverterACPower(data: SolaxCloudAPIResult): number;
|
|
109
|
-
/**
|
|
110
|
-
* Gets the inverter power charging battery (in W) from the retrieved API results.
|
|
111
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
112
|
-
* @returns {number} The measured inverter DC power to battery (in W).
|
|
113
|
-
*/
|
|
114
|
-
static getInverterPowerToBattery(data: SolaxCloudAPIResult): number;
|
|
115
|
-
/**
|
|
116
|
-
* Gets the inverter power drawn from battery (in W) from the retrieved API results.
|
|
117
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
118
|
-
* @returns {number} The measured inverter DC power from battery (in W).
|
|
119
|
-
*/
|
|
120
|
-
static getInverterPowerFromBattery(data: SolaxCloudAPIResult): number;
|
|
121
|
-
/**
|
|
122
|
-
* Gets the Inverter AC energy out for today (KWh) from the retrieved API results.
|
|
123
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
124
|
-
* @returns {number} The AC energy output by the inverter today (in KWh).
|
|
125
|
-
*/
|
|
126
|
-
static getYieldToday(data: SolaxCloudAPIResult): number;
|
|
127
|
-
/**
|
|
128
|
-
* Gets the Inverter AC energy out total (KWh) from the retrieved API results.
|
|
129
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
130
|
-
* @returns {number} The total AC energy output by the inverter (in KWh).
|
|
131
|
-
*/
|
|
132
|
-
static getYieldTotal(data: SolaxCloudAPIResult): number;
|
|
133
|
-
/**
|
|
134
|
-
* Gets the battery State of Charge - Soc (%) from the retrieved API results.
|
|
135
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
136
|
-
* @returns {number} The battery State of Charge for this inverter (%).
|
|
137
|
-
*/
|
|
138
|
-
static getBatterySoC(data: SolaxCloudAPIResult): number;
|
|
139
|
-
/**
|
|
140
|
-
* Gets the power currently being fed to the grid by the inverter (in W).
|
|
141
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
142
|
-
* @returns The power currently being sent to the grid (in W).
|
|
143
|
-
*/
|
|
144
|
-
static getInverterPowerToGrid(data: SolaxCloudAPIResult): number;
|
|
145
|
-
/**
|
|
146
|
-
* Gets the power currently being drawn from the grid to the house (in W).
|
|
147
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
148
|
-
* @returns The power currently being drawn from the grid to the house (in W).
|
|
149
|
-
*/
|
|
150
|
-
static getGridPowerToHouse(data: SolaxCloudAPIResult): number;
|
|
151
|
-
/**
|
|
152
|
-
* Gets the power currently being generated by the inverter to the house (in W).
|
|
153
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
154
|
-
* @returns The power currently being generated by the inverter to the house (in W).
|
|
155
|
-
*/
|
|
156
|
-
static getInverterPowerToHouse(data: SolaxCloudAPIResult): number;
|
|
157
|
-
/**
|
|
158
|
-
* Retrieves inverter data using Solax Cloud "real-time" API.
|
|
159
|
-
* @returns {SolaxCloudAPIResponse} The response by Solax Cloud API.
|
|
160
|
-
*/
|
|
161
|
-
getAPIData(): SolaxCloudAPIResponse;
|
|
162
|
-
}
|
|
163
|
-
//# sourceMappingURL=solaxcloudapi.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solaxcloudapi.d.ts","sourceRoot":"","sources":["../src/solaxcloudapi.ts"],"names":[],"mappings":"AAEA;;KAEK;AACL,MAAM,WAAW,mBAAmB;IAChC,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,kCAAkC;IAClC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,kCAAkC;IAClC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,kCAAkC;IAClC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,yBAAyB;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,2BAA2B;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,QAAQ,EAAE,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,aAAa,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM;IAI9D;;;;OAIG;WACW,sBAAsB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM;IAIvE;;;;OAIG;WACW,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM;IAIpE;;;;OAIG;WACW,uBAAuB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM;IAIxE;;;OAGG;IACI,UAAU,IAAI,qBAAqB;CAc3C"}
|
package/dist/solaxcloudapi.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SolaxCloudAPI = exports.INVERTER_BRAND = void 0;
|
|
7
|
-
const sync_fetch_1 = __importDefault(require("sync-fetch"));
|
|
8
|
-
/**
|
|
9
|
-
* Brand for cloud data fetching.
|
|
10
|
-
*/
|
|
11
|
-
exports.INVERTER_BRAND = {
|
|
12
|
-
SOLAX: 0,
|
|
13
|
-
QCELLS: 1,
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Cloud API URL for data fetching.
|
|
17
|
-
*/
|
|
18
|
-
const CLOUD_URL = {
|
|
19
|
-
SOLAX: 'https://www.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do',
|
|
20
|
-
QCELLS: 'https://www.portal-q-cells.us/proxyApp/proxy/api/getRealtimeInfo.do',
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Main class to retrieve data from Solax API.
|
|
24
|
-
*/
|
|
25
|
-
class SolaxCloudAPI {
|
|
26
|
-
/**
|
|
27
|
-
* Class constructor.
|
|
28
|
-
* @param {number} brand Inverter brand type.
|
|
29
|
-
* @param {string} tokenId Token ID to gather data from Solax Cloud API.
|
|
30
|
-
* @param {string} sn Unique identifier of inverter (Serial No).
|
|
31
|
-
*/
|
|
32
|
-
constructor(brand, tokenId, sn) {
|
|
33
|
-
this.brand = brand;
|
|
34
|
-
this.tokenId = tokenId;
|
|
35
|
-
this.sn = sn;
|
|
36
|
-
this.brand = brand;
|
|
37
|
-
this.tokenId = tokenId;
|
|
38
|
-
this.sn = sn;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Gets the cloud API URL depending on the inverter brand.
|
|
42
|
-
* @returns Cloud API URL.
|
|
43
|
-
*/
|
|
44
|
-
getCloudURL() {
|
|
45
|
-
if (this.brand === exports.INVERTER_BRAND.QCELLS) {
|
|
46
|
-
return CLOUD_URL.QCELLS;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
return CLOUD_URL.SOLAX;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Gets the inverter type description from the corresponding type code.
|
|
54
|
-
* @param {string} typeCode The Solax inverter type code.
|
|
55
|
-
* @returns Corresponding inverter type description.
|
|
56
|
-
*/
|
|
57
|
-
static getInverterType(typeCode) {
|
|
58
|
-
switch (typeCode) {
|
|
59
|
-
case '1':
|
|
60
|
-
return 'X1-LX';
|
|
61
|
-
case '2':
|
|
62
|
-
return 'X-Hybrid';
|
|
63
|
-
case '3':
|
|
64
|
-
return 'X1-Hybiyd/Fit';
|
|
65
|
-
case '4':
|
|
66
|
-
return 'X1-Boost/Air/Mini';
|
|
67
|
-
case '5':
|
|
68
|
-
return 'X3-Hybiyd/Fit';
|
|
69
|
-
case '6':
|
|
70
|
-
return 'X3-20K/30K';
|
|
71
|
-
case '7':
|
|
72
|
-
return 'X3-MIC/PRO';
|
|
73
|
-
case '8':
|
|
74
|
-
return 'X1-Smart';
|
|
75
|
-
case '9':
|
|
76
|
-
return 'X1-AC';
|
|
77
|
-
case '10':
|
|
78
|
-
return 'A1-Hybrid';
|
|
79
|
-
case '11':
|
|
80
|
-
return 'A1-Fit';
|
|
81
|
-
case '12':
|
|
82
|
-
return 'A1-Grid';
|
|
83
|
-
case '13':
|
|
84
|
-
return 'J1-ESS';
|
|
85
|
-
default:
|
|
86
|
-
return 'Unknown';
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Gets the inverter status description from the corresponding status code.
|
|
91
|
-
* @param {string} statusCode The inverter status code.
|
|
92
|
-
* @returns Corresponding inverter status description.
|
|
93
|
-
*/
|
|
94
|
-
static getInverterStatus(statusCode) {
|
|
95
|
-
switch (statusCode) {
|
|
96
|
-
case '100':
|
|
97
|
-
return 'Wait Mode';
|
|
98
|
-
case '101':
|
|
99
|
-
return 'Check Mode';
|
|
100
|
-
case '102':
|
|
101
|
-
return 'Normal Mode';
|
|
102
|
-
case '103':
|
|
103
|
-
return 'Fault Mode';
|
|
104
|
-
case '104':
|
|
105
|
-
return 'Permanent Fault Mode';
|
|
106
|
-
case '105':
|
|
107
|
-
return 'Update Mode';
|
|
108
|
-
case '106':
|
|
109
|
-
return 'EPS Check Mode';
|
|
110
|
-
case '107':
|
|
111
|
-
return 'EPS Mode';
|
|
112
|
-
case '108':
|
|
113
|
-
return 'Self-Test Mode';
|
|
114
|
-
case '109':
|
|
115
|
-
return 'Idle Mode';
|
|
116
|
-
case '110':
|
|
117
|
-
return 'Standby Mode';
|
|
118
|
-
case '111':
|
|
119
|
-
return 'Pv Wake Up Bat Mode';
|
|
120
|
-
case '112':
|
|
121
|
-
return 'Gen Check Mode';
|
|
122
|
-
case '113':
|
|
123
|
-
return 'Gen Run Mode';
|
|
124
|
-
default:
|
|
125
|
-
return 'Unknown';
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Gets the inverter fed photovoltaic DC power (in W) from the retrieved API results.
|
|
130
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
131
|
-
* @returns {number} The measured inverter photovoltaic input DC power (in W).
|
|
132
|
-
*/
|
|
133
|
-
static getPVPower(data) {
|
|
134
|
-
return (data.powerdc1 || 0) + (data.powerdc2 || 0) + (data.powerdc3 || 0) + (data.powerdc4 || 0);
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Gets the inverter output AC power (in W) from the retrieved API results.
|
|
138
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
139
|
-
* @returns {number} The measured inverter output AC power (in W).
|
|
140
|
-
*/
|
|
141
|
-
static getInverterACPower(data) {
|
|
142
|
-
return data.acpower;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Gets the inverter power charging battery (in W) from the retrieved API results.
|
|
146
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
147
|
-
* @returns {number} The measured inverter DC power to battery (in W).
|
|
148
|
-
*/
|
|
149
|
-
static getInverterPowerToBattery(data) {
|
|
150
|
-
return data.batPower > 0 ? data.batPower : 0;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Gets the inverter power drawn from battery (in W) from the retrieved API results.
|
|
154
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
155
|
-
* @returns {number} The measured inverter DC power from battery (in W).
|
|
156
|
-
*/
|
|
157
|
-
static getInverterPowerFromBattery(data) {
|
|
158
|
-
return data.batPower < 0 ? -data.batPower : 0;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Gets the Inverter AC energy out for today (KWh) from the retrieved API results.
|
|
162
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
163
|
-
* @returns {number} The AC energy output by the inverter today (in KWh).
|
|
164
|
-
*/
|
|
165
|
-
static getYieldToday(data) {
|
|
166
|
-
return data.yieldtoday;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Gets the Inverter AC energy out total (KWh) from the retrieved API results.
|
|
170
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
171
|
-
* @returns {number} The total AC energy output by the inverter (in KWh).
|
|
172
|
-
*/
|
|
173
|
-
static getYieldTotal(data) {
|
|
174
|
-
return data.yieldtotal;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Gets the battery State of Charge - Soc (%) from the retrieved API results.
|
|
178
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
179
|
-
* @returns {number} The battery State of Charge for this inverter (%).
|
|
180
|
-
*/
|
|
181
|
-
static getBatterySoC(data) {
|
|
182
|
-
return data.soc === null ? 0 : data.soc;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Gets the power currently being fed to the grid by the inverter (in W).
|
|
186
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
187
|
-
* @returns The power currently being sent to the grid (in W).
|
|
188
|
-
*/
|
|
189
|
-
static getInverterPowerToGrid(data) {
|
|
190
|
-
return data.feedinpower > 0 ? data.feedinpower : 0;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Gets the power currently being drawn from the grid to the house (in W).
|
|
194
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
195
|
-
* @returns The power currently being drawn from the grid to the house (in W).
|
|
196
|
-
*/
|
|
197
|
-
static getGridPowerToHouse(data) {
|
|
198
|
-
return data.feedinpower < 0 ? -data.feedinpower : 0;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Gets the power currently being generated by the inverter to the house (in W).
|
|
202
|
-
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
203
|
-
* @returns The power currently being generated by the inverter to the house (in W).
|
|
204
|
-
*/
|
|
205
|
-
static getInverterPowerToHouse(data) {
|
|
206
|
-
return this.getInverterACPower(data) - this.getInverterPowerToGrid(data);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Retrieves inverter data using Solax Cloud "real-time" API.
|
|
210
|
-
* @returns {SolaxCloudAPIResponse} The response by Solax Cloud API.
|
|
211
|
-
*/
|
|
212
|
-
getAPIData() {
|
|
213
|
-
try {
|
|
214
|
-
const response = (0, sync_fetch_1.default)(this.getCloudURL() + '?tokenId=' + this.tokenId + '&sn=' + this.sn);
|
|
215
|
-
if (!response.ok) {
|
|
216
|
-
throw new Error(`unexpected response ${response.statusText}`);
|
|
217
|
-
}
|
|
218
|
-
return response.json();
|
|
219
|
-
}
|
|
220
|
-
catch (error) {
|
|
221
|
-
return { exception: error, result: {}, success: false };
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
exports.SolaxCloudAPI = SolaxCloudAPI;
|
|
226
|
-
//# sourceMappingURL=solaxcloudapi.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solaxcloudapi.js","sourceRoot":"","sources":["../src/solaxcloudapi.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AA8D/B;;GAEG;AACU,QAAA,cAAc,GAAG;IAC5B,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;CACV,CAAC;AAEF;;GAEG;AACH,MAAM,SAAS,GAAG;IAChB,KAAK,EAAE,8DAA8D;IACrE,MAAM,EAAE,qEAAqE;CAC9E,CAAC;AAEF;;GAEG;AACH,MAAa,aAAa;IAExB;;;;;SAKK;IACL,YAA6B,KAAa,EAAkB,OAAe,EAAkB,EAAU;QAA1E,UAAK,GAAL,KAAK,CAAQ;QAAkB,YAAO,GAAP,OAAO,CAAQ;QAAkB,OAAE,GAAF,EAAE,CAAQ;QACrG,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED;;;OAGG;IACK,WAAW;QACjB,IAAI,IAAI,CAAC,KAAK,KAAK,sBAAc,CAAC,MAAM,EAAE;YACxC,OAAO,SAAS,CAAC,MAAM,CAAC;SAC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