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.
Files changed (44) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +76 -0
  3. package/config.json +11 -0
  4. package/config.sample +11 -0
  5. package/config.schema.json +47 -0
  6. package/dist/index.d.ts +7 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +7 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/motionAccessory.d.ts +30 -0
  11. package/dist/motionAccessory.d.ts.map +1 -0
  12. package/dist/motionAccessory.js +67 -0
  13. package/dist/motionAccessory.js.map +1 -0
  14. package/dist/outletAccessory.d.ts +36 -0
  15. package/dist/outletAccessory.d.ts.map +1 -0
  16. package/dist/outletAccessory.js +76 -0
  17. package/dist/outletAccessory.js.map +1 -0
  18. package/dist/platform.d.ts +43 -0
  19. package/dist/platform.d.ts.map +1 -0
  20. package/dist/platform.js +123 -0
  21. package/dist/platform.js.map +1 -0
  22. package/dist/platformAccessory.d.ts +38 -0
  23. package/dist/platformAccessory.d.ts.map +1 -0
  24. package/dist/platformAccessory.js +70 -0
  25. package/dist/platformAccessory.js.map +1 -0
  26. package/dist/request.d.ts +29 -0
  27. package/dist/request.d.ts.map +1 -0
  28. package/dist/request.js +75 -0
  29. package/dist/request.js.map +1 -0
  30. package/dist/settings.d.ts +9 -0
  31. package/dist/settings.d.ts.map +1 -0
  32. package/dist/settings.js +12 -0
  33. package/dist/settings.js.map +1 -0
  34. package/dist/solaxcloudapi.d.ts +125 -0
  35. package/dist/solaxcloudapi.d.ts.map +1 -0
  36. package/dist/solaxcloudapi.js +164 -0
  37. package/dist/solaxcloudapi.js.map +1 -0
  38. package/dist/statistics.d.ts +2 -0
  39. package/dist/statistics.d.ts.map +1 -0
  40. package/dist/statistics.js +20 -0
  41. package/dist/statistics.js.map +1 -0
  42. package/images/homebridge-ui.png +0 -0
  43. package/package.json +51 -0
  44. package/test/solaxcloudapi.test.ts +60 -0
@@ -0,0 +1,123 @@
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.SolaxCloudAPIPlatform = void 0;
7
+ const homebridge_lib_1 = require("homebridge-lib");
8
+ const outletAccessory_1 = require("./outletAccessory");
9
+ const util_1 = __importDefault(require("util"));
10
+ const solaxcloudapi_1 = require("./solaxcloudapi");
11
+ const motionAccessory_1 = require("./motionAccessory");
12
+ /**
13
+ * HomebridgePlatform
14
+ * This class is the main constructor for your plugin, this is where you should
15
+ * parse the user config and discover/register accessories with Homebridge.
16
+ */
17
+ class SolaxCloudAPIPlatform {
18
+ /**
19
+ * Platform constructor.
20
+ * @param log
21
+ * @param config
22
+ * @param api
23
+ * @returns
24
+ */
25
+ constructor(log, config, api) {
26
+ this.sleep = util_1.default.promisify(setTimeout);
27
+ // store values in properties
28
+ this.log = log;
29
+ this.config = config;
30
+ this.api = api;
31
+ // sanity check
32
+ if (!api || !config) {
33
+ return;
34
+ }
35
+ this.eve = new homebridge_lib_1.EveHomeKitTypes(api);
36
+ this.log.debug(`Config: \n${JSON.stringify(config, null, ' ')}`);
37
+ // setup outlet accessories
38
+ this.outletPV = new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} PV`);
39
+ this.outletInverterAC = new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Inverter AC`);
40
+ this.outletInverterToGrid = new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Inverter to Grid`);
41
+ this.outletInverterToHouse = new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Inverter to House`);
42
+ this.outletGridToHouse = new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Grid to House`);
43
+ // setup update motion sensor
44
+ this.motionUpdate = new motionAccessory_1.SolaxMotionAccessory(this, this.log, `${this.config.name} Update`);
45
+ // init new Solax Cloud API object with give tokenID and sn
46
+ this.solaxCloudAPI = new solaxcloudapi_1.SolaxCloudAPI(this.config.tokenId, this.config.sn);
47
+ this.getAPIData();
48
+ this.log.debug('Finished initializing platform.'),
49
+ // When this event is fired it means Homebridge has created all accessories.
50
+ this.api.on("didFinishLaunching" /* DID_FINISH_LAUNCHING */, () => {
51
+ this.log.debug('Executed didFinishLaunching callback');
52
+ });
53
+ }
54
+ /**
55
+ * Periodically retrieves inverter data from Solax Cloud API using configured tokenID and SN.
56
+ */
57
+ async getDataPeriodically() {
58
+ try {
59
+ this.log.debug('Retrieving data from Solax Cloud API.');
60
+ this.apiData = await this.solaxCloudAPI.getAPIData();
61
+ if (this.apiData.success) {
62
+ this.log.debug(`Retrieved inverter status: ${JSON.stringify(this.apiData.result)}`);
63
+ // update outlets
64
+ this.outletPV.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getPVPower(this.apiData.result));
65
+ this.outletPV.setSerial(`pv-${this.apiData.result.inverterSN}`);
66
+ this.outletPV.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
67
+ this.outletInverterAC.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getInverterACPower(this.apiData.result));
68
+ this.outletInverterAC.setSerial(`inv-ac-${this.apiData.result.inverterSN}`);
69
+ this.outletInverterAC.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
70
+ this.outletInverterToGrid.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getInverterPowerToGrid(this.apiData.result));
71
+ this.outletInverterToGrid.setSerial(`inv-grid-${this.apiData.result.inverterSN}`);
72
+ this.outletInverterToGrid.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
73
+ this.outletInverterToHouse.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getInverterPowerToHouse(this.apiData.result));
74
+ this.outletInverterToHouse.setSerial(`inv-house-${this.apiData.result.inverterSN}`);
75
+ this.outletInverterToHouse.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
76
+ this.outletGridToHouse.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getGridPowerToHouse(this.apiData.result));
77
+ this.outletGridToHouse.setSerial(`grid-house-${this.apiData.result.inverterSN}`);
78
+ this.outletGridToHouse.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
79
+ // update motion sensor
80
+ this.motionUpdate.setState(true);
81
+ this.motionUpdate.setSerial(`update-${this.apiData.result.inverterSN}`);
82
+ this.motionUpdate.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
83
+ }
84
+ else {
85
+ throw new Error(this.apiData.exception);
86
+ }
87
+ }
88
+ catch (error) {
89
+ this.log.error(`Failed to read from Solax Cloud API. Error: ${error}`);
90
+ }
91
+ finally {
92
+ this.log.debug(`Sleeping for ${this.config.pollingFrequency} seconds.`);
93
+ this.sleep(this.config.pollingFrequency * 1000).then(async () => await this.getDataPeriodically());
94
+ }
95
+ }
96
+ /**
97
+ * Gets the latest API data available.
98
+ * @returns
99
+ */
100
+ getAPIData() {
101
+ if (this.apiData) {
102
+ return this.apiData;
103
+ }
104
+ else {
105
+ this.getDataPeriodically().then(() => {
106
+ return this.getAPIData();
107
+ });
108
+ }
109
+ return this.apiData;
110
+ }
111
+ /*
112
+ * This method is called once at startup.
113
+ * The Platform should pass all accessories which need to be created to the callback in form of a AccessoryPlugin.
114
+ * The Platform must respond in a timely manner as otherwise the startup of the bridge would be unnecessarily delayed.
115
+ */
116
+ accessories(callback) {
117
+ callback([this.outletPV, this.outletInverterAC,
118
+ this.outletInverterToGrid, this.outletInverterToHouse, this.outletGridToHouse,
119
+ this.motionUpdate]);
120
+ }
121
+ }
122
+ exports.SolaxCloudAPIPlatform = SolaxCloudAPIPlatform;
123
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @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,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC;SACpG;IACH,CAAC;IAED;;;OAGG;IACI,UAAU;QACf,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,OAAO,IAAI,CAAC,OAAO,CAAC;SACrB;aAAM;YACL,IAAI,CAAC,mBAAmB,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;gBACnC,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;YAC3B,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,QAAuD;QACjE,QAAQ,CAAC,CAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,gBAAgB;YAC7C,IAAI,CAAC,oBAAoB,EAAE,IAAI,CAAC,qBAAqB,EAAE,IAAI,CAAC,iBAAiB;YAC7E,IAAI,CAAC,YAAY,CAAE,CAAC,CAAC;IACzB,CAAC;CACF;AA9ID,sDA8IC"}
@@ -0,0 +1,38 @@
1
+ import { Service, AccessoryPlugin, Logging } from 'homebridge';
2
+ import { SolaxCloudAPIPlatform } from './platform';
3
+ /**
4
+ * Platform Accessory.
5
+ * An instance of this class is created for each accessory your platform registers
6
+ * Each accessory may expose multiple services of different service types.
7
+ */
8
+ export declare class SolaxPlatformAccessory implements AccessoryPlugin {
9
+ protected readonly platform: SolaxCloudAPIPlatform;
10
+ protected readonly log: Logging;
11
+ protected readonly name: string;
12
+ protected readonly informationService: Service;
13
+ protected model: string;
14
+ protected serial: string;
15
+ constructor(platform: SolaxCloudAPIPlatform, log: Logging, name: string);
16
+ /**
17
+ * Handle requests to get the current value of the "Model" characteristic.
18
+ * @returns {string} The model.
19
+ */
20
+ getModel(): string;
21
+ /**
22
+ * Sets the model string for Model characteristic.
23
+ * @param {string} model Model to set.
24
+ */
25
+ setModel(model: string): void;
26
+ /**
27
+ * Handle requests to get the current value of the "SerialNumber" characteristic.
28
+ * @returns {string} The inverter serial number.
29
+ */
30
+ getSerial(): string;
31
+ /**
32
+ * Sets model serial information for this outlet.
33
+ * @param {string} serial Serial number to set.
34
+ */
35
+ setSerial(serial: string): void;
36
+ getServices(): Service[];
37
+ }
38
+ //# sourceMappingURL=platformAccessory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platformAccessory.d.ts","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;GAIG;AACH,qBAAa,sBAAuB,YAAW,eAAe;IAC5D,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IACnD,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IAChC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEhC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;IAE/C,SAAS,CAAC,KAAK,SAAoB;IACnC,SAAS,CAAC,MAAM,SAAoB;gBAExB,QAAQ,EAAE,qBAAqB,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM;IAqBvE;;;OAGG;IACI,QAAQ,IAAI,MAAM;IAMzB;;;OAGG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM;IAM7B;;;OAGG;IACI,SAAS,IAAI,MAAM;IAM1B;;;OAGG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM;IAU/B,WAAW,IAAI,OAAO,EAAE;CAMzB"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SolaxPlatformAccessory = void 0;
4
+ /**
5
+ * Platform Accessory.
6
+ * An instance of this class is created for each accessory your platform registers
7
+ * Each accessory may expose multiple services of different service types.
8
+ */
9
+ class SolaxPlatformAccessory {
10
+ constructor(platform, log, name) {
11
+ this.model = 'Solax inverter';
12
+ this.serial = 'Default serial';
13
+ this.platform = platform;
14
+ this.log = log;
15
+ this.name = name;
16
+ const hap = this.platform.api.hap;
17
+ this.log.debug(`Creating outlet "${this.name}"`);
18
+ // information service
19
+ this.informationService =
20
+ new hap.Service.AccessoryInformation()
21
+ .setCharacteristic(hap.Characteristic.Name, this.name)
22
+ .setCharacteristic(hap.Characteristic.Manufacturer, 'Solax');
23
+ this.informationService.getCharacteristic(hap.Characteristic.SerialNumber).onGet(this.getSerial.bind(this));
24
+ this.informationService.getCharacteristic(hap.Characteristic.Model).onGet(this.getModel.bind(this));
25
+ log.info(`Outlet "${name}" created!`);
26
+ }
27
+ /**
28
+ * Handle requests to get the current value of the "Model" characteristic.
29
+ * @returns {string} The model.
30
+ */
31
+ getModel() {
32
+ this.log.debug(`${this.name}: GET Model (model=${this.model})`);
33
+ return this.model;
34
+ }
35
+ /**
36
+ * Sets the model string for Model characteristic.
37
+ * @param {string} model Model to set.
38
+ */
39
+ setModel(model) {
40
+ this.log.debug(`${this.name}: SET Model (model=${model})`);
41
+ this.model = model;
42
+ }
43
+ /**
44
+ * Handle requests to get the current value of the "SerialNumber" characteristic.
45
+ * @returns {string} The inverter serial number.
46
+ */
47
+ getSerial() {
48
+ this.log.debug(`${this.name}: GET Serial (serial=${this.serial})`);
49
+ return this.serial;
50
+ }
51
+ /**
52
+ * Sets model serial information for this outlet.
53
+ * @param {string} serial Serial number to set.
54
+ */
55
+ setSerial(serial) {
56
+ this.log.debug(`${this.name}: SET Serial (serial=${serial})`);
57
+ this.serial = serial;
58
+ }
59
+ /*
60
+ * This method is called directly after creation of this instance.
61
+ * It should return all services which should be added to the accessory.
62
+ */
63
+ getServices() {
64
+ return [
65
+ this.informationService,
66
+ ];
67
+ }
68
+ }
69
+ exports.SolaxPlatformAccessory = SolaxPlatformAccessory;
70
+ //# sourceMappingURL=platformAccessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platformAccessory.js","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":";;;AAIA;;;;GAIG;AACH,MAAa,sBAAsB;IAUjC,YAAY,QAA+B,EAAE,GAAY,EAAE,IAAY;QAH7D,UAAK,GAAG,gBAAgB,CAAC;QACzB,WAAM,GAAG,gBAAgB,CAAC;QAGlC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;QAElC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,oBAAoB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAEjD,sBAAsB;QACtB,IAAI,CAAC,kBAAkB;YACrB,IAAI,GAAG,CAAC,OAAO,CAAC,oBAAoB,EAAE;iBACnC,iBAAiB,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;iBACrD,iBAAiB,CAAC,GAAG,CAAC,cAAc,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAEjE,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5G,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEpG,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,YAAY,CAAC,CAAC;IACxC,CAAC;IAED;;;OAGG;IACI,QAAQ;QACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,sBAAsB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QAEhE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;OAGG;IACI,QAAQ,CAAC,KAAa;QAC3B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,sBAAsB,KAAK,GAAG,CAAC,CAAC;QAE3D,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;;OAGG;IACI,SAAS;QACd,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,wBAAwB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAEnE,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;OAGG;IACI,SAAS,CAAC,MAAc;QAC7B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,wBAAwB,MAAM,GAAG,CAAC,CAAC;QAE9D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO;YACL,IAAI,CAAC,kBAAkB;SACxB,CAAC;IACJ,CAAC;CAEF;AAjFD,wDAiFC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * This Source Code Form is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ */
6
+ export interface RequestOptions {
7
+ ignoreCache?: boolean;
8
+ headers?: {
9
+ [key: string]: string;
10
+ };
11
+ timeout?: number;
12
+ }
13
+ export declare const DEFAULT_REQUEST_OPTIONS: {
14
+ ignoreCache: boolean;
15
+ headers: {
16
+ Accept: string;
17
+ };
18
+ timeout: number;
19
+ };
20
+ export interface RequestResult {
21
+ ok: boolean;
22
+ status: number;
23
+ statusText: string;
24
+ data: string;
25
+ json: <T>() => T;
26
+ headers: string;
27
+ }
28
+ export declare function request(method: 'get' | 'post', url: string, queryParams?: object, body?: unknown, options?: RequestOptions): Promise<RequestResult>;
29
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAE,MAAM,CAAA;KAAC,CAAC;IAEjC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAEH,eAAO,MAAM,uBAAuB;;;;;;CAOnC,CAAC;AAEF,MAAM,WAAW,aAAa;IAC1B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAmCH,wBAAgB,OAAO,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,EAC5C,GAAG,EAAE,MAAM,EACX,WAAW,GAAE,MAAW,EACxB,IAAI,GAAE,OAAc,EACpB,OAAO,GAAE,cAAwC,0BAuClD"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.request = exports.DEFAULT_REQUEST_OPTIONS = void 0;
4
+ const xmlhttprequest_1 = require("xmlhttprequest");
5
+ exports.DEFAULT_REQUEST_OPTIONS = {
6
+ ignoreCache: false,
7
+ headers: {
8
+ Accept: 'application/json, text/javascript, text/plain',
9
+ },
10
+ // default max duration for a request
11
+ timeout: 5000,
12
+ };
13
+ function queryParams(params = {}) {
14
+ return Object.keys(params)
15
+ .map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k]))
16
+ .join('&');
17
+ }
18
+ function withQuery(url, params = {}) {
19
+ const queryString = queryParams(params);
20
+ return queryString ? url + (url.indexOf('?') === -1 ? '?' : '&') + queryString : url;
21
+ }
22
+ function parseXHRResult(xhr) {
23
+ return {
24
+ ok: xhr.status >= 200 && xhr.status < 300,
25
+ status: xhr.status,
26
+ statusText: xhr.statusText,
27
+ headers: xhr.getAllResponseHeaders(),
28
+ data: xhr.responseText,
29
+ json: () => JSON.parse(xhr.responseText),
30
+ };
31
+ }
32
+ function errorResponse(xhr, message = null) {
33
+ return {
34
+ ok: false,
35
+ status: xhr.status,
36
+ statusText: xhr.statusText,
37
+ headers: xhr.getAllResponseHeaders(),
38
+ data: message || xhr.statusText,
39
+ json: () => JSON.parse(message || xhr.statusText),
40
+ };
41
+ }
42
+ function request(method, url, queryParams = {}, body = null, options = exports.DEFAULT_REQUEST_OPTIONS) {
43
+ const ignoreCache = options.ignoreCache || exports.DEFAULT_REQUEST_OPTIONS.ignoreCache;
44
+ const headers = options.headers || exports.DEFAULT_REQUEST_OPTIONS.headers;
45
+ const timeout = options.timeout || exports.DEFAULT_REQUEST_OPTIONS.timeout;
46
+ return new Promise((resolve) => {
47
+ const xhr = new xmlhttprequest_1.XMLHttpRequest();
48
+ xhr.open(method, withQuery(url, queryParams));
49
+ if (headers) {
50
+ Object.keys(headers).forEach(key => xhr.setRequestHeader(key, headers[key]));
51
+ }
52
+ if (ignoreCache) {
53
+ xhr.setRequestHeader('Cache-Control', 'no-cache');
54
+ }
55
+ xhr.timeout = timeout;
56
+ xhr.onload = () => {
57
+ resolve(parseXHRResult(xhr));
58
+ };
59
+ xhr.onerror = () => {
60
+ resolve(errorResponse(xhr, 'Failed to make request.'));
61
+ };
62
+ xhr.ontimeout = () => {
63
+ resolve(errorResponse(xhr, 'Request took longer than expected.'));
64
+ };
65
+ if (method === 'post' && body) {
66
+ xhr.setRequestHeader('Content-Type', 'application/json');
67
+ xhr.send(JSON.stringify(body));
68
+ }
69
+ else {
70
+ xhr.send();
71
+ }
72
+ });
73
+ }
74
+ exports.request = request;
75
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAcnC,QAAA,uBAAuB,GAAG;IACrC,WAAW,EAAE,KAAK;IAClB,OAAO,EAAE;QACP,MAAM,EAAE,+CAA+C;KACxD;IACD,qCAAqC;IACrC,OAAO,EAAE,IAAI;CACd,CAAC;AAWF,SAAS,WAAW,CAAC,SAAiB,EAAE;IACtC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;SACvB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SACrE,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,SAAS,SAAS,CAAC,GAAW,EAAE,SAAiB,EAAE;IACjD,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,OAAO,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC;AACvF,CAAC;AAED,SAAS,cAAc,CAAC,GAAmB;IACzC,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG;QACzC,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,OAAO,EAAE,GAAG,CAAC,qBAAqB,EAAE;QACpC,IAAI,EAAE,GAAG,CAAC,YAAY;QACtB,IAAI,EAAE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B,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;SACnD;QAED,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QAEtB,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE;YAChB,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/B,CAAC,CAAC;QAEF,GAAG,CAAC,OAAO,GAAG,GAAG,EAAE;YACjB,OAAO,CAAC,aAAa,CAAC,GAAG,EAAE,yBAAyB,CAAC,CAAC,CAAC;QACzD,CAAC,CAAC;QAEF,GAAG,CAAC,SAAS,GAAG,GAAG,EAAE;YACnB,OAAO,CAAC,aAAa,CAAC,GAAG,EAAE,oCAAoC,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC;QAEF,IAAI,MAAM,KAAK,MAAM,IAAI,IAAI,EAAE;YAC7B,GAAG,CAAC,gBAAgB,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;YACzD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;SAChC;aAAM;YACL,GAAG,CAAC,IAAI,EAAE,CAAC;SACZ;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AA3CD,0BA2CC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This is the name of the platform that users will use to register the plugin in the Homebridge config.json
3
+ */
4
+ export declare const PLATFORM_NAME = "SolaxCloudAPI";
5
+ /**
6
+ * This must match the name of your plugin as defined the package.json
7
+ */
8
+ export declare const PLUGIN_NAME = "homebridge-solaxcloud-api";
9
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,WAAW,8BAA8B,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLUGIN_NAME = exports.PLATFORM_NAME = void 0;
4
+ /**
5
+ * This is the name of the platform that users will use to register the plugin in the Homebridge config.json
6
+ */
7
+ exports.PLATFORM_NAME = 'SolaxCloudAPI';
8
+ /**
9
+ * This must match the name of your plugin as defined the package.json
10
+ */
11
+ exports.PLUGIN_NAME = 'homebridge-solaxcloud-api';
12
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,aAAa,GAAG,eAAe,CAAC;AAE7C;;GAEG;AACU,QAAA,WAAW,GAAG,2BAA2B,CAAC"}
@@ -0,0 +1,125 @@
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
+ uploadTime: string;
36
+ batPower: number;
37
+ powerdc1: number | null;
38
+ powerdc2: number | null;
39
+ powerdc3: number | null;
40
+ powerdc4: number | null;
41
+ }
42
+ /**
43
+ * SolaxCloudAPIResponse interface for responses from Solax Cloud API.
44
+ */
45
+ export interface SolaxCloudAPIResponse {
46
+ /** Response from server */
47
+ exception: string;
48
+ /** Data returned */
49
+ result: SolaxCloudAPIResult;
50
+ /** Whether the data request was successful */
51
+ success: boolean;
52
+ }
53
+ /**
54
+ * Main class to retrieve data from Solax API.
55
+ */
56
+ export declare class SolaxCloudAPI {
57
+ readonly tokenId: string;
58
+ readonly sn: string;
59
+ /**
60
+ * Class constructor.
61
+ * @param tokenId Token ID to gather data from Solax Cloud API.
62
+ * @param sn Unique identifier of inverter (Serial No).
63
+ */
64
+ constructor(tokenId: string, sn: string);
65
+ /**
66
+ * Gets the inverter type description from the corresponding type code.
67
+ * @param {string} typeCode The Solax inverter type code.
68
+ * @returns Corresponding inverter type description.
69
+ */
70
+ static getInverterType(typeCode: string): string;
71
+ /**
72
+ * Gets the inverter status description from the corresponding status code.
73
+ * @param {string} statusCode The inverter status code.
74
+ * @returns Corresponding inverter status description.
75
+ */
76
+ static getInverterStatus(statusCode: string): string;
77
+ /**
78
+ * Gets the inverter fed photovoltaic DC power (in W) from the retrieved API results.
79
+ * @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
80
+ * @returns {number} The measured inverter photovoltaic input DC power (in W).
81
+ */
82
+ static getPVPower(data: SolaxCloudAPIResult): number;
83
+ /**
84
+ * Gets the inverter output AC power (in W) from the retrieved API results.
85
+ * @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
86
+ * @returns {number} The measured inverter output AC power (in W).
87
+ */
88
+ static getInverterACPower(data: SolaxCloudAPIResult): number;
89
+ /**
90
+ * Gets the Inverter AC energy out for today (KWh) from the retrieved API results.
91
+ * @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
92
+ * @returns {number} The AC energy output by the inverter today (in KWh).
93
+ */
94
+ static getYieldToday(data: SolaxCloudAPIResult): number;
95
+ /**
96
+ * Gets the Inverter AC energy out total (KWh) from the retrieved API results.
97
+ * @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
98
+ * @returns {number} The total AC energy output by the inverter (in KWh).
99
+ */
100
+ static getYieldTotal(data: SolaxCloudAPIResult): number;
101
+ /**
102
+ * Gets the power currently being fed to the grid by the inverter (in W).
103
+ * @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
104
+ * @returns The power currently being sent to the grid (in W).
105
+ */
106
+ static getInverterPowerToGrid(data: SolaxCloudAPIResult): number;
107
+ /**
108
+ * Gets the power currently being drawn from the grid to the house (in W).
109
+ * @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
110
+ * @returns The power currently being drawn from the grid to the house (in W).
111
+ */
112
+ static getGridPowerToHouse(data: SolaxCloudAPIResult): number;
113
+ /**
114
+ * Gets the power currently being generated by the inverter to the house (in W).
115
+ * @param {SolaxCloudAPIResult} data The result data retrieved from the Solax Cloud API.
116
+ * @returns The power currently being generated by the inverter to the house (in W).
117
+ */
118
+ static getInverterPowerToHouse(data: SolaxCloudAPIResult): number;
119
+ /**
120
+ * Retrieves inverter data using Solax Cloud "real-time" API.
121
+ * @returns {SolaxCloudAPIResponse} The response by Solax Cloud API.
122
+ */
123
+ getAPIData(): Promise<SolaxCloudAPIResponse>;
124
+ }
125
+ //# sourceMappingURL=solaxcloudapi.d.ts.map
@@ -0,0 +1 @@
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,0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