homebridge-solaxcloud-api 1.2.1 → 1.4.1-beta.1
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/README.md +23 -20
- package/config.sample +1 -1
- package/config.schema.json +7 -4
- package/dist/motionAccessory.d.ts +10 -6
- package/dist/motionAccessory.d.ts.map +1 -1
- package/dist/motionAccessory.js +14 -8
- package/dist/motionAccessory.js.map +1 -1
- package/dist/outletAccessory.d.ts +24 -4
- package/dist/outletAccessory.d.ts.map +1 -1
- package/dist/outletAccessory.js +48 -14
- package/dist/outletAccessory.js.map +1 -1
- package/dist/platform.d.ts +24 -10
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +37 -37
- package/dist/platform.js.map +1 -1
- package/dist/platformAccessory.d.ts +8 -8
- package/dist/platformAccessory.d.ts.map +1 -1
- package/dist/platformAccessory.js +14 -10
- package/dist/platformAccessory.js.map +1 -1
- package/dist/solaxcloudapi.d.ts +1 -1
- package/dist/solaxcloudapi.d.ts.map +1 -1
- package/dist/solaxcloudapi.js +15 -5
- package/dist/solaxcloudapi.js.map +1 -1
- package/dist/statistics.js +8 -9
- package/dist/statistics.js.map +1 -1
- package/images/plugin-accessories-eve.png +0 -0
- package/images/plugin-outlet-consumption.png +0 -0
- package/package.json +5 -4
- package/dist/request.d.ts +0 -29
- package/dist/request.d.ts.map +0 -1
- package/dist/request.js +0 -75
- package/dist/request.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
<img src="https://github.com/homebridge/branding/raw/master/logos/homebridge-wordmark-logo-vertical.png" width="150">
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
<table>
|
|
3
|
+
<tr>
|
|
4
|
+
<td align="center"><img src="https://github.com/homebridge/branding/raw/master/logos/homebridge-wordmark-logo-vertical.png" width="150"></td>
|
|
5
|
+
<td align="center"><img src="https://www.solaxpower.com/wp-content/uploads/2020/03/weblogo5.png" width="300"></td>
|
|
6
|
+
<tr>
|
|
7
|
+
</table>
|
|
8
8
|
|
|
9
9
|
# Solax Cloud Plugin for Homebridge
|
|
10
10
|
|
|
11
11
|
 
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
The Solax Cloud Plugin for [Homebridge](https://homebridge.io/) was created as a platform plugin to gather data exposed by Solax inverters to the cloud through the [Solax Cloud API](https://www.eu.solaxcloud.com/phoebus/resource/files/userGuide/Solax_API_for_End-user_V1.0.pdf).
|
|
15
15
|
|
|
16
|
-
HomeKit is still clueless about what a solar panel is
|
|
16
|
+
As HomeKit is still clueless about what a solar panel is, this plugin exposes a set of standard HomeKit accessories though Homebridge that will allow interacting and automating your smart home based on the data made available from the Solax platform:
|
|
17
17
|
|
|
18
|
-
- Inverter PV (outlet with power consumption)
|
|
19
|
-
- Inverter AC (outlet with power
|
|
20
|
-
- Inverter to Grid (outlet with power consumption)
|
|
21
|
-
- Inverter to House (outlet with power consumption)
|
|
22
|
-
- Grid To House (outlet with power consumption)
|
|
23
|
-
- Update (Motion sensor)
|
|
18
|
+
- **Inverter PV** (outlet with power consumption)
|
|
19
|
+
- **Inverter AC** (outlet with power and total energy consumptions)
|
|
20
|
+
- **Inverter to Grid** (outlet with power consumption)
|
|
21
|
+
- **Inverter to House** (outlet with power consumption)
|
|
22
|
+
- **Grid To House** (outlet with power consumption)
|
|
23
|
+
- **Update** (Motion sensor)
|
|
24
24
|
|
|
25
25
|

|
|
26
26
|
|
|
@@ -57,7 +57,9 @@ Minimum platform configuration is depicted by the example configuration file bel
|
|
|
57
57
|
]
|
|
58
58
|
}
|
|
59
59
|
```
|
|
60
|
-
|
|
60
|
+
**NOTE:** The `pollingFrequency` parameter is optional and defaults to 300 seconds, since Solax inverters update cloud data every 5 minutes.
|
|
61
|
+
|
|
62
|
+
Configuration through the the use of [Homebridge UI](https://github.com/oznu/homebridge-config-ui-x) plugin is also available and recommended:
|
|
61
63
|
|
|
62
64
|

|
|
63
65
|
|
|
@@ -65,17 +67,17 @@ Configuration through the the use of Homebridge UI plugin is also available:
|
|
|
65
67
|
|
|
66
68
|
Non-standard accessory characteristics are available through the use of [Eve for HomeKit app](https://apps.apple.com/us/app/eve-for-homekit/id917695792) you may download from the App Store.
|
|
67
69
|
|
|
68
|
-
This will allow some important non-standard characteristics to be visible (like consumption), as depicted in the image below:
|
|
70
|
+
This will allow some important non-standard characteristics to be visible (like power or total energy consumption), as depicted in the image below:
|
|
69
71
|
|
|
70
72
|

|
|
71
73
|
|
|
72
74
|
# Automation
|
|
73
75
|
|
|
74
|
-
Automation can be
|
|
76
|
+
Automation can be achieved with the help of the virtual "Update" motion sensor that was specifically tailored for this effect. This motion sensor will be triggered whenever data gets updated from the Solax Cloud API (according to what is defined on the `pollingFrequency` configuration setting).
|
|
75
77
|
|
|
76
78
|

|
|
77
79
|
|
|
78
|
-
|
|
80
|
+
Motion is detected by the **Update** motion sensor whenever there is newly fetched data from Solax Cloud. Using this sensor as a trigger combined with power and energy data from the virtual outlets enumerated above forms the basic building blocks for defining an automation.
|
|
79
81
|
|
|
80
82
|
## Automation example
|
|
81
83
|
|
|
@@ -85,5 +87,6 @@ As an automation example...
|
|
|
85
87
|
|
|
86
88
|
Next planned plugin releases should include:
|
|
87
89
|
|
|
88
|
-
- Inverter AC
|
|
89
|
-
-
|
|
90
|
+
- [X] **Inverter AC** to include Yield Energy
|
|
91
|
+
- [ ] Consumption history through the [fakegato-history](https://github.com/simont77/fakegato-history) module
|
|
92
|
+
- [ ] Accessories for battery state and consumptions (do not have one available)
|
package/config.sample
CHANGED
package/config.schema.json
CHANGED
|
@@ -37,10 +37,13 @@
|
|
|
37
37
|
"title": "Polling frequency (seconds)",
|
|
38
38
|
"type": "integer",
|
|
39
39
|
"required": false,
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
"default": 300,
|
|
41
|
+
"oneOf": [
|
|
42
|
+
{ "title": "300 (5 minutes)", "enum": [ 300 ] },
|
|
43
|
+
{ "title": "600 (10 minutes)", "enum": [ 600 ] },
|
|
44
|
+
{ "title": "900 (15 minutes)", "enum": [ 900 ] }
|
|
45
|
+
],
|
|
46
|
+
"description": "Plugin data polling frequency from Solax Cloud in seconds."
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
}
|
|
@@ -3,17 +3,21 @@ import { Service, AccessoryPlugin, Logging, CharacteristicGetCallback } from 'ho
|
|
|
3
3
|
import { SolaxCloudAPIPlatform } from './platform';
|
|
4
4
|
import { SolaxPlatformAccessory } from './platformAccessory';
|
|
5
5
|
/**
|
|
6
|
-
* Solax Motion Accessory
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Solax Motion Accessory.
|
|
7
|
+
* Virtual motion sensor triggered whenever new data is fetched from Solax Cloud.
|
|
8
|
+
* Sensor will automatically clear itself after MOTION_TIMEOUT seconds (5 seconds).
|
|
9
9
|
*/
|
|
10
10
|
export declare class SolaxMotionAccessory extends SolaxPlatformAccessory implements AccessoryPlugin {
|
|
11
11
|
private readonly motionService;
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Whether motion is detected (Solax Cloud data updated).
|
|
14
|
+
*/
|
|
13
15
|
private motion;
|
|
14
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Update interval to turn motion back off (in seconds).
|
|
18
|
+
*/
|
|
15
19
|
private motionTimeout;
|
|
16
|
-
constructor(platform: SolaxCloudAPIPlatform, log: Logging, name: string);
|
|
20
|
+
constructor(platform: SolaxCloudAPIPlatform, log: Logging, name: string, serial: string);
|
|
17
21
|
sleep: typeof import("timers/promises").setTimeout;
|
|
18
22
|
/**
|
|
19
23
|
* Gets the motion sensor state Characteristic.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motionAccessory.d.ts","sourceRoot":"","sources":["../src/motionAccessory.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAI1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"motionAccessory.d.ts","sourceRoot":"","sources":["../src/motionAccessory.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAI1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAO7D;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,sBAAuB,YAAW,eAAe;IAEzF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAU;IAExC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAS;IAEvB;;OAEG;IACH,OAAO,CAAC,aAAa,CAA0B;gBAEnC,QAAQ,EAAE,qBAAqB,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAevF,KAAK,8CAA8B;IAEnC;;;OAGG;IACI,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI;IAM1D;;;OAGG;IACI,QAAQ,CAAC,MAAM,EAAE,OAAO;IAmB/B,WAAW,IAAI,OAAO,EAAE;CAOzB"}
|
package/dist/motionAccessory.js
CHANGED
|
@@ -6,19 +6,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.SolaxMotionAccessory = void 0;
|
|
7
7
|
const util_1 = __importDefault(require("util"));
|
|
8
8
|
const platformAccessory_1 = require("./platformAccessory");
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Motion timeout in seconds.
|
|
11
|
+
*/
|
|
10
12
|
const MOTION_TIMEOUT = 5;
|
|
11
13
|
/**
|
|
12
|
-
* Solax Motion Accessory
|
|
13
|
-
*
|
|
14
|
-
*
|
|
14
|
+
* Solax Motion Accessory.
|
|
15
|
+
* Virtual motion sensor triggered whenever new data is fetched from Solax Cloud.
|
|
16
|
+
* Sensor will automatically clear itself after MOTION_TIMEOUT seconds (5 seconds).
|
|
15
17
|
*/
|
|
16
18
|
class SolaxMotionAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
17
|
-
constructor(platform, log, name) {
|
|
18
|
-
super(platform, log, name);
|
|
19
|
-
/**
|
|
19
|
+
constructor(platform, log, name, serial) {
|
|
20
|
+
super(platform, log, name, serial);
|
|
21
|
+
/**
|
|
22
|
+
* Whether motion is detected (Solax Cloud data updated).
|
|
23
|
+
*/
|
|
20
24
|
this.motion = false;
|
|
21
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Update interval to turn motion back off (in seconds).
|
|
27
|
+
*/
|
|
22
28
|
this.motionTimeout = MOTION_TIMEOUT;
|
|
23
29
|
this.sleep = util_1.default.promisify(setTimeout);
|
|
24
30
|
const hap = this.platform.api.hap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motionAccessory.js","sourceRoot":"","sources":["../src/motionAccessory.ts"],"names":[],"mappings":";;;;;;AAEA,gDAAwB;AAGxB,2DAA6D;AAE7D
|
|
1
|
+
{"version":3,"file":"motionAccessory.js","sourceRoot":"","sources":["../src/motionAccessory.ts"],"names":[],"mappings":";;;;;;AAEA,gDAAwB;AAGxB,2DAA6D;AAE7D;;GAEG;AACH,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB;;;;GAIG;AACH,MAAa,oBAAqB,SAAQ,0CAAsB;IAc9D,YAAY,QAA+B,EAAE,GAAY,EAAE,IAAY,EAAE,MAAc;QACrF,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAXrC;;WAEG;QACK,WAAM,GAAG,KAAK,CAAC;QAEvB;;WAEG;QACK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AI,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;SACxE;IACH,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO;YACL,IAAI,CAAC,kBAAkB;YACvB,IAAI,CAAC,aAAa;SACnB,CAAC;IACJ,CAAC;CAEF;AAvED,oDAuEC"}
|
|
@@ -3,15 +3,27 @@ import { SolaxCloudAPIPlatform } from './platform';
|
|
|
3
3
|
import { SolaxPlatformAccessory } from './platformAccessory';
|
|
4
4
|
/**
|
|
5
5
|
* Solax Outlet Accessory.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Virtual outlet used to monitor and measure both power and total energy consumption from Solax devices.
|
|
7
|
+
* Outlet use is inferred from a positive power comsumption.
|
|
8
8
|
*/
|
|
9
9
|
export declare class SolaxOutletAccessory extends SolaxPlatformAccessory implements AccessoryPlugin {
|
|
10
|
+
/**
|
|
11
|
+
* Outlet service with power meter.
|
|
12
|
+
*/
|
|
10
13
|
private readonly outletService;
|
|
14
|
+
/**
|
|
15
|
+
* Current power reading in Watt.
|
|
16
|
+
*/
|
|
11
17
|
private powerConsumption;
|
|
12
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Total energy readings in KWh.
|
|
20
|
+
*/
|
|
13
21
|
private totalEnergyConsumption;
|
|
14
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Elgato Eve fake history service for energy and status.
|
|
24
|
+
*/
|
|
25
|
+
private readonly loggingService;
|
|
26
|
+
constructor(platform: SolaxCloudAPIPlatform, log: Logging, name: string, serial: string);
|
|
15
27
|
/**
|
|
16
28
|
* Sets a characteristic value for a sepecific characteristic.
|
|
17
29
|
* @param {string} charName The characteristic name.
|
|
@@ -26,6 +38,14 @@ export declare class SolaxOutletAccessory extends SolaxPlatformAccessory impleme
|
|
|
26
38
|
* Sets the current power consumption.
|
|
27
39
|
* @param {number} powerConsumption The power consumption to set. */
|
|
28
40
|
setPowerConsumption(powerConsumption: number): void;
|
|
41
|
+
/**
|
|
42
|
+
* Gets the total energy consumpion.
|
|
43
|
+
*/
|
|
44
|
+
getTotalEnergyConsumption(callback: CharacteristicGetCallback): void;
|
|
45
|
+
/**
|
|
46
|
+
* Sets the total energy consumption.
|
|
47
|
+
* @param {number} totalEnergyConsumption The total energy consumption to set. */
|
|
48
|
+
setTotalEnergyConsumption(totalEnergyConsumption: number): void;
|
|
29
49
|
/**
|
|
30
50
|
* Gets the outlet state Characteristic based on its consumed power.
|
|
31
51
|
* @param {CharacteristicGetCallback} callback The callback.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outletAccessory.d.ts","sourceRoot":"","sources":["../src/outletAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,yBAAyB,EAAkB,MAAM,YAAY,CAAC;AAE1G,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"outletAccessory.d.ts","sourceRoot":"","sources":["../src/outletAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,yBAAyB,EAAkB,MAAM,YAAY,CAAC;AAE1G,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAI7D;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,sBAAuB,YAAW,eAAe;IAEzF;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAU;IAExC;;OAEG;IACH,OAAO,CAAC,gBAAgB,CAAK;IAE7B;;OAEG;IACH,OAAO,CAAC,sBAAsB,CAAO;IAErC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAyB;gBAI5C,QAAQ,EAAE,qBAAqB,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAmCvF;;;;OAIG;IACI,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAS7D;;OAEG;IACI,mBAAmB,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI;IAMrE;;wEAEoE;IAC7D,mBAAmB,CAAC,gBAAgB,EAAE,MAAM;IAYnD;;OAEG;IACI,yBAAyB,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI;IAQ3E;;qFAEiF;IAC1E,yBAAyB,CAAC,sBAAsB,EAAE,MAAM;IAQ/D;;;OAGG;IACI,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI;IAU1D,WAAW,IAAI,OAAO,EAAE;CAQzB"}
|
package/dist/outletAccessory.js
CHANGED
|
@@ -4,26 +4,40 @@ exports.SolaxOutletAccessory = void 0;
|
|
|
4
4
|
const platformAccessory_1 = require("./platformAccessory");
|
|
5
5
|
/**
|
|
6
6
|
* Solax Outlet Accessory.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Virtual outlet used to monitor and measure both power and total energy consumption from Solax devices.
|
|
8
|
+
* Outlet use is inferred from a positive power comsumption.
|
|
9
9
|
*/
|
|
10
10
|
class SolaxOutletAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
//private services: Service[];
|
|
12
|
+
constructor(platform, log, name, serial) {
|
|
13
|
+
super(platform, log, name, serial);
|
|
14
|
+
/**
|
|
15
|
+
* Current power reading in Watt.
|
|
16
|
+
*/
|
|
14
17
|
this.powerConsumption = 0;
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Total energy readings in KWh.
|
|
20
|
+
*/
|
|
17
21
|
this.totalEnergyConsumption = 0.0;
|
|
18
22
|
const hap = this.platform.api.hap;
|
|
19
23
|
this.log.debug(`Creating outlet "${this.name}"`);
|
|
20
|
-
//
|
|
21
|
-
this.outletService = new
|
|
24
|
+
// create power meter service
|
|
25
|
+
this.outletService = new this.platform.eve.Services.Outlet(this.name);
|
|
22
26
|
// outlet on/off state
|
|
23
|
-
this.outletService.getCharacteristic(hap.Characteristic.On).
|
|
24
|
-
|
|
27
|
+
this.outletService.getCharacteristic(hap.Characteristic.On).on("get" /* GET */, this.getState.bind(this));
|
|
28
|
+
// in use
|
|
29
|
+
//this.outletService.getCharacteristic(hap.Characteristic.OutletInUse).on(hap.CharacteristicEventTypes.GET, this.getState.bind(this));
|
|
25
30
|
// current consumption
|
|
26
|
-
this.outletService.
|
|
31
|
+
this.outletService.getCharacteristic(this.platform.eve.Characteristics.CurrentConsumption)
|
|
32
|
+
.on("get" /* GET */, this.getPowerConsumption.bind(this));
|
|
33
|
+
// total consumption
|
|
34
|
+
this.outletService.getCharacteristic(this.platform.eve.Characteristics.TotalConsumption)
|
|
35
|
+
.on("get" /* GET */, this.getTotalEnergyConsumption.bind(this));
|
|
36
|
+
// reset
|
|
37
|
+
//this.powerMeterService.addOptionalCharacteristic(this.platform.eve.Characteristics.ResetTotal);
|
|
38
|
+
// history logging services
|
|
39
|
+
this.loggingService = new this.platform.eveService('energy', this, { storage: 'fs' });
|
|
40
|
+
//this.services.push(this.loggingService);
|
|
27
41
|
log.info(`Outlet "${name}" created!`);
|
|
28
42
|
}
|
|
29
43
|
/**
|
|
@@ -35,7 +49,7 @@ class SolaxOutletAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
|
35
49
|
// set up characteristic
|
|
36
50
|
const char = this.outletService.getCharacteristic(charName);
|
|
37
51
|
if (char) {
|
|
38
|
-
char.
|
|
52
|
+
char.updateValue(value);
|
|
39
53
|
}
|
|
40
54
|
}
|
|
41
55
|
/**
|
|
@@ -50,8 +64,27 @@ class SolaxOutletAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
|
50
64
|
* @param {number} powerConsumption The power consumption to set. */
|
|
51
65
|
setPowerConsumption(powerConsumption) {
|
|
52
66
|
this.log.debug(`${this.name}: SET Power (power=${powerConsumption}W)`);
|
|
53
|
-
this.powerConsumption = powerConsumption;
|
|
67
|
+
this.powerConsumption = powerConsumption >= 0 ? powerConsumption : 0;
|
|
54
68
|
this.setCharacteristicValue(this.platform.eve.Characteristics.CurrentConsumption, this.powerConsumption);
|
|
69
|
+
// add entries to history
|
|
70
|
+
this.loggingService.
|
|
71
|
+
addEntry({ time: Math.round(new Date().valueOf() / 1000), power: this.powerConsumption /*, status: this.powerConsumption > 0 */ });
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Gets the total energy consumpion.
|
|
75
|
+
*/
|
|
76
|
+
getTotalEnergyConsumption(callback) {
|
|
77
|
+
this.log.debug(`${this.name}: GET Total Energy (energy=${this.totalEnergyConsumption}kWh)`);
|
|
78
|
+
callback(null, this.totalEnergyConsumption);
|
|
79
|
+
//this.log.debug(JSON.stringify(this.energyHistoryService));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Sets the total energy consumption.
|
|
83
|
+
* @param {number} totalEnergyConsumption The total energy consumption to set. */
|
|
84
|
+
setTotalEnergyConsumption(totalEnergyConsumption) {
|
|
85
|
+
this.log.debug(`${this.name}: SET Total Energy (energy=${totalEnergyConsumption}kWh)`);
|
|
86
|
+
this.totalEnergyConsumption = totalEnergyConsumption;
|
|
87
|
+
this.setCharacteristicValue(this.platform.eve.Characteristics.TotalConsumption, this.totalEnergyConsumption);
|
|
55
88
|
}
|
|
56
89
|
/**
|
|
57
90
|
* Gets the outlet state Characteristic based on its consumed power.
|
|
@@ -69,6 +102,7 @@ class SolaxOutletAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
|
69
102
|
return [
|
|
70
103
|
this.informationService,
|
|
71
104
|
this.outletService,
|
|
105
|
+
this.loggingService,
|
|
72
106
|
];
|
|
73
107
|
}
|
|
74
108
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outletAccessory.js","sourceRoot":"","sources":["../src/outletAccessory.ts"],"names":[],"mappings":";;;AAGA,2DAA6D;
|
|
1
|
+
{"version":3,"file":"outletAccessory.js","sourceRoot":"","sources":["../src/outletAccessory.ts"],"names":[],"mappings":";;;AAGA,2DAA6D;AAI7D;;;;GAIG;AACH,MAAa,oBAAqB,SAAQ,0CAAsB;IAsB9D,8BAA8B;IAE9B,YAAY,QAA+B,EAAE,GAAY,EAAE,IAAY,EAAE,MAAc;QACrF,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAlBrC;;WAEG;QACK,qBAAgB,GAAG,CAAC,CAAC;QAE7B;;WAEG;QACK,2BAAsB,GAAG,GAAG,CAAC;QAYnC,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,6BAA6B;QAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEtE,sBAAsB;QACtB,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,kBAAmC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAE3H,SAAS;QACT,sIAAsI;QAEtI,sBAAsB;QACtB,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,kBAAkB,CAAC;aACvF,EAAE,kBAAmC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QA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AAI,CAAC,aAAa;YAClB,IAAI,CAAC,cAAc;SACpB,CAAC;IACJ,CAAC;CAEF;AA7ID,oDA6IC"}
|
package/dist/platform.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { AccessoryPlugin, API, StaticPlatformPlugin, Logging, PlatformConfig } from 'homebridge';
|
|
3
3
|
import { EveHomeKitTypes } from 'homebridge-lib';
|
|
4
|
-
import
|
|
4
|
+
import fakegato from 'fakegato-history';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* SolaxCloudAPIPlatform.
|
|
7
7
|
* This class is the main constructor for your plugin, this is where you should
|
|
8
8
|
* parse the user config and discover/register accessories with Homebridge.
|
|
9
9
|
*/
|
|
@@ -11,14 +11,33 @@ export declare class SolaxCloudAPIPlatform implements StaticPlatformPlugin {
|
|
|
11
11
|
private readonly log;
|
|
12
12
|
private readonly config;
|
|
13
13
|
readonly api: API;
|
|
14
|
-
eve: EveHomeKitTypes;
|
|
14
|
+
readonly eve: EveHomeKitTypes;
|
|
15
|
+
eveService: fakegato;
|
|
15
16
|
private readonly solaxCloudAPI;
|
|
16
|
-
apiData
|
|
17
|
+
private apiData;
|
|
18
|
+
/**
|
|
19
|
+
* Virtual outlet used to detect and measure photovoltaic production.
|
|
20
|
+
*/
|
|
17
21
|
private outletPV;
|
|
22
|
+
/**
|
|
23
|
+
* Virtual outlet used to detect and measure inverter AC production.
|
|
24
|
+
*/
|
|
18
25
|
private outletInverterAC;
|
|
26
|
+
/**
|
|
27
|
+
* Virtual outlet used to detect and measure inverter excess production injected in the grid.
|
|
28
|
+
*/
|
|
19
29
|
private outletInverterToGrid;
|
|
30
|
+
/**
|
|
31
|
+
* Virtual outlet used to detect and measure inverter production directly fed into the house (self-consumption).
|
|
32
|
+
*/
|
|
20
33
|
private outletInverterToHouse;
|
|
34
|
+
/**
|
|
35
|
+
* Virtual outlet used to detect and measure grid power fed into the house.
|
|
36
|
+
*/
|
|
21
37
|
private outletGridToHouse;
|
|
38
|
+
/**
|
|
39
|
+
* Virtual motion sensor triggered by data updates from Solax Cloud.
|
|
40
|
+
*/
|
|
22
41
|
private motionUpdate;
|
|
23
42
|
/**
|
|
24
43
|
* Platform constructor.
|
|
@@ -32,12 +51,7 @@ export declare class SolaxCloudAPIPlatform implements StaticPlatformPlugin {
|
|
|
32
51
|
/**
|
|
33
52
|
* Periodically retrieves inverter data from Solax Cloud API using configured tokenID and SN.
|
|
34
53
|
*/
|
|
35
|
-
private
|
|
36
|
-
/**
|
|
37
|
-
* Gets the latest API data available.
|
|
38
|
-
* @returns
|
|
39
|
-
*/
|
|
40
|
-
getAPIData(): SolaxCloudAPIResponse;
|
|
54
|
+
private fetchDataPeriodically;
|
|
41
55
|
accessories(callback: (foundAccessories: AccessoryPlugin[]) => void): void;
|
|
42
56
|
}
|
|
43
57
|
//# sourceMappingURL=platform.d.ts.map
|
package/dist/platform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,oBAAoB,EAAE,OAAO,EAAE,cAAc,EAAY,MAAM,YAAY,CAAC;AAE3G,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,oBAAoB,EAAE,OAAO,EAAE,cAAc,EAAY,MAAM,YAAY,CAAC;AAE3G,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AAcxC;;;;GAIG;AACH,qBAAa,qBAAsB,YAAW,oBAAoB;IAChE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAU;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,SAAgB,GAAG,EAAE,GAAG,CAAC;IAEzB,SAAgB,GAAG,EAAE,eAAe,CAAC;IAC9B,UAAU,EAAE,QAAQ,CAAC;IAE5B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAC/C,OAAO,CAAC,OAAO,CAAyB;IAExC;;MAEE;IACF,OAAO,CAAC,QAAQ,CAAwB;IAExC;;OAEG;IACH,OAAO,CAAC,gBAAgB,CAAwB;IAEhD;;OAEG;IACH,OAAO,CAAC,oBAAoB,CAAwB;IAEpD;;OAEG;IACH,OAAO,CAAC,qBAAqB,CAAwB;IAErD;;OAEG;IACH,OAAO,CAAC,iBAAiB,CAAwB;IAEjD;;OAEG;IACH,OAAO,CAAC,YAAY,CAAwB;IAE5C;;;;;;OAMG;gBACU,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,GAAG;IAwD3D,KAAK,8CAA8B;IAEnC;;OAEG;YACW,qBAAqB;IA+CnC,WAAW,CAAC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,eAAe,EAAE,KAAK,IAAI,GAAG,IAAI;CAK3E"}
|
package/dist/platform.js
CHANGED
|
@@ -5,12 +5,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SolaxCloudAPIPlatform = void 0;
|
|
7
7
|
const homebridge_lib_1 = require("homebridge-lib");
|
|
8
|
+
const fakegato_history_1 = __importDefault(require("fakegato-history"));
|
|
8
9
|
const outletAccessory_1 = require("./outletAccessory");
|
|
9
10
|
const util_1 = __importDefault(require("util"));
|
|
10
11
|
const solaxcloudapi_1 = require("./solaxcloudapi");
|
|
11
12
|
const motionAccessory_1 = require("./motionAccessory");
|
|
12
13
|
/**
|
|
13
|
-
*
|
|
14
|
+
* Default polling frequency from Solax Cloud (in seconds).
|
|
15
|
+
*/
|
|
16
|
+
const DEFAULT_POLLING_FREQUENCY = 300;
|
|
17
|
+
/**
|
|
18
|
+
* SolaxCloudAPIPlatform.
|
|
14
19
|
* This class is the main constructor for your plugin, this is where you should
|
|
15
20
|
* parse the user config and discover/register accessories with Homebridge.
|
|
16
21
|
*/
|
|
@@ -32,19 +37,33 @@ class SolaxCloudAPIPlatform {
|
|
|
32
37
|
if (!api || !config) {
|
|
33
38
|
return;
|
|
34
39
|
}
|
|
35
|
-
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
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`);
|
|
40
|
+
// setup default polling frequency
|
|
41
|
+
this.config.pollingFrequency = this.config.pollingFrequency || DEFAULT_POLLING_FREQUENCY;
|
|
42
|
+
this.eve = new homebridge_lib_1.EveHomeKitTypes(this.api);
|
|
43
|
+
this.eveService = (0, fakegato_history_1.default)(this.api);
|
|
44
|
+
this.log.debug(`Config: ${JSON.stringify(config)}`);
|
|
45
45
|
// init new Solax Cloud API object with give tokenID and sn
|
|
46
46
|
this.solaxCloudAPI = new solaxcloudapi_1.SolaxCloudAPI(this.config.tokenId, this.config.sn);
|
|
47
|
-
|
|
47
|
+
// initial data set
|
|
48
|
+
this.apiData = this.solaxCloudAPI.getAPIData();
|
|
49
|
+
this.log.debug(`apiData = ${JSON.stringify(this.apiData)}`);
|
|
50
|
+
const inverterSN = this.apiData.result.inverterSN.toLowerCase();
|
|
51
|
+
// setup outlet accessories
|
|
52
|
+
this.outletPV =
|
|
53
|
+
new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} PV`, `pv-${inverterSN}`);
|
|
54
|
+
this.outletInverterAC =
|
|
55
|
+
new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Inverter AC`, `inv-ac-${inverterSN}`);
|
|
56
|
+
this.outletInverterToGrid =
|
|
57
|
+
new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Inverter to Grid`, `inv-grid-${inverterSN}`);
|
|
58
|
+
this.outletInverterToHouse =
|
|
59
|
+
new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Inverter to House`, `inv-house-${inverterSN}`);
|
|
60
|
+
this.outletGridToHouse =
|
|
61
|
+
new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Grid to House`, `grid-house-${inverterSN}`);
|
|
62
|
+
// setup update motion sensor
|
|
63
|
+
this.motionUpdate =
|
|
64
|
+
new motionAccessory_1.SolaxMotionAccessory(this, this.log, `${this.config.name} Update`, `update-${inverterSN}`);
|
|
65
|
+
// start data fetching
|
|
66
|
+
this.fetchDataPeriodically();
|
|
48
67
|
this.log.debug('Finished initializing platform.'),
|
|
49
68
|
// When this event is fired it means Homebridge has created all accessories.
|
|
50
69
|
this.api.on("didFinishLaunching" /* DID_FINISH_LAUNCHING */, () => {
|
|
@@ -54,31 +73,26 @@ class SolaxCloudAPIPlatform {
|
|
|
54
73
|
/**
|
|
55
74
|
* Periodically retrieves inverter data from Solax Cloud API using configured tokenID and SN.
|
|
56
75
|
*/
|
|
57
|
-
async
|
|
76
|
+
async fetchDataPeriodically() {
|
|
58
77
|
try {
|
|
59
78
|
this.log.debug('Retrieving data from Solax Cloud API.');
|
|
60
|
-
this.apiData =
|
|
79
|
+
this.apiData = this.solaxCloudAPI.getAPIData();
|
|
61
80
|
if (this.apiData.success) {
|
|
62
81
|
this.log.debug(`Retrieved inverter status: ${JSON.stringify(this.apiData.result)}`);
|
|
63
82
|
// update outlets
|
|
64
83
|
this.outletPV.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getPVPower(this.apiData.result));
|
|
65
|
-
this.outletPV.setSerial(`pv-${this.apiData.result.inverterSN}`);
|
|
66
84
|
this.outletPV.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
|
|
67
85
|
this.outletInverterAC.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getInverterACPower(this.apiData.result));
|
|
68
|
-
this.outletInverterAC.
|
|
86
|
+
this.outletInverterAC.setTotalEnergyConsumption(solaxcloudapi_1.SolaxCloudAPI.getYieldTotal(this.apiData.result));
|
|
69
87
|
this.outletInverterAC.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
|
|
70
88
|
this.outletInverterToGrid.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getInverterPowerToGrid(this.apiData.result));
|
|
71
|
-
this.outletInverterToGrid.setSerial(`inv-grid-${this.apiData.result.inverterSN}`);
|
|
72
89
|
this.outletInverterToGrid.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
|
|
73
90
|
this.outletInverterToHouse.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getInverterPowerToHouse(this.apiData.result));
|
|
74
|
-
this.outletInverterToHouse.setSerial(`inv-house-${this.apiData.result.inverterSN}`);
|
|
75
91
|
this.outletInverterToHouse.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
|
|
76
92
|
this.outletGridToHouse.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getGridPowerToHouse(this.apiData.result));
|
|
77
|
-
this.outletGridToHouse.setSerial(`grid-house-${this.apiData.result.inverterSN}`);
|
|
78
93
|
this.outletGridToHouse.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
|
|
79
94
|
// update motion sensor
|
|
80
95
|
this.motionUpdate.setState(true);
|
|
81
|
-
this.motionUpdate.setSerial(`update-${this.apiData.result.inverterSN}`);
|
|
82
96
|
this.motionUpdate.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
|
|
83
97
|
}
|
|
84
98
|
else {
|
|
@@ -89,24 +103,10 @@ class SolaxCloudAPIPlatform {
|
|
|
89
103
|
this.log.error(`Failed to read from Solax Cloud API. Error: ${error}`);
|
|
90
104
|
}
|
|
91
105
|
finally {
|
|
92
|
-
this.log.
|
|
93
|
-
this.sleep(this.config.pollingFrequency * 1000)
|
|
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
|
-
});
|
|
106
|
+
this.log.info(`Updated data from Solax Cloud API, sleeping for ${this.config.pollingFrequency} seconds.`);
|
|
107
|
+
this.sleep(this.config.pollingFrequency * 1000)
|
|
108
|
+
.then(async () => await this.fetchDataPeriodically());
|
|
108
109
|
}
|
|
109
|
-
return this.apiData;
|
|
110
110
|
}
|
|
111
111
|
/*
|
|
112
112
|
* This method is called once at startup.
|
package/dist/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;;;;AAEA,mDAAiD;
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;;;;AAEA,mDAAiD;AACjD,wEAAwC;AAExC,uDAAyD;AAEzD,gDAAwB;AAExB,mDAAuE;AACvE,uDAAyD;AAEzD;;GAEG;AACH,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAEtC;;;;GAIG;AACH,MAAa,qBAAqB;IAyChC;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AAE,CAAC,CAAC;SACzD;IACH,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;AAjKD,sDAiKC"}
|
|
@@ -2,17 +2,17 @@ import { Service, AccessoryPlugin, Logging } from 'homebridge';
|
|
|
2
2
|
import { SolaxCloudAPIPlatform } from './platform';
|
|
3
3
|
/**
|
|
4
4
|
* Platform Accessory.
|
|
5
|
-
*
|
|
6
|
-
* Each accessory may expose multiple services of different service types.
|
|
5
|
+
* Generic platform accessory to store accessory name, manufacturer (Solax), inverter model and serial number.
|
|
7
6
|
*/
|
|
8
7
|
export declare class SolaxPlatformAccessory implements AccessoryPlugin {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
readonly platform: SolaxCloudAPIPlatform;
|
|
9
|
+
readonly log: Logging;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly displayName: string;
|
|
12
|
+
serialNumber: string;
|
|
13
|
+
model: string;
|
|
12
14
|
protected readonly informationService: Service;
|
|
13
|
-
|
|
14
|
-
protected serial: string;
|
|
15
|
-
constructor(platform: SolaxCloudAPIPlatform, log: Logging, name: string);
|
|
15
|
+
constructor(platform: SolaxCloudAPIPlatform, log: Logging, name: string, serialNumber: string);
|
|
16
16
|
/**
|
|
17
17
|
* Handle requests to get the current value of the "Model" characteristic.
|
|
18
18
|
* @returns {string} The model.
|
|
@@ -1 +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;
|
|
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;AAKnD;;;GAGG;AACH,qBAAa,sBAAuB,YAAW,eAAe;IAC5D,SAAgB,QAAQ,EAAE,qBAAqB,CAAC;IAChD,SAAgB,GAAG,EAAE,OAAO,CAAC;IAC7B,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,WAAW,EAAE,MAAM,CAAC;IAE7B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,SAAoB;IAEhC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;gBAEnC,QAAQ,EAAE,qBAAqB,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAqB7F;;;OAGG;IACI,QAAQ,IAAI,MAAM;IAMzB;;;OAGG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM;IAQ7B;;;OAGG;IACI,SAAS,IAAI,MAAM;IAM1B;;;OAGG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM;IAW/B,WAAW,IAAI,OAAO,EAAE;CAMzB"}
|
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SolaxPlatformAccessory = void 0;
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
5
|
+
const plugin = require('../package.json');
|
|
4
6
|
/**
|
|
5
7
|
* Platform Accessory.
|
|
6
|
-
*
|
|
7
|
-
* Each accessory may expose multiple services of different service types.
|
|
8
|
+
* Generic platform accessory to store accessory name, manufacturer (Solax), inverter model and serial number.
|
|
8
9
|
*/
|
|
9
10
|
class SolaxPlatformAccessory {
|
|
10
|
-
constructor(platform, log, name) {
|
|
11
|
+
constructor(platform, log, name, serialNumber) {
|
|
11
12
|
this.model = 'Solax inverter';
|
|
12
|
-
this.serial = 'Default serial';
|
|
13
13
|
this.platform = platform;
|
|
14
14
|
this.log = log;
|
|
15
15
|
this.name = name;
|
|
16
|
+
this.displayName = name;
|
|
17
|
+
this.serialNumber = serialNumber;
|
|
16
18
|
const hap = this.platform.api.hap;
|
|
17
|
-
this.log.debug(`Creating outlet "${this.name}"`);
|
|
18
19
|
// information service
|
|
19
20
|
this.informationService =
|
|
20
21
|
new hap.Service.AccessoryInformation()
|
|
21
22
|
.setCharacteristic(hap.Characteristic.Name, this.name)
|
|
22
|
-
.setCharacteristic(hap.Characteristic.Manufacturer, 'Solax')
|
|
23
|
+
.setCharacteristic(hap.Characteristic.Manufacturer, 'Solax')
|
|
24
|
+
.setCharacteristic(hap.Characteristic.FirmwareRevision, plugin.version)
|
|
25
|
+
.setCharacteristic(hap.Characteristic.SerialNumber, this.serialNumber);
|
|
23
26
|
this.informationService.getCharacteristic(hap.Characteristic.SerialNumber).onGet(this.getSerial.bind(this));
|
|
24
27
|
this.informationService.getCharacteristic(hap.Characteristic.Model).onGet(this.getModel.bind(this));
|
|
25
|
-
log.info(`Outlet "${name}" created!`);
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* Handle requests to get the current value of the "Model" characteristic.
|
|
@@ -39,14 +41,15 @@ class SolaxPlatformAccessory {
|
|
|
39
41
|
setModel(model) {
|
|
40
42
|
this.log.debug(`${this.name}: SET Model (model=${model})`);
|
|
41
43
|
this.model = model;
|
|
44
|
+
this.informationService.setCharacteristic(this.platform.api.hap.Characteristic.Model, model);
|
|
42
45
|
}
|
|
43
46
|
/**
|
|
44
47
|
* Handle requests to get the current value of the "SerialNumber" characteristic.
|
|
45
48
|
* @returns {string} The inverter serial number.
|
|
46
49
|
*/
|
|
47
50
|
getSerial() {
|
|
48
|
-
this.log.debug(`${this.name}: GET Serial (serial=${this.
|
|
49
|
-
return this.
|
|
51
|
+
this.log.debug(`${this.name}: GET Serial (serial=${this.serialNumber})`);
|
|
52
|
+
return this.serialNumber;
|
|
50
53
|
}
|
|
51
54
|
/**
|
|
52
55
|
* Sets model serial information for this outlet.
|
|
@@ -54,7 +57,8 @@ class SolaxPlatformAccessory {
|
|
|
54
57
|
*/
|
|
55
58
|
setSerial(serial) {
|
|
56
59
|
this.log.debug(`${this.name}: SET Serial (serial=${serial})`);
|
|
57
|
-
this.
|
|
60
|
+
this.serialNumber = serial;
|
|
61
|
+
this.informationService.setCharacteristic(this.platform.api.hap.Characteristic.SerialNumber, serial);
|
|
58
62
|
}
|
|
59
63
|
/*
|
|
60
64
|
* This method is called directly after creation of this instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platformAccessory.js","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":";;;AAIA
|
|
1
|
+
{"version":3,"file":"platformAccessory.js","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":";;;AAIA,8DAA8D;AAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE1C;;;GAGG;AACH,MAAa,sBAAsB;IAWjC,YAAY,QAA+B,EAAE,GAAY,EAAE,IAAY,EAAE,YAAoB;QAJtF,UAAK,GAAG,gBAAgB,CAAC;QAK9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QAEjC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;QAElC,sBAAsB;QACtB,IAAI,CAAC,kBAAkB;YACrB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OAGG;IACI,SAAS;QACd,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,wBAAwB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QAEzE,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,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,YAAY,GAAG,MAAM,CAAC;QAC3B,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACvG,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO;YACL,IAAI,CAAC,kBAAkB;SACxB,CAAC;IACJ,CAAC;CAEF;AArFD,wDAqFC"}
|
package/dist/solaxcloudapi.d.ts
CHANGED
|
@@ -120,6 +120,6 @@ export declare class SolaxCloudAPI {
|
|
|
120
120
|
* Retrieves inverter data using Solax Cloud "real-time" API.
|
|
121
121
|
* @returns {SolaxCloudAPIResponse} The response by Solax Cloud API.
|
|
122
122
|
*/
|
|
123
|
-
getAPIData():
|
|
123
|
+
getAPIData(): SolaxCloudAPIResponse;
|
|
124
124
|
}
|
|
125
125
|
//# sourceMappingURL=solaxcloudapi.d.ts.map
|
|
@@ -1 +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,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M;IAIpE;;;;OAIG;WACW,uBAAuB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM;IAIxE;;;OAGG;IACI,UAAU,IAAI,qBAAqB;CAc3C"}
|
package/dist/solaxcloudapi.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.SolaxCloudAPI = void 0;
|
|
4
|
-
const
|
|
7
|
+
const sync_fetch_1 = __importDefault(require("sync-fetch"));
|
|
5
8
|
const SOLAX_CLOUD_URL = 'https://www.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do';
|
|
6
9
|
/**
|
|
7
10
|
* Main class to retrieve data from Solax API.
|
|
@@ -154,10 +157,17 @@ class SolaxCloudAPI {
|
|
|
154
157
|
* Retrieves inverter data using Solax Cloud "real-time" API.
|
|
155
158
|
* @returns {SolaxCloudAPIResponse} The response by Solax Cloud API.
|
|
156
159
|
*/
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
getAPIData() {
|
|
161
|
+
try {
|
|
162
|
+
const response = (0, sync_fetch_1.default)(SOLAX_CLOUD_URL + '?tokenId=' + this.tokenId + '&sn=' + this.sn);
|
|
163
|
+
if (!response.ok) {
|
|
164
|
+
throw new Error(`unexpected response ${response.statusText}`);
|
|
165
|
+
}
|
|
166
|
+
return response.json();
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
return { exception: error, result: {}, success: false };
|
|
170
|
+
}
|
|
161
171
|
}
|
|
162
172
|
}
|
|
163
173
|
exports.SolaxCloudAPI = SolaxCloudAPI;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solaxcloudapi.js","sourceRoot":"","sources":["../src/solaxcloudapi.ts"],"names":[],"m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AC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,mBAAmB,CAAC,IAAyB;QACzD,OAAO,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,uBAAuB,CAAC,IAAyB;QAC7D,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAE,GAAE,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAC3E,CAAC;IAED;;;OAGG;IACI,UAAU;QACf,IAAI;YACF,MAAM,QAAQ,GAAG,IAAA,oBAAK,EAAC,eAAe,GAAG,WAAW,GAAG,IAAI,CAAC,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;YAExF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;gBAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;aAC/D;YAED,OAA+B,QAAQ,CAAC,IAAI,EAAE,CAAC;SAChD;QAAC,OAAO,KAAK,EAAE;YACd,OAA+B,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;SACjF;IACH,CAAC;CAEF;AA3KD,sCA2KC"}
|
package/dist/statistics.js
CHANGED
|
@@ -8,13 +8,12 @@ const solaxcloudapi_1 = require("./solaxcloudapi");
|
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const config = JSON.parse(fs_1.default.readFileSync('config.json').toString());
|
|
10
10
|
const api = new solaxcloudapi_1.SolaxCloudAPI(config.platforms[0].tokenId, config.platforms[0].sn);
|
|
11
|
-
api.getAPIData()
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
11
|
+
const result = api.getAPIData();
|
|
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`);
|
|
20
19
|
//# sourceMappingURL=statistics.js.map
|
package/dist/statistics.js.map
CHANGED
|
@@ -1 +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
|
|
1
|
+
{"version":3,"file":"statistics.js","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":";;;;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
3
|
-
"displayName": "Solax Cloud API",
|
|
3
|
+
"displayName": "Homebridge Solax Cloud API",
|
|
4
4
|
"name": "homebridge-solaxcloud-api",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.4.1-beta.1",
|
|
6
6
|
"description": "Integrates solar production info using public Solax Cloud API into Homebrigde acessories.",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"repository": {
|
|
@@ -32,8 +32,9 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"jshint": "^2.13.1",
|
|
35
|
-
"
|
|
36
|
-
"homebridge-lib": "^5.1.21"
|
|
35
|
+
"sync-fetch": "^0.3.1",
|
|
36
|
+
"homebridge-lib": "^5.1.21",
|
|
37
|
+
"fakegato-history": "^0.6.2"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@types/mocha": "^9.0.0",
|
package/dist/request.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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
|
package/dist/request.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/request.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
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
|
package/dist/request.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,GAA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