homebridge-solaxcloud-api 1.4.1-beta.1 → 1.4.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/dist/motionAccessory.d.ts +15 -2
- package/dist/motionAccessory.d.ts.map +1 -1
- package/dist/motionAccessory.js +17 -3
- package/dist/motionAccessory.js.map +1 -1
- package/dist/outletAccessory.d.ts +1 -1
- package/dist/outletAccessory.d.ts.map +1 -1
- package/dist/outletAccessory.js +4 -4
- package/dist/outletAccessory.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +7 -12
- package/dist/platform.js.map +1 -1
- package/dist/platformAccessory.d.ts +7 -7
- package/dist/platformAccessory.d.ts.map +1 -1
- package/dist/platformAccessory.js +13 -3
- package/dist/platformAccessory.js.map +1 -1
- package/dist/util.d.ts +18 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +35 -0
- package/dist/util.js.map +1 -0
- package/package.json +2 -1
|
@@ -8,16 +8,19 @@ import { SolaxPlatformAccessory } from './platformAccessory';
|
|
|
8
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
|
+
/**
|
|
12
|
+
* Homekit Motion Service for this accessory.
|
|
13
|
+
*/
|
|
11
14
|
private readonly motionService;
|
|
12
15
|
/**
|
|
13
16
|
* Whether motion is detected (Solax Cloud data updated).
|
|
14
17
|
*/
|
|
15
18
|
private motion;
|
|
16
19
|
/**
|
|
17
|
-
*
|
|
20
|
+
* Interval before clearing motion (in seconds).
|
|
18
21
|
*/
|
|
19
22
|
private motionTimeout;
|
|
20
|
-
constructor(platform: SolaxCloudAPIPlatform, log: Logging, name: string, serial: string);
|
|
23
|
+
constructor(platform: SolaxCloudAPIPlatform, log: Logging, name: string, serial: string, model: string);
|
|
21
24
|
sleep: typeof import("timers/promises").setTimeout;
|
|
22
25
|
/**
|
|
23
26
|
* Gets the motion sensor state Characteristic.
|
|
@@ -29,6 +32,16 @@ export declare class SolaxMotionAccessory extends SolaxPlatformAccessory impleme
|
|
|
29
32
|
* @param {boolean} motion Whether motion was detected.
|
|
30
33
|
*/
|
|
31
34
|
setState(motion: boolean): void;
|
|
35
|
+
/**
|
|
36
|
+
* Sets the motion timeout.
|
|
37
|
+
* @param {number} timeout Number of seconds before clearing motion.
|
|
38
|
+
*/
|
|
39
|
+
setMotionTimeout(timeout: number): void;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the motion timeout.
|
|
42
|
+
* @return {number} Number of seconds before clearing motion.
|
|
43
|
+
*/
|
|
44
|
+
getMotionTimeout(): number;
|
|
32
45
|
getServices(): Service[];
|
|
33
46
|
}
|
|
34
47
|
//# sourceMappingURL=motionAccessory.d.ts.map
|
|
@@ -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;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;
|
|
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;;OAEG;IACH,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,EAAE,KAAK,EAAE,MAAM;IAetG,KAAK,8CAA8B;IAEnC;;;OAGG;IACI,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI;IAM1D;;;OAGG;IACI,QAAQ,CAAC,MAAM,EAAE,OAAO;IAe/B;;;OAGG;IACH,gBAAgB,CAAC,OAAO,EAAE,MAAM;IAIhC;;;OAGG;IACH,gBAAgB,IAAI,MAAM;IAQ1B,WAAW,IAAI,OAAO,EAAE;CAOzB"}
|
package/dist/motionAccessory.js
CHANGED
|
@@ -16,14 +16,14 @@ const MOTION_TIMEOUT = 5;
|
|
|
16
16
|
* Sensor will automatically clear itself after MOTION_TIMEOUT seconds (5 seconds).
|
|
17
17
|
*/
|
|
18
18
|
class SolaxMotionAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
19
|
-
constructor(platform, log, name, serial) {
|
|
20
|
-
super(platform, log, name, serial);
|
|
19
|
+
constructor(platform, log, name, serial, model) {
|
|
20
|
+
super(platform, log, name, serial, model);
|
|
21
21
|
/**
|
|
22
22
|
* Whether motion is detected (Solax Cloud data updated).
|
|
23
23
|
*/
|
|
24
24
|
this.motion = false;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Interval before clearing motion (in seconds).
|
|
27
27
|
*/
|
|
28
28
|
this.motionTimeout = MOTION_TIMEOUT;
|
|
29
29
|
this.sleep = util_1.default.promisify(setTimeout);
|
|
@@ -58,6 +58,20 @@ class SolaxMotionAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
|
58
58
|
this.sleep(this.motionTimeout * 1000).then(() => this.setState(false));
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Sets the motion timeout.
|
|
63
|
+
* @param {number} timeout Number of seconds before clearing motion.
|
|
64
|
+
*/
|
|
65
|
+
setMotionTimeout(timeout) {
|
|
66
|
+
this.motionTimeout = timeout;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Gets the motion timeout.
|
|
70
|
+
* @return {number} Number of seconds before clearing motion.
|
|
71
|
+
*/
|
|
72
|
+
getMotionTimeout() {
|
|
73
|
+
return this.motionTimeout;
|
|
74
|
+
}
|
|
61
75
|
/*
|
|
62
76
|
* This method is called directly after creation of this instance.
|
|
63
77
|
* It should return all services which should be added to the accessory.
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;IAiB9D,YAAY,QAA+B,EAAE,GAAY,EAAE,IAAY,EAAE,MAAc,EAAE,KAAa;QACpG,KAAK,CAAC,QAAQ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EvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,4BAA4B;YAC5B,IAAI,CAAC,KAAK,CAAC,IAAI,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,gBAAgB,CAAC,OAAe;QAC9B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,gBAAgB;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO;YACL,IAAI,CAAC,kBAAkB;YACvB,IAAI,CAAC,aAAa;SACnB,CAAC;IACJ,CAAC;CAEF;AA1FD,oDA0FC"}
|
|
@@ -23,7 +23,7 @@ export declare class SolaxOutletAccessory extends SolaxPlatformAccessory impleme
|
|
|
23
23
|
* Elgato Eve fake history service for energy and status.
|
|
24
24
|
*/
|
|
25
25
|
private readonly loggingService;
|
|
26
|
-
constructor(platform: SolaxCloudAPIPlatform, log: Logging, name: string, serial: string);
|
|
26
|
+
constructor(platform: SolaxCloudAPIPlatform, log: Logging, name: string, serial: string, model: string);
|
|
27
27
|
/**
|
|
28
28
|
* Sets a characteristic value for a sepecific characteristic.
|
|
29
29
|
* @param {string} charName The characteristic name.
|
|
@@ -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;AAI7D;;;;GAIG;AACH,qBA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;OAEG;IACI,yBAAyB,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI;IAM3E;;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
|
@@ -9,8 +9,8 @@ const platformAccessory_1 = require("./platformAccessory");
|
|
|
9
9
|
*/
|
|
10
10
|
class SolaxOutletAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
11
11
|
//private services: Service[];
|
|
12
|
-
constructor(platform, log, name, serial) {
|
|
13
|
-
super(platform, log, name, serial);
|
|
12
|
+
constructor(platform, log, name, serial, model) {
|
|
13
|
+
super(platform, log, name, serial, model);
|
|
14
14
|
/**
|
|
15
15
|
* Current power reading in Watt.
|
|
16
16
|
*/
|
|
@@ -36,7 +36,7 @@ class SolaxOutletAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
|
36
36
|
// reset
|
|
37
37
|
//this.powerMeterService.addOptionalCharacteristic(this.platform.eve.Characteristics.ResetTotal);
|
|
38
38
|
// history logging services
|
|
39
|
-
this.loggingService = new this.platform.eveService('energy', this, { storage: 'fs' });
|
|
39
|
+
this.loggingService = new this.platform.eveService('energy', this, { storage: 'fs', log: this.log });
|
|
40
40
|
//this.services.push(this.loggingService);
|
|
41
41
|
log.info(`Outlet "${name}" created!`);
|
|
42
42
|
}
|
|
@@ -69,6 +69,7 @@ class SolaxOutletAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
|
69
69
|
// add entries to history
|
|
70
70
|
this.loggingService.
|
|
71
71
|
addEntry({ time: Math.round(new Date().valueOf() / 1000), power: this.powerConsumption /*, status: this.powerConsumption > 0 */ });
|
|
72
|
+
//this.log.debug(JSON.stringify(this.loggingService));
|
|
72
73
|
}
|
|
73
74
|
/**
|
|
74
75
|
* Gets the total energy consumpion.
|
|
@@ -76,7 +77,6 @@ class SolaxOutletAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
|
76
77
|
getTotalEnergyConsumption(callback) {
|
|
77
78
|
this.log.debug(`${this.name}: GET Total Energy (energy=${this.totalEnergyConsumption}kWh)`);
|
|
78
79
|
callback(null, this.totalEnergyConsumption);
|
|
79
|
-
//this.log.debug(JSON.stringify(this.energyHistoryService));
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* Sets the total energy consumption.
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,EAAE,KAAa;QACpG,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAlB5C;;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,C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;;;;;;OAMG;gBACU,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,GAAG;IAyD3D,KAAK,8CAA8B;IAEnC;;OAEG;YACW,qBAAqB;IAyCnC,WAAW,CAAC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,eAAe,EAAE,KAAK,IAAI,GAAG,IAAI;CAK3E"}
|
package/dist/platform.js
CHANGED
|
@@ -48,20 +48,21 @@ class SolaxCloudAPIPlatform {
|
|
|
48
48
|
this.apiData = this.solaxCloudAPI.getAPIData();
|
|
49
49
|
this.log.debug(`apiData = ${JSON.stringify(this.apiData)}`);
|
|
50
50
|
const inverterSN = this.apiData.result.inverterSN.toLowerCase();
|
|
51
|
+
const inverterModel = solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType);
|
|
51
52
|
// setup outlet accessories
|
|
52
53
|
this.outletPV =
|
|
53
|
-
new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} PV`, `pv-${inverterSN}
|
|
54
|
+
new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} PV`, `pv-${inverterSN}`, inverterModel);
|
|
54
55
|
this.outletInverterAC =
|
|
55
|
-
new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Inverter AC`, `inv-ac-${inverterSN}
|
|
56
|
+
new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Inverter AC`, `inv-ac-${inverterSN}`, inverterModel);
|
|
56
57
|
this.outletInverterToGrid =
|
|
57
|
-
new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Inverter to Grid`, `inv-grid-${inverterSN}
|
|
58
|
+
new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Inverter to Grid`, `inv-grid-${inverterSN}`, inverterModel);
|
|
58
59
|
this.outletInverterToHouse =
|
|
59
|
-
new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Inverter to House`, `inv-house-${inverterSN}
|
|
60
|
+
new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Inverter to House`, `inv-house-${inverterSN}`, inverterModel);
|
|
60
61
|
this.outletGridToHouse =
|
|
61
|
-
new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Grid to House`, `grid-house-${inverterSN}
|
|
62
|
+
new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} Grid to House`, `grid-house-${inverterSN}`, inverterModel);
|
|
62
63
|
// setup update motion sensor
|
|
63
64
|
this.motionUpdate =
|
|
64
|
-
new motionAccessory_1.SolaxMotionAccessory(this, this.log, `${this.config.name} Update`, `update-${inverterSN}
|
|
65
|
+
new motionAccessory_1.SolaxMotionAccessory(this, this.log, `${this.config.name} Update`, `update-${inverterSN}`, inverterModel);
|
|
65
66
|
// start data fetching
|
|
66
67
|
this.fetchDataPeriodically();
|
|
67
68
|
this.log.debug('Finished initializing platform.'),
|
|
@@ -81,19 +82,13 @@ class SolaxCloudAPIPlatform {
|
|
|
81
82
|
this.log.debug(`Retrieved inverter status: ${JSON.stringify(this.apiData.result)}`);
|
|
82
83
|
// update outlets
|
|
83
84
|
this.outletPV.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getPVPower(this.apiData.result));
|
|
84
|
-
this.outletPV.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
|
|
85
85
|
this.outletInverterAC.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getInverterACPower(this.apiData.result));
|
|
86
86
|
this.outletInverterAC.setTotalEnergyConsumption(solaxcloudapi_1.SolaxCloudAPI.getYieldTotal(this.apiData.result));
|
|
87
|
-
this.outletInverterAC.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
|
|
88
87
|
this.outletInverterToGrid.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getInverterPowerToGrid(this.apiData.result));
|
|
89
|
-
this.outletInverterToGrid.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
|
|
90
88
|
this.outletInverterToHouse.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getInverterPowerToHouse(this.apiData.result));
|
|
91
|
-
this.outletInverterToHouse.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
|
|
92
89
|
this.outletGridToHouse.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getGridPowerToHouse(this.apiData.result));
|
|
93
|
-
this.outletGridToHouse.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
|
|
94
90
|
// update motion sensor
|
|
95
91
|
this.motionUpdate.setState(true);
|
|
96
|
-
this.motionUpdate.setModel(solaxcloudapi_1.SolaxCloudAPI.getInverterType(this.apiData.result.inverterType));
|
|
97
92
|
}
|
|
98
93
|
else {
|
|
99
94
|
throw new Error(this.apiData.exception);
|
package/dist/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;;;;;;OAMG;IACH,YAAa,GAAY,EAAE,MAAsB,EAAE,GAAQ;
|
|
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;;;;;;OAMG;IACH,YAAa,GAAY,EAAE,MA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,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;gBAEnG,uBAAuB;gBACvB,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;aAClC;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;aACzC;SACF;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,+CAA+C,KAAK,EAAE,CAAC,CAAC;SACxE;gBAAS;YACR,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,mDAAmD,IAAI,CAAC,MAAM,CAAC,gBAAgB,WAAW,CAAC,CAAC;YAE1G,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC;iBAC5C,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,qBAAqB,EAAE,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;AA5JD,sDA4JC"}
|
|
@@ -5,14 +5,14 @@ import { SolaxCloudAPIPlatform } from './platform';
|
|
|
5
5
|
* Generic platform accessory to store accessory name, manufacturer (Solax), inverter model and serial number.
|
|
6
6
|
*/
|
|
7
7
|
export declare class SolaxPlatformAccessory implements AccessoryPlugin {
|
|
8
|
-
readonly platform: SolaxCloudAPIPlatform;
|
|
9
|
-
readonly log: Logging;
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly displayName: string;
|
|
12
|
-
serialNumber: string;
|
|
13
|
-
model: string;
|
|
8
|
+
protected readonly platform: SolaxCloudAPIPlatform;
|
|
9
|
+
protected readonly log: Logging;
|
|
10
|
+
protected readonly name: string;
|
|
11
|
+
protected readonly displayName: string;
|
|
12
|
+
protected serialNumber: string;
|
|
13
|
+
protected model: string;
|
|
14
14
|
protected readonly informationService: Service;
|
|
15
|
-
constructor(platform: SolaxCloudAPIPlatform, log: Logging, name: string, serialNumber: string);
|
|
15
|
+
constructor(platform: SolaxCloudAPIPlatform, log: Logging, name: string, serialNumber: string, model: 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;
|
|
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;AAI/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AASnD;;;GAGG;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;IAChC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAEvC,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC;IAC/B,SAAS,CAAC,KAAK,SAAoB;IAEnC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;gBAEnC,QAAQ,EAAE,qBAAqB,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IA2B5G;;;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,6 +1,12 @@
|
|
|
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.SolaxPlatformAccessory = void 0;
|
|
7
|
+
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const util_1 = require("./util");
|
|
9
|
+
const string_hash_64_1 = __importDefault(require("string-hash-64"));
|
|
4
10
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
5
11
|
const plugin = require('../package.json');
|
|
6
12
|
/**
|
|
@@ -8,21 +14,25 @@ const plugin = require('../package.json');
|
|
|
8
14
|
* Generic platform accessory to store accessory name, manufacturer (Solax), inverter model and serial number.
|
|
9
15
|
*/
|
|
10
16
|
class SolaxPlatformAccessory {
|
|
11
|
-
constructor(platform, log, name, serialNumber) {
|
|
17
|
+
constructor(platform, log, name, serialNumber, model) {
|
|
12
18
|
this.model = 'Solax inverter';
|
|
13
19
|
this.platform = platform;
|
|
14
20
|
this.log = log;
|
|
15
21
|
this.name = name;
|
|
16
22
|
this.displayName = name;
|
|
17
|
-
|
|
23
|
+
// hash "true" serial and hostname to 32 bit hex
|
|
24
|
+
this.serialNumber = (0, string_hash_64_1.default)(`${serialNumber}-${os_1.default.hostname()}`).toString(16);
|
|
25
|
+
this.model = util_1.Util.normalizeName(model);
|
|
18
26
|
const hap = this.platform.api.hap;
|
|
27
|
+
//this.uuid = hap.uuid.generate(this.serialNumber);
|
|
19
28
|
// information service
|
|
20
29
|
this.informationService =
|
|
21
30
|
new hap.Service.AccessoryInformation()
|
|
22
31
|
.setCharacteristic(hap.Characteristic.Name, this.name)
|
|
23
32
|
.setCharacteristic(hap.Characteristic.Manufacturer, 'Solax')
|
|
24
33
|
.setCharacteristic(hap.Characteristic.FirmwareRevision, plugin.version)
|
|
25
|
-
.setCharacteristic(hap.Characteristic.SerialNumber, this.serialNumber)
|
|
34
|
+
.setCharacteristic(hap.Characteristic.SerialNumber, this.serialNumber)
|
|
35
|
+
.setCharacteristic(hap.Characteristic.Model, this.model);
|
|
26
36
|
this.informationService.getCharacteristic(hap.Characteristic.SerialNumber).onGet(this.getSerial.bind(this));
|
|
27
37
|
this.informationService.getCharacteristic(hap.Characteristic.Model).onGet(this.getModel.bind(this));
|
|
28
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platformAccessory.js","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"platformAccessory.js","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":";;;;;;AAEA,4CAAoB;AAIpB,iCAA8B;AAE9B,oEAAkC;AAElC,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,EAAE,KAAa;QAJlG,UAAK,GAAG,gBAAgB,CAAC;QAKjC,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;QAExB,gDAAgD;QAChD,IAAI,CAAC,YAAY,GAAG,IAAA,wBAAI,EAAC,GAAG,Y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,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;QAG3D,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC/F,CAAC;IAED;;;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;AA3FD,wDA2FC"}
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility class.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Util {
|
|
5
|
+
/**
|
|
6
|
+
* Calculates 32 bit hash from a string.
|
|
7
|
+
* @param s {string} String to calculate 32 bit hash from.
|
|
8
|
+
* @returns {number} The 32 bit hash from the string.
|
|
9
|
+
*/
|
|
10
|
+
static hash32(s: string): number;
|
|
11
|
+
/**
|
|
12
|
+
* Removes non-standard alphanumeric characters from string.
|
|
13
|
+
* @param {string} s The original string.
|
|
14
|
+
* @returns {string} Resulting string without any non-standard chars.
|
|
15
|
+
*/
|
|
16
|
+
static normalizeName(s: string): string;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,qBAAa,IAAI;IAEf;;;;OAIG;WACW,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAiBvC;;;;OAIG;WACW,aAAa,CAAC,CAAC,EAAE,MAAM;CAItC"}
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Util = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Utility class.
|
|
6
|
+
*/
|
|
7
|
+
class Util {
|
|
8
|
+
/**
|
|
9
|
+
* Calculates 32 bit hash from a string.
|
|
10
|
+
* @param s {string} String to calculate 32 bit hash from.
|
|
11
|
+
* @returns {number} The 32 bit hash from the string.
|
|
12
|
+
*/
|
|
13
|
+
static hash32(s) {
|
|
14
|
+
let hash = 0;
|
|
15
|
+
if (s.length === 0) {
|
|
16
|
+
return hash;
|
|
17
|
+
}
|
|
18
|
+
for (let i = 0; i < s.length; i++) {
|
|
19
|
+
const chr = s.charCodeAt(i);
|
|
20
|
+
hash = ((hash << 5) - hash) + chr;
|
|
21
|
+
hash |= 0; // Convert to 32bit integer
|
|
22
|
+
}
|
|
23
|
+
return hash;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Removes non-standard alphanumeric characters from string.
|
|
27
|
+
* @param {string} s The original string.
|
|
28
|
+
* @returns {string} Resulting string without any non-standard chars.
|
|
29
|
+
*/
|
|
30
|
+
static normalizeName(s) {
|
|
31
|
+
return s.replace(/[^-_ a-zA-Z0-9]/gi, '');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.Util = Util;
|
|
35
|
+
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AACA;;GAEG;AACH,MAAa,IAAI;IAEf;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,CAAS;QAC5B,IAAI,IAAI,GAAG,CAAC,CAAC;QAEb,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;YAClB,OAAO,IAAI,CAAC;SACb;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACjC,MAAM,GAAG,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAE5B,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;YAClC,IAAI,IAAI,CAAC,CAAC,CAAC,2BAA2B;SACvC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,aAAa,CAAC,CAAS;QACnC,OAAO,CAAC,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;IAC5C,CAAC;CAEF;AAjCD,oBAiCC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"private": false,
|
|
3
3
|
"displayName": "Homebridge Solax Cloud API",
|
|
4
4
|
"name": "homebridge-solaxcloud-api",
|
|
5
|
-
"version": "1.4.1
|
|
5
|
+
"version": "1.4.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": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"jshint": "^2.13.1",
|
|
35
35
|
"sync-fetch": "^0.3.1",
|
|
36
|
+
"string-hash-64": "^1.0.3",
|
|
36
37
|
"homebridge-lib": "^5.1.21",
|
|
37
38
|
"fakegato-history": "^0.6.2"
|
|
38
39
|
},
|