homebridge-solaxcloud-api 1.2.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/LICENSE +176 -0
- package/README.md +76 -0
- package/config.json +11 -0
- package/config.sample +11 -0
- package/config.schema.json +47 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/motionAccessory.d.ts +30 -0
- package/dist/motionAccessory.d.ts.map +1 -0
- package/dist/motionAccessory.js +67 -0
- package/dist/motionAccessory.js.map +1 -0
- package/dist/outletAccessory.d.ts +36 -0
- package/dist/outletAccessory.d.ts.map +1 -0
- package/dist/outletAccessory.js +76 -0
- package/dist/outletAccessory.js.map +1 -0
- package/dist/platform.d.ts +43 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +123 -0
- package/dist/platform.js.map +1 -0
- package/dist/platformAccessory.d.ts +38 -0
- package/dist/platformAccessory.d.ts.map +1 -0
- package/dist/platformAccessory.js +70 -0
- package/dist/platformAccessory.js.map +1 -0
- package/dist/request.d.ts +29 -0
- package/dist/request.d.ts.map +1 -0
- package/dist/request.js +75 -0
- package/dist/request.js.map +1 -0
- package/dist/settings.d.ts +9 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +12 -0
- package/dist/settings.js.map +1 -0
- package/dist/solaxcloudapi.d.ts +125 -0
- package/dist/solaxcloudapi.d.ts.map +1 -0
- package/dist/solaxcloudapi.js +164 -0
- package/dist/solaxcloudapi.js.map +1 -0
- package/dist/statistics.d.ts +2 -0
- package/dist/statistics.d.ts.map +1 -0
- package/dist/statistics.js +20 -0
- package/dist/statistics.js.map +1 -0
- package/images/homebridge-ui.png +0 -0
- package/package.json +51 -0
- package/test/solaxcloudapi.test.ts +60 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SolaxCloudAPI = void 0;
|
|
4
|
+
const request_1 = require("./request");
|
|
5
|
+
const SOLAX_CLOUD_URL = 'https://www.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do';
|
|
6
|
+
/**
|
|
7
|
+
* Main class to retrieve data from Solax API.
|
|
8
|
+
*/
|
|
9
|
+
class SolaxCloudAPI {
|
|
10
|
+
/**
|
|
11
|
+
* Class constructor.
|
|
12
|
+
* @param tokenId Token ID to gather data from Solax Cloud API.
|
|
13
|
+
* @param sn Unique identifier of inverter (Serial No).
|
|
14
|
+
*/
|
|
15
|
+
constructor(tokenId, sn) {
|
|
16
|
+
this.tokenId = tokenId;
|
|
17
|
+
this.sn = sn;
|
|
18
|
+
this.tokenId = tokenId;
|
|
19
|
+
this.sn = sn;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Gets the inverter type description from the corresponding type code.
|
|
23
|
+
* @param {string} typeCode The Solax inverter type code.
|
|
24
|
+
* @returns Corresponding inverter type description.
|
|
25
|
+
*/
|
|
26
|
+
static getInverterType(typeCode) {
|
|
27
|
+
switch (typeCode) {
|
|
28
|
+
case '1':
|
|
29
|
+
return 'X1-LX';
|
|
30
|
+
case '2':
|
|
31
|
+
return 'X-Hybrid';
|
|
32
|
+
case '3':
|
|
33
|
+
return 'X1-Hybiyd/Fit';
|
|
34
|
+
case '4':
|
|
35
|
+
return 'X1-Boost/Air/Mini';
|
|
36
|
+
case '5':
|
|
37
|
+
return 'X3-Hybiyd/Fit';
|
|
38
|
+
case '6':
|
|
39
|
+
return 'X3-20K/30K';
|
|
40
|
+
case '7':
|
|
41
|
+
return 'X3-MIC/PRO';
|
|
42
|
+
case '8':
|
|
43
|
+
return 'X1-Smart';
|
|
44
|
+
case '9':
|
|
45
|
+
return 'X1-AC';
|
|
46
|
+
case '10':
|
|
47
|
+
return 'A1-Hybrid';
|
|
48
|
+
case '11':
|
|
49
|
+
return 'A1-Fit';
|
|
50
|
+
case '12':
|
|
51
|
+
return 'A1-Grid';
|
|
52
|
+
case '13':
|
|
53
|
+
return 'J1-ESS';
|
|
54
|
+
default:
|
|
55
|
+
return 'Unknown';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Gets the inverter status description from the corresponding status code.
|
|
60
|
+
* @param {string} statusCode The inverter status code.
|
|
61
|
+
* @returns Corresponding inverter status description.
|
|
62
|
+
*/
|
|
63
|
+
static getInverterStatus(statusCode) {
|
|
64
|
+
switch (statusCode) {
|
|
65
|
+
case '100':
|
|
66
|
+
return 'Wait Mode';
|
|
67
|
+
case '101':
|
|
68
|
+
return 'Check Mode';
|
|
69
|
+
case '102':
|
|
70
|
+
return 'Normal Mode';
|
|
71
|
+
case '103':
|
|
72
|
+
return 'Fault Mode';
|
|
73
|
+
case '104':
|
|
74
|
+
return 'Permanent Fault Mode';
|
|
75
|
+
case '105':
|
|
76
|
+
return 'Update Mode';
|
|
77
|
+
case '106':
|
|
78
|
+
return 'EPS Check Mode';
|
|
79
|
+
case '107':
|
|
80
|
+
return 'EPS Mode';
|
|
81
|
+
case '108':
|
|
82
|
+
return 'Self-Test Mode';
|
|
83
|
+
case '109':
|
|
84
|
+
return 'Idle Mode';
|
|
85
|
+
case '110':
|
|
86
|
+
return 'Standby Mode';
|
|
87
|
+
case '111':
|
|
88
|
+
return 'Pv Wake Up Bat Mode';
|
|
89
|
+
case '112':
|
|
90
|
+
return 'Gen Check Mode';
|
|
91
|
+
case '113':
|
|
92
|
+
return 'Gen Run Mode';
|
|
93
|
+
default:
|
|
94
|
+
return 'Unknown';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
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) {
|
|
103
|
+
return (data.powerdc1 || 0) + (data.powerdc2 || 0) + (data.powerdc3 || 0) + (data.powerdc4 || 0);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Gets the inverter output AC power (in W) from the retrieved API results.
|
|
107
|
+
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
108
|
+
* @returns {number} The measured inverter output AC power (in W).
|
|
109
|
+
*/
|
|
110
|
+
static getInverterACPower(data) {
|
|
111
|
+
return data.acpower;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Gets the Inverter AC energy out for today (KWh) from the retrieved API results.
|
|
115
|
+
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
116
|
+
* @returns {number} The AC energy output by the inverter today (in KWh).
|
|
117
|
+
*/
|
|
118
|
+
static getYieldToday(data) {
|
|
119
|
+
return data.yieldtoday;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Gets the Inverter AC energy out total (KWh) from the retrieved API results.
|
|
123
|
+
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
124
|
+
* @returns {number} The total AC energy output by the inverter (in KWh).
|
|
125
|
+
*/
|
|
126
|
+
static getYieldTotal(data) {
|
|
127
|
+
return data.yieldtotal;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Gets the power currently being fed to the grid by the inverter (in W).
|
|
131
|
+
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
132
|
+
* @returns The power currently being sent to the grid (in W).
|
|
133
|
+
*/
|
|
134
|
+
static getInverterPowerToGrid(data) {
|
|
135
|
+
return data.feedinpower > 0 ? data.feedinpower : 0;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Gets the power currently being drawn from the grid to the house (in W).
|
|
139
|
+
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
140
|
+
* @returns The power currently being drawn from the grid to the house (in W).
|
|
141
|
+
*/
|
|
142
|
+
static getGridPowerToHouse(data) {
|
|
143
|
+
return data.feedinpower < 0 ? -data.feedinpower : 0;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Gets the power currently being generated by the inverter to the house (in W).
|
|
147
|
+
* @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
|
|
148
|
+
* @returns The power currently being generated by the inverter to the house (in W).
|
|
149
|
+
*/
|
|
150
|
+
static getInverterPowerToHouse(data) {
|
|
151
|
+
return this.getInverterACPower(data) - this.getInverterPowerToGrid(data);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Retrieves inverter data using Solax Cloud "real-time" API.
|
|
155
|
+
* @returns {SolaxCloudAPIResponse} The response by Solax Cloud API.
|
|
156
|
+
*/
|
|
157
|
+
async getAPIData() {
|
|
158
|
+
const reply = await (0, request_1.request)('get', SOLAX_CLOUD_URL, { tokenId: this.tokenId, sn: this.sn });
|
|
159
|
+
return reply.ok ?
|
|
160
|
+
reply.json() : { exception: reply.statusText, result: {}, success: false };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
exports.SolaxCloudAPI = SolaxCloudAPI;
|
|
164
|
+
//# sourceMappingURL=solaxcloudapi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solaxcloudapi.js","sourceRoot":"","sources":["../src/solaxcloudapi.ts"],"names":[],"mappings":";;;AAAA,uCAAoC;AAwDpC,MAAM,eAAe,GAAG,8DAA8D,CAAC;AAEvF;;GAEG;AACH,MAAa,aAAa;IAExB;;;;SAIK;IACL,YAA6B,OAAe,EAAkB,EAAU;QAA3C,YAAO,GAAP,OAAO,CAAQ;QAAkB,OAAE,GAAF,EAAE,CAAQ;QACtE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED;;;;SAIK;IACE,MAAM,CAAC,eAAe,CAAC,QAAgB;QAC5C,QAAQ,QAAQ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AAU;QACrB,MAAM,KAAK,GAAG,MAAM,IAAA,iBAAO,EAAC,KAAK,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAE5F,OAAO,KAAK,CAAC,EAAE,CAAC,CAAC;YACa,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAyB,EAAE,SAAS,EAAE,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACnI,CAAC;CAEF;AApKD,sCAoKC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
/* eslint-disable no-console */
|
|
7
|
+
const solaxcloudapi_1 = require("./solaxcloudapi");
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const config = JSON.parse(fs_1.default.readFileSync('config.json').toString());
|
|
10
|
+
const api = new solaxcloudapi_1.SolaxCloudAPI(config.platforms[0].tokenId, config.platforms[0].sn);
|
|
11
|
+
api.getAPIData().then(result => {
|
|
12
|
+
console.log(`PV Power: ${solaxcloudapi_1.SolaxCloudAPI.getPVPower(result.result)}W`);
|
|
13
|
+
console.log(`Inverter AC Power: ${solaxcloudapi_1.SolaxCloudAPI.getInverterACPower(result.result)}W`);
|
|
14
|
+
console.log(`Grid Power to House: ${solaxcloudapi_1.SolaxCloudAPI.getGridPowerToHouse(result.result)}W`);
|
|
15
|
+
console.log(`Inverter Power to Grid: ${solaxcloudapi_1.SolaxCloudAPI.getInverterPowerToGrid(result.result)}W`);
|
|
16
|
+
console.log(`Inverter Power to House: ${solaxcloudapi_1.SolaxCloudAPI.getInverterPowerToHouse(result.result)}W`);
|
|
17
|
+
console.log(`Yield Today: ${solaxcloudapi_1.SolaxCloudAPI.getYieldToday(result.result)}KWh`);
|
|
18
|
+
console.log(`Yield Total: ${solaxcloudapi_1.SolaxCloudAPI.getYieldTotal(result.result)}KWh`);
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=statistics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statistics.js","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":";;;;;AAAA,+BAA+B;AAC/B,mDAAgD;AAEhD,4CAAoB;AAEpB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;AACrE,MAAM,GAAG,GAAG,IAAI,6BAAa,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAEnF,GAAG,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;IAC7B,OAAO,CAAC,GAAG,CAAC,aAAa,6BAAa,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,sBAAsB,6BAAa,CAAC,kBAAkB,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACtF,OAAO,CAAC,GAAG,CAAC,wBAAwB,6BAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACzF,OAAO,CAAC,GAAG,CAAC,2BAA2B,6BAAa,CAAC,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/F,OAAO,CAAC,GAAG,CAAC,4BAA4B,6BAAa,CAAC,uBAAuB,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAEjG,OAAO,CAAC,GAAG,CAAC,gBAAgB,6BAAa,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7E,OAAO,CAAC,GAAG,CAAC,gBAAgB,6BAAa,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/E,CAAC,CAAC,CAAC"}
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"private": false,
|
|
3
|
+
"displayName": "Solax Cloud API plugin for Homebridge",
|
|
4
|
+
"name": "homebridge-solaxcloud-api",
|
|
5
|
+
"version": "1.2.0",
|
|
6
|
+
"description": "Integrates solar production info using public Solax Cloud API into Homebrigde acessories.",
|
|
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.5"
|
|
18
|
+
},
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "mocha --timeout 0",
|
|
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
|
+
"solaxcloud"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"jshint": "^2.13.1",
|
|
35
|
+
"xmlhttprequest": "^1.8.0",
|
|
36
|
+
"homebridge-lib": "^5.1.21"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/mocha": "^9.0.0",
|
|
40
|
+
"@types/node": "^16.10.9",
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
42
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
43
|
+
"eslint": "^8.0.1",
|
|
44
|
+
"homebridge": "^1.3.5",
|
|
45
|
+
"mocha": "^9.1.3",
|
|
46
|
+
"nodemon": "^2.0.13",
|
|
47
|
+
"rimraf": "^3.0.2",
|
|
48
|
+
"ts-node": "^10.3.0",
|
|
49
|
+
"typescript": "^4.4.4"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { SolaxCloudAPI, SolaxCloudAPIResponse } from '../src/solaxcloudapi';
|
|
2
|
+
|
|
3
|
+
import assert = require('assert');
|
|
4
|
+
|
|
5
|
+
describe('Static methods', () => {
|
|
6
|
+
|
|
7
|
+
const sampleReply: SolaxCloudAPIResponse = {
|
|
8
|
+
success: true,
|
|
9
|
+
exception: 'Query success!',
|
|
10
|
+
result: {
|
|
11
|
+
inverterSN: 'HUE512H3456789',
|
|
12
|
+
sn: 'ABCDEFGHIJ',
|
|
13
|
+
acpower: 1214,
|
|
14
|
+
yieldtoday: 1.1,
|
|
15
|
+
yieldtotal: 121.1,
|
|
16
|
+
feedinpower: 37,
|
|
17
|
+
feedinenergy: 24.65,
|
|
18
|
+
consumeenergy: 433.09,
|
|
19
|
+
feedinpowerM2: 0,
|
|
20
|
+
soc: 0,
|
|
21
|
+
peps1: 0,
|
|
22
|
+
peps2: null,
|
|
23
|
+
peps3: null,
|
|
24
|
+
inverterType: '3',
|
|
25
|
+
inverterStatus: '102',
|
|
26
|
+
uploadTime: '2021-12-06 10:16:59',
|
|
27
|
+
batPower: 0,
|
|
28
|
+
powerdc1: 0,
|
|
29
|
+
powerdc2: 1258,
|
|
30
|
+
powerdc3: null,
|
|
31
|
+
powerdc4: null,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
it('PV Power', () => {
|
|
36
|
+
assert.strictEqual(1258, SolaxCloudAPI.getPVPower(sampleReply.result));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('Inverter AC Power', () => {
|
|
40
|
+
assert.strictEqual(1214, SolaxCloudAPI.getInverterACPower(sampleReply.result));
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('Yield Today', () => {
|
|
44
|
+
assert.strictEqual(1.1, SolaxCloudAPI.getYieldToday(sampleReply.result));
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
it('Yield Total', () => {
|
|
49
|
+
assert.strictEqual(121.1, SolaxCloudAPI.getYieldTotal(sampleReply.result));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('Inverter power to grid', () => {
|
|
53
|
+
assert.strictEqual(37, SolaxCloudAPI.getInverterPowerToGrid(sampleReply.result));
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('Grid power to house', () => {
|
|
57
|
+
assert.strictEqual(0, SolaxCloudAPI.getGridPowerToHouse(sampleReply.result));
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
});
|