homebridge-solaxcloud-api 2.4.2 → 2.5.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/CHANGELOG.md +16 -0
- package/README.md +30 -3
- package/config.schema.json +2 -2
- package/dist/batteryAccessory.d.ts +1 -1
- package/dist/batteryAccessory.d.ts.map +1 -1
- package/dist/batteryAccessory.js +17 -17
- package/dist/batteryAccessory.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/lightSensorAccessory.d.ts +23 -16
- package/dist/lightSensorAccessory.d.ts.map +1 -1
- package/dist/lightSensorAccessory.js +109 -32
- package/dist/lightSensorAccessory.js.map +1 -1
- package/dist/motionAccessory.d.ts +1 -2
- package/dist/motionAccessory.d.ts.map +1 -1
- package/dist/motionAccessory.js +17 -20
- 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 +47 -33
- package/dist/outletAccessory.js.map +1 -1
- package/dist/platform.d.ts +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +30 -27
- package/dist/platform.js.map +1 -1
- package/dist/platformAccessory.d.ts.map +1 -1
- package/dist/platformAccessory.js +40 -18
- package/dist/platformAccessory.js.map +1 -1
- package/dist/platformInverter.d.ts +5 -0
- package/dist/platformInverter.d.ts.map +1 -1
- package/dist/platformInverter.js +148 -75
- package/dist/platformInverter.js.map +1 -1
- package/dist/platformMeters.d.ts +2 -2
- package/dist/platformMeters.d.ts.map +1 -1
- package/dist/platformMeters.js +1 -2
- package/dist/settings.js +2 -5
- package/dist/settings.js.map +1 -1
- package/dist/solaxcloudfetch.js +14 -19
- package/dist/solaxcloudfetch.js.map +1 -1
- package/dist/statistics.js +1 -5
- package/dist/statistics.js.map +1 -1
- package/dist/util.js +1 -5
- package/dist/util.js.map +1 -1
- package/package.json +21 -16
- package/test/batteryAccessory.test.ts +3 -3
- package/test/helpers.ts +49 -5
- package/test/lightSensorAccessory.test.ts +48 -3
- package/test/motionAccessory.test.ts +3 -3
- package/test/outletAccessory.test.ts +3 -3
- package/test/platformAccessory.test.ts +3 -3
- package/test/platformConfig.test.ts +2 -2
- package/test/platformTotalizer.test.ts +64 -4
- package/test/statistics.test.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [v2.5.1] - 2026-10-28
|
|
6
|
+
### Changed
|
|
7
|
+
* Matter electrical sensors are now created whenever Matter is enabled for the bridge; `pureHomeApp` is no longer required.
|
|
8
|
+
* Renamed the `pureHomeApp` UI option to clarify that it is only a legacy Apple Home fallback.
|
|
9
|
+
* Advertised both Matter and HAP support in the package metadata.
|
|
10
|
+
### Fixed
|
|
11
|
+
* Decoupled Matter power and energy updates from the legacy `pureHomeApp` setting.
|
|
12
|
+
|
|
13
|
+
## [v2.5.0] - 2026-10-27
|
|
14
|
+
### Added
|
|
15
|
+
* Added Matter electrical sensor support for power and cumulative energy in Apple Home.
|
|
16
|
+
### Changed
|
|
17
|
+
* Updated the project for Homebridge 2.4, modern Node.js, TypeScript, and ESM compatibility.
|
|
18
|
+
### Fixed
|
|
19
|
+
* Corrected Matter device registration, measurement schemas, unit conversions, and accessory deduplication.
|
|
20
|
+
|
|
5
21
|
## [v2.4.2] - 2026-06-03
|
|
6
22
|
### Changed
|
|
7
23
|
* Bumped Homebridge Lib dependency.
|
package/README.md
CHANGED
|
@@ -79,9 +79,9 @@ Configuration parameters are described on the table below:
|
|
|
79
79
|
| `platform` | string | Platform name (must be SolaxCloudAPI) | - | Y |
|
|
80
80
|
| `inverters` | array | Array of configured inverters as objects with `{ brand: string, tokenId: string, name: string, sn: string, hasBattery: boolean }`, where `brand` is "solax" or "qcells", `tokenID` is the access token retrieved from the API page of Solax/QCells Cloud, `name` is the inverter name, used as prefix for accessory naming, `sn` is the inverter registration no. (inverter module SN) and `hasBattery` indicates on whether this inverter is connected to a battery. | - | Y |
|
|
81
81
|
| `pollingFrequency` | number | Plugin data polling frequency from Solax Cloud (in seconds) | 300 | N |
|
|
82
|
-
| `
|
|
82
|
+
| `smoothMeters` | boolean | Whether to create additional meters by smoothing raw values from Solax Cloud | true | N |
|
|
83
83
|
| `smoothingMethod` | string | Statistical method to use for smoothing raw values from Solax Cloud (simple or exponential moving average - "sma" or "ema") | "sma" | N |
|
|
84
|
-
| `pureHomeApp` | boolean |
|
|
84
|
+
| `pureHomeApp` | boolean | Legacy fallback that exposes power as ambient light sensors when Matter is unavailable. It is ignored when Matter is enabled for the bridge. | false | N |
|
|
85
85
|
| `enableHistory` | boolean | Whether to enable Eve/fakegato history services for outlet power readings | true | N |
|
|
86
86
|
|
|
87
87
|
**NOTE:** The `pollingFrequency` parameter defaults to 300 seconds, since Solax/QCells inverters update cloud data every 5 minutes.
|
|
@@ -90,6 +90,32 @@ Configuration through the the use of [Homebridge UI](https://github.com/oznu/hom
|
|
|
90
90
|
|
|
91
91
|
<img src="images/homebridge-ui.png" width="100%" height="100%">
|
|
92
92
|
|
|
93
|
+
## Matter electrical sensors
|
|
94
|
+
|
|
95
|
+
On Homebridge 2.4 or newer, the plugin exposes power readings as native Matter
|
|
96
|
+
Electrical Sensor devices. The **AC** sensor also exposes cumulative generated
|
|
97
|
+
energy. Matter support does not require `pureHomeApp`.
|
|
98
|
+
|
|
99
|
+
To enable the sensors:
|
|
100
|
+
|
|
101
|
+
1. Open **Homebridge UI > Plugins > Homebridge Solax Cloud API > Bridge Settings**.
|
|
102
|
+
2. Enable **Matter**, save, and restart the plugin.
|
|
103
|
+
3. Open the bridge settings again to display its Matter QR code.
|
|
104
|
+
4. In Apple Home, select **Add Accessory** and scan the QR code.
|
|
105
|
+
|
|
106
|
+
The plugin logs `Matter enabled - exposing native electrical sensors.` followed
|
|
107
|
+
by one `Matter Electrical Sensor` creation message for each applicable meter.
|
|
108
|
+
New sensors start at 0 W and receive data on the next successful Solax Cloud
|
|
109
|
+
update (the default polling interval is five minutes). The already-paired Matter
|
|
110
|
+
bridge does not need to be removed or paired again when sensors are added.
|
|
111
|
+
|
|
112
|
+
Raw and smoothed readings are exposed as separate sensors by default. Disable
|
|
113
|
+
`smoothMeters` if you do not want the additional smoothed sensors.
|
|
114
|
+
|
|
115
|
+
When Matter is unavailable, enabling `pureHomeApp` provides the legacy Apple
|
|
116
|
+
Home fallback by representing power readings as ambient light sensors. With
|
|
117
|
+
Matter enabled, `pureHomeApp` is ignored and native electrical sensors are used.
|
|
118
|
+
|
|
93
119
|
## Non-standard characteristics
|
|
94
120
|
|
|
95
121
|
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.
|
|
@@ -98,7 +124,7 @@ This will allow some non-standard characteristics to be visible along with its h
|
|
|
98
124
|
|
|
99
125
|
<img src="images/plugin-outlet-consumption.png" width="50%" height="50%">
|
|
100
126
|
|
|
101
|
-
If you want to rely solely on the native Home App,
|
|
127
|
+
If Matter is unavailable and you want to rely solely on the native Home App, enable the `pureHomeApp` config setting. This legacy fallback exposes power consumption on each meter as an Ambient Light Sensor (the minimum value for an Ambient Light Sensor is 0.1 lux):
|
|
102
128
|
|
|
103
129
|
<img src="images/plugin-accessories-home-pure.png" width="50%" height="50%">
|
|
104
130
|
|
|
@@ -191,6 +217,7 @@ Next planned plugin releases should include:
|
|
|
191
217
|
- [X] Consumption history through the [fakegato-history](https://github.com/simont77/fakegato-history) module
|
|
192
218
|
- [x] Enable support for "pure" Home App accessories (power meters will be exposed as Ambient Light sensors)
|
|
193
219
|
- [x] Add "smooth" accessories for power meters (compensating for sporadic scenarios like cloud a passing)
|
|
220
|
+
- [x] Add native Matter support for power and energy readings
|
|
194
221
|
- [x] Support for multiple inverters
|
|
195
222
|
- [x] Support for multiple brands (between Solax and QCells)
|
|
196
223
|
- [x] Accessories for battery state and consumptions
|
package/config.schema.json
CHANGED
|
@@ -95,11 +95,11 @@
|
|
|
95
95
|
"description": "Statistical method for smoothing power consumption data."
|
|
96
96
|
},
|
|
97
97
|
"pureHomeApp": {
|
|
98
|
-
"title": "
|
|
98
|
+
"title": "Legacy Apple Home power sensors",
|
|
99
99
|
"type": "boolean",
|
|
100
100
|
"required": false,
|
|
101
101
|
"default": false,
|
|
102
|
-
"description": "
|
|
102
|
+
"description": "Expose power as ambient light sensors when Matter is unavailable. This setting is ignored when Matter is enabled for the bridge."
|
|
103
103
|
},
|
|
104
104
|
"enableHistory": {
|
|
105
105
|
"title": "Enable Eve history?",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AccessoryPlugin, API, CharacteristicGetCallback, Logging, Service } from 'homebridge';
|
|
2
|
-
import { SolaxPlatformAccessory } from './platformAccessory';
|
|
2
|
+
import { SolaxPlatformAccessory } from './platformAccessory.js';
|
|
3
3
|
/**
|
|
4
4
|
* Enum with possible battery charging states.
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batteryAccessory.d.ts","sourceRoot":"","sources":["../src/batteryAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,GAAG,EAA4B,yBAAyB,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEzH,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"batteryAccessory.d.ts","sourceRoot":"","sources":["../src/batteryAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,GAAG,EAA4B,yBAAyB,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEzH,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;CAIlC,CAAC;AAOF;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,sBAAuB,YAAW,eAAe;IAC1F;;QAEI;IACJ,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;IAEzC;;OAEG;IACH,OAAO,CAAC,YAAY,CAAK;IAEzB;;OAEG;IACH,OAAO,CAAC,kBAAkB,CAAuC;IAEjE;;;;;;;OAOG;gBACS,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAwB/E;;OAEG;IACI,mBAAmB,IAAI,MAAM;IAepC;;;OAGG;IACI,aAAa,IAAI,MAAM;IAI9B;;OAEG;IACI,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI;IAM1D;;;OAGG;IACI,QAAQ,CAAC,UAAU,EAAE,MAAM;IAQlC;;OAEG;IACI,cAAc,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI;IAMhE;;;OAGG;IACI,cAAc,CAAC,KAAK,EAAE,MAAM;IAQnC;;;OAGG;IACI,mBAAmB,IAAI,MAAM;IAQpC,WAAW,IAAI,OAAO,EAAE;CAIzB"}
|
package/dist/batteryAccessory.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SolaxBatteryAccessory = exports.BATTERY_CHARGING_STATE = void 0;
|
|
4
|
-
const platformAccessory_1 = require("./platformAccessory");
|
|
1
|
+
import { SolaxPlatformAccessory } from './platformAccessory.js';
|
|
5
2
|
/**
|
|
6
3
|
* Enum with possible battery charging states.
|
|
7
4
|
*/
|
|
8
|
-
|
|
5
|
+
export const BATTERY_CHARGING_STATE = {
|
|
9
6
|
NOT_CHARGING: 0,
|
|
10
7
|
CHARGING: 1,
|
|
11
8
|
NOT_CHARGEABLE: 2,
|
|
@@ -18,7 +15,19 @@ const LOW_BATTERY_THRESHOLD = 10;
|
|
|
18
15
|
* Solax Battery Accessory.
|
|
19
16
|
* Battery sensor used to monitor inverter battery state of charge (SoC).
|
|
20
17
|
*/
|
|
21
|
-
class SolaxBatteryAccessory extends
|
|
18
|
+
export class SolaxBatteryAccessory extends SolaxPlatformAccessory {
|
|
19
|
+
/**
|
|
20
|
+
* The battery service for Homekit.
|
|
21
|
+
**/
|
|
22
|
+
batteryService;
|
|
23
|
+
/**
|
|
24
|
+
* The battery charge level (in percentage).
|
|
25
|
+
*/
|
|
26
|
+
batteryLevel = 0;
|
|
27
|
+
/**
|
|
28
|
+
* Ambient light level.
|
|
29
|
+
*/
|
|
30
|
+
batteryChargeState = BATTERY_CHARGING_STATE.NOT_CHARGING;
|
|
22
31
|
/**
|
|
23
32
|
* Solax virtual light sensor class constructor.
|
|
24
33
|
* @param {Logging} log The platform logging for homebridge.
|
|
@@ -29,24 +38,16 @@ class SolaxBatteryAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
|
29
38
|
*/
|
|
30
39
|
constructor(log, api, name, serial, model) {
|
|
31
40
|
super(log, api, name, serial, model);
|
|
32
|
-
/**
|
|
33
|
-
* The battery charge level (in percentage).
|
|
34
|
-
*/
|
|
35
|
-
this.batteryLevel = 0;
|
|
36
|
-
/**
|
|
37
|
-
* Ambient light level.
|
|
38
|
-
*/
|
|
39
|
-
this.batteryChargeState = exports.BATTERY_CHARGING_STATE.NOT_CHARGING;
|
|
40
41
|
this.log.debug(`Creating battery "${this.name}"`);
|
|
41
42
|
this.batteryService = new this.api.hap.Service.Battery(name);
|
|
42
43
|
// handler for getting battery level
|
|
43
44
|
this.batteryService
|
|
44
45
|
.getCharacteristic(this.api.hap.Characteristic.BatteryLevel)
|
|
45
|
-
.on("get" /* GET */, this.getLevel.bind(this));
|
|
46
|
+
.on("get" /* CharacteristicEventTypes.GET */, this.getLevel.bind(this));
|
|
46
47
|
// handler for charging state
|
|
47
48
|
this.batteryService
|
|
48
49
|
.getCharacteristic(this.api.hap.Characteristic.ChargingState)
|
|
49
|
-
.on("get" /* GET */, this.getChargeState.bind(this));
|
|
50
|
+
.on("get" /* CharacteristicEventTypes.GET */, this.getChargeState.bind(this));
|
|
50
51
|
// handler for low battery
|
|
51
52
|
this.batteryService.getCharacteristic(this.api.hap.Characteristic.StatusLowBattery)
|
|
52
53
|
.onGet(this.getStatusLowBattery.bind(this));
|
|
@@ -121,5 +122,4 @@ class SolaxBatteryAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
|
121
122
|
return [this.informationService, this.batteryService];
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
|
-
exports.SolaxBatteryAccessory = SolaxBatteryAccessory;
|
|
125
125
|
//# sourceMappingURL=batteryAccessory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batteryAccessory.js","sourceRoot":"","sources":["../src/batteryAccessory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"batteryAccessory.js","sourceRoot":"","sources":["../src/batteryAccessory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,YAAY,EAAE,CAAC;IACf,QAAQ,EAAE,CAAC;IACX,cAAc,EAAE,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,sBAAsB;IAC/D;;QAEI;IACa,cAAc,CAAU;IAEzC;;OAEG;IACK,YAAY,GAAG,CAAC,CAAC;IAEzB;;OAEG;IACK,kBAAkB,GAAG,sBAAsB,CAAC,YAAY,CAAC;IAEjE;;;;;;;OAOG;IACH,YAAY,GAAY,EAAE,GAAQ,EAAE,IAAY,EAAE,MAAc,EAAE,KAAa;QAC7E,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAErC,IAA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cAAc,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IAC7F,CAAC;IAED;;;OAGG;IACI,mBAAmB;QACxB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO,CAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,cAAc,CAAE,CAAC;IAC1D,CAAC;CAEF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { API } from 'homebridge';
|
|
2
|
-
declare const _default: (api: API) => void;
|
|
3
2
|
/**
|
|
4
3
|
* This method registers the platform with Homebridge
|
|
5
4
|
*/
|
|
6
|
-
|
|
5
|
+
declare const _default: (api: API) => void;
|
|
6
|
+
export default _default;
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAKjC;;GAEG;yBACa,KAAK,GAAG;AAAxB,wBAEE"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { PLATFORM_NAME } from './settings.js';
|
|
2
|
+
import { SolaxCloudAPIPlatform } from './platform.js';
|
|
3
|
+
/**
|
|
4
|
+
* This method registers the platform with Homebridge
|
|
5
|
+
*/
|
|
6
|
+
export default (api) => {
|
|
7
|
+
api.registerPlatform(PLATFORM_NAME, SolaxCloudAPIPlatform);
|
|
6
8
|
};
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD;;GAEG;AACH,eAAe,CAAC,GAAQ,EAAE,EAAE;IAC1B,GAAG,CAAC,gBAAgB,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;AAC7D,CAAC,CAAC"}
|
|
@@ -1,35 +1,42 @@
|
|
|
1
1
|
import { AccessoryPlugin, API, CharacteristicGetCallback, Logging, Service } from 'homebridge';
|
|
2
|
-
import { SolaxPlatformAccessory } from './platformAccessory';
|
|
2
|
+
import { SolaxPlatformAccessory } from './platformAccessory.js';
|
|
3
3
|
/**
|
|
4
|
-
* Solax
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Using Lux to display power comsumption.
|
|
4
|
+
* Solax Power Sensor Accessory (Upgraded to Matter).
|
|
5
|
+
* Exposes power consumption directly to Apple Home Energy via Matter,
|
|
6
|
+
* or falls back to a virtual light sensor for older HAP setups.
|
|
8
7
|
*/
|
|
9
8
|
export declare class SolaxLightSensorAccessory extends SolaxPlatformAccessory implements AccessoryPlugin {
|
|
10
|
-
private readonly lightService
|
|
9
|
+
private readonly lightService?;
|
|
10
|
+
private readonly matterApi?;
|
|
11
|
+
private readonly matterUuid?;
|
|
12
|
+
private readonly matterRegistration?;
|
|
13
|
+
private readonly published;
|
|
14
|
+
private currentPowerW;
|
|
11
15
|
/**
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
private lux;
|
|
15
|
-
/**
|
|
16
|
-
* Solax virtual light sensor class constructor.
|
|
16
|
+
* Solax virtual light/power sensor class constructor.
|
|
17
17
|
* @param {Logging} log The platform logging for homebridge.
|
|
18
18
|
* @param {API} api The platform API.
|
|
19
19
|
* @param {string} name The accessory name.
|
|
20
20
|
* @param {string} serial "Real world" serial number for this accessory.
|
|
21
21
|
* @param {string} model Accessory model.
|
|
22
22
|
*/
|
|
23
|
-
constructor(log: Logging, api: API, name: string, serial: string, model: string);
|
|
23
|
+
constructor(log: Logging, api: API, name: string, serial: string, model: string, supportsEnergy?: boolean, published?: boolean);
|
|
24
24
|
/**
|
|
25
|
-
* Gets the current
|
|
25
|
+
* Gets the current power consumption in Watts.
|
|
26
26
|
*/
|
|
27
27
|
getAmbientLightLevel(callback: CharacteristicGetCallback): void;
|
|
28
28
|
/**
|
|
29
|
-
* Sets the current
|
|
30
|
-
* @param {number}
|
|
29
|
+
* Sets the current power consumption in Watts.
|
|
30
|
+
* @param {number} power The power consumption value to set (previously lux).
|
|
31
|
+
*/
|
|
32
|
+
setAmbientLightLevel(power: number): void;
|
|
33
|
+
/**
|
|
34
|
+
* Sets cumulative generated energy in Watt-hours.
|
|
35
|
+
* @param {number} energyWh The cumulative generated energy in Watt-hours.
|
|
31
36
|
*/
|
|
32
|
-
|
|
37
|
+
setTotalEnergyConsumption(energyWh: number): void;
|
|
38
|
+
isMatterAccessory(): boolean;
|
|
39
|
+
private updateMatterState;
|
|
33
40
|
getServices(): Service[];
|
|
34
41
|
}
|
|
35
42
|
//# sourceMappingURL=lightSensorAccessory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lightSensorAccessory.d.ts","sourceRoot":"","sources":["../src/lightSensorAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"lightSensorAccessory.d.ts","sourceRoot":"","sources":["../src/lightSensorAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,GAAG,EAEH,yBAAyB,EACzB,OAAO,EAGP,OAAO,EACR,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGhE;;;;GAIG;AACH,qBAAa,yBAA0B,SAAQ,sBAAuB,YAAW,eAAe;IAC9F,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAU;IACxC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAY;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAmB;IACvD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;IACpC,OAAO,CAAC,aAAa,CAAK;IAE1B;;;;;;;OAOG;gBAED,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,cAAc,UAAQ,EACtB,SAAS,UAAO;IA4DlB;;OAEG;IACI,oBAAoB,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI;IAMtE;;;OAGG;IACI,oBAAoB,CAAC,KAAK,EAAE,MAAM;IAczC;;;OAGG;IACI,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAejD,iBAAiB,IAAI,OAAO;IAInC,OAAO,CAAC,iBAAiB;IAsBzB,WAAW,IAAI,OAAO,EAAE;CAMzB"}
|
|
@@ -1,59 +1,136 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.SolaxLightSensorAccessory = void 0;
|
|
4
|
-
const platformAccessory_1 = require("./platformAccessory");
|
|
1
|
+
import { SolaxPlatformAccessory } from './platformAccessory.js';
|
|
2
|
+
import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js';
|
|
5
3
|
/**
|
|
6
|
-
* Solax
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Using Lux to display power comsumption.
|
|
4
|
+
* Solax Power Sensor Accessory (Upgraded to Matter).
|
|
5
|
+
* Exposes power consumption directly to Apple Home Energy via Matter,
|
|
6
|
+
* or falls back to a virtual light sensor for older HAP setups.
|
|
10
7
|
*/
|
|
11
|
-
class SolaxLightSensorAccessory extends
|
|
8
|
+
export class SolaxLightSensorAccessory extends SolaxPlatformAccessory {
|
|
9
|
+
lightService;
|
|
10
|
+
matterApi;
|
|
11
|
+
matterUuid;
|
|
12
|
+
matterRegistration;
|
|
13
|
+
published;
|
|
14
|
+
currentPowerW = 0;
|
|
12
15
|
/**
|
|
13
|
-
* Solax virtual light sensor class constructor.
|
|
16
|
+
* Solax virtual light/power sensor class constructor.
|
|
14
17
|
* @param {Logging} log The platform logging for homebridge.
|
|
15
18
|
* @param {API} api The platform API.
|
|
16
19
|
* @param {string} name The accessory name.
|
|
17
20
|
* @param {string} serial "Real world" serial number for this accessory.
|
|
18
21
|
* @param {string} model Accessory model.
|
|
19
22
|
*/
|
|
20
|
-
constructor(log, api, name, serial, model) {
|
|
23
|
+
constructor(log, api, name, serial, model, supportsEnergy = false, published = true) {
|
|
21
24
|
super(log, api, name, serial, model);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
.
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
this.log.debug(`Creating power sensor "${this.name}"`);
|
|
26
|
+
this.published = published;
|
|
27
|
+
if (!published) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
this.matterApi = this.api.matter;
|
|
31
|
+
if (this.matterApi) {
|
|
32
|
+
this.matterUuid = this.api.hap.uuid.generate(serial + '-matter-power');
|
|
33
|
+
const clusters = {
|
|
34
|
+
electricalPowerMeasurement: {
|
|
35
|
+
activePower: 0,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
if (supportsEnergy) {
|
|
39
|
+
clusters.electricalEnergyMeasurement = {
|
|
40
|
+
cumulativeEnergyExported: { energy: 0 },
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const matterAccessory = {
|
|
44
|
+
displayName: name,
|
|
45
|
+
UUID: this.matterUuid,
|
|
46
|
+
deviceType: this.matterApi.deviceTypes.ElectricalSensor,
|
|
47
|
+
serialNumber: serial,
|
|
48
|
+
manufacturer: 'Solax',
|
|
49
|
+
model,
|
|
50
|
+
context: {},
|
|
51
|
+
clusters,
|
|
52
|
+
};
|
|
53
|
+
this.matterRegistration = this.matterApi
|
|
54
|
+
.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [matterAccessory])
|
|
55
|
+
.then(() => {
|
|
56
|
+
log.info(`Matter Electrical Sensor (Watts) "${name}" created!`);
|
|
57
|
+
return true;
|
|
58
|
+
})
|
|
59
|
+
.catch(error => {
|
|
60
|
+
log.error(`Failed to register Matter accessory "${name}": ${error}`);
|
|
61
|
+
return false;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.lightService = new this.api.hap.Service.LightSensor(name);
|
|
66
|
+
this.lightService
|
|
67
|
+
.getCharacteristic(this.api.hap.Characteristic.CurrentAmbientLightLevel)
|
|
68
|
+
.on("get" /* CharacteristicEventTypes.GET */, this.getAmbientLightLevel.bind(this));
|
|
69
|
+
log.info(`Light sensor (watts reader) "${name}" created!`);
|
|
70
|
+
}
|
|
32
71
|
}
|
|
33
72
|
/**
|
|
34
|
-
* Gets the current
|
|
73
|
+
* Gets the current power consumption in Watts.
|
|
35
74
|
*/
|
|
36
75
|
getAmbientLightLevel(callback) {
|
|
37
|
-
this.log.debug(`${this.name}: GET
|
|
38
|
-
callback(null, this.
|
|
76
|
+
this.log.debug(`${this.name}: GET Power Level (W=${this.currentPowerW})`);
|
|
77
|
+
callback(null, Math.max(0.1, this.currentPowerW));
|
|
39
78
|
}
|
|
40
79
|
/**
|
|
41
|
-
* Sets the current
|
|
42
|
-
* @param {number}
|
|
80
|
+
* Sets the current power consumption in Watts.
|
|
81
|
+
* @param {number} power The power consumption value to set (previously lux).
|
|
43
82
|
*/
|
|
44
|
-
setAmbientLightLevel(
|
|
45
|
-
this.log.debug(`${this.name}: SET
|
|
46
|
-
|
|
47
|
-
this.
|
|
48
|
-
|
|
83
|
+
setAmbientLightLevel(power) {
|
|
84
|
+
this.log.debug(`${this.name}: SET Power (W=${power})`);
|
|
85
|
+
this.currentPowerW = power;
|
|
86
|
+
if (this.matterApi && this.matterUuid) {
|
|
87
|
+
this.updateMatterState(this.matterApi.clusterNames.ElectricalPowerMeasurement, { activePower: Math.round(power * 1000) });
|
|
88
|
+
}
|
|
89
|
+
else if (this.lightService) {
|
|
90
|
+
this.lightService.updateCharacteristic(this.api.hap.Characteristic.CurrentAmbientLightLevel, Math.max(0.1, power));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Sets cumulative generated energy in Watt-hours.
|
|
95
|
+
* @param {number} energyWh The cumulative generated energy in Watt-hours.
|
|
96
|
+
*/
|
|
97
|
+
setTotalEnergyConsumption(energyWh) {
|
|
98
|
+
if (!this.matterApi || !this.matterUuid) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this.updateMatterState(this.matterApi.clusterNames.ElectricalEnergyMeasurement, {
|
|
102
|
+
cumulativeEnergyExported: {
|
|
103
|
+
energy: Math.round(energyWh * 1000),
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
isMatterAccessory() {
|
|
108
|
+
return Boolean(this.matterApi);
|
|
109
|
+
}
|
|
110
|
+
updateMatterState(cluster, attributes) {
|
|
111
|
+
if (!this.matterApi || !this.matterUuid || !this.matterRegistration) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
void this.matterRegistration
|
|
115
|
+
.then(registered => {
|
|
116
|
+
if (!registered) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
return this.matterApi.updateAccessoryState(this.matterUuid, cluster, attributes);
|
|
120
|
+
})
|
|
121
|
+
.catch(error => {
|
|
122
|
+
this.log.error(`Failed to update Matter accessory "${this.name}": ${error}`);
|
|
123
|
+
});
|
|
49
124
|
}
|
|
50
125
|
/*
|
|
51
126
|
* This method is called directly after creation of this instance.
|
|
52
127
|
* It should return all services which should be added to the accessory.
|
|
53
128
|
*/
|
|
54
129
|
getServices() {
|
|
130
|
+
if (!this.published || this.matterApi) {
|
|
131
|
+
return [this.informationService];
|
|
132
|
+
}
|
|
55
133
|
return [this.informationService, this.lightService];
|
|
56
134
|
}
|
|
57
135
|
}
|
|
58
|
-
exports.SolaxLightSensorAccessory = SolaxLightSensorAccessory;
|
|
59
136
|
//# sourceMappingURL=lightSensorAccessory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lightSensorAccessory.js","sourceRoot":"","sources":["../src/lightSensorAccessory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lightSensorAccessory.js","sourceRoot":"","sources":["../src/lightSensorAccessory.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE3D;;;;GAIG;AACH,MAAM,OAAO,yBAA0B,SAAQ,sBAAsB;IAClD,YAAY,CAAW;IACvB,SAAS,CAAa;IACtB,UAAU,CAAU;IACpB,kBAAkB,CAAoB;IACtC,SAAS,CAAU;IAC5B,aAAa,GAAG,CAAC,CAAC;IAE1B;;;;;;;OAOG;IACH,YACE,GAAY,EACZ,GAAQ,EACR,IAAY,EACZ,MAAc,EACd,KAAa,EACb,cAAc,GAAG,KAAK,EACtB,SAAS,GAAG,IAAI;QAEhB,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAErC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,0BAA0B,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO;QACT,C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,kBAAkB,EAAE,IAAI,CAAC,YAAa,CAAE,CAAC;IACzD,CAAC;CACF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Service, AccessoryPlugin, Logging, CharacteristicGetCallback, API } from 'homebridge';
|
|
3
|
-
import { SolaxPlatformAccessory } from './platformAccessory';
|
|
2
|
+
import { SolaxPlatformAccessory } from './platformAccessory.js';
|
|
4
3
|
/**
|
|
5
4
|
* Solax Motion Accessory.
|
|
6
5
|
* Virtual motion sensor triggered whenever new data is fetched from Solax Cloud.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motionAccessory.d.ts","sourceRoot":"","sources":["../src/motionAccessory.ts"],"names":[],"mappings":"
|
|
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,GAAG,EAAE,MAAM,YAAY,CAAC;AAI/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAOhE;;;;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;IAE/C;;;;;;;OAOG;gBACS,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAa/E,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
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SolaxMotionAccessory = void 0;
|
|
7
|
-
const util_1 = __importDefault(require("util"));
|
|
8
|
-
const platformAccessory_1 = require("./platformAccessory");
|
|
1
|
+
import util from 'util';
|
|
2
|
+
import { SolaxPlatformAccessory } from './platformAccessory.js';
|
|
9
3
|
/**
|
|
10
4
|
* Motion timeout in seconds.
|
|
11
5
|
*/
|
|
@@ -15,7 +9,19 @@ const MOTION_TIMEOUT = 5;
|
|
|
15
9
|
* Virtual motion sensor triggered whenever new data is fetched from Solax Cloud.
|
|
16
10
|
* Sensor will automatically clear itself after MOTION_TIMEOUT seconds (defaults to 5 seconds).
|
|
17
11
|
*/
|
|
18
|
-
class SolaxMotionAccessory extends
|
|
12
|
+
export class SolaxMotionAccessory extends SolaxPlatformAccessory {
|
|
13
|
+
/**
|
|
14
|
+
* Homekit Motion Service for this accessory.
|
|
15
|
+
*/
|
|
16
|
+
motionService;
|
|
17
|
+
/**
|
|
18
|
+
* Whether motion is detected (Solax Cloud data updated).
|
|
19
|
+
*/
|
|
20
|
+
motion = false;
|
|
21
|
+
/**
|
|
22
|
+
* Interval before clearing motion (in seconds).
|
|
23
|
+
*/
|
|
24
|
+
motionTimeout = MOTION_TIMEOUT;
|
|
19
25
|
/**
|
|
20
26
|
* Solax virtual motion sensor class constructor.
|
|
21
27
|
* @param {Logging} log The platform logging for homebridge.
|
|
@@ -26,22 +32,14 @@ class SolaxMotionAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
|
26
32
|
*/
|
|
27
33
|
constructor(log, api, name, serial, model) {
|
|
28
34
|
super(log, api, name, serial, model);
|
|
29
|
-
/**
|
|
30
|
-
* Whether motion is detected (Solax Cloud data updated).
|
|
31
|
-
*/
|
|
32
|
-
this.motion = false;
|
|
33
|
-
/**
|
|
34
|
-
* Interval before clearing motion (in seconds).
|
|
35
|
-
*/
|
|
36
|
-
this.motionTimeout = MOTION_TIMEOUT;
|
|
37
|
-
this.sleep = util_1.default.promisify(setTimeout);
|
|
38
35
|
this.log.debug(`Creating motion sensor "${this.name}"`);
|
|
39
36
|
this.motionService = new this.api.hap.Service.MotionSensor(this.name);
|
|
40
37
|
this.motionService
|
|
41
38
|
.getCharacteristic(this.api.hap.Characteristic.MotionDetected)
|
|
42
|
-
.on("get" /* GET */, this.getState.bind(this));
|
|
39
|
+
.on("get" /* this.api.hap.CharacteristicEventTypes.GET */, this.getState.bind(this));
|
|
43
40
|
log.info(`Motion sensor "${name}" created!`);
|
|
44
41
|
}
|
|
42
|
+
sleep = util.promisify(setTimeout);
|
|
45
43
|
/**
|
|
46
44
|
* Gets the motion sensor state Characteristic.
|
|
47
45
|
* @param {CharacteristicGetCallback} callback The callback.
|
|
@@ -90,5 +88,4 @@ class SolaxMotionAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
|
90
88
|
];
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
|
-
exports.SolaxMotionAccessory = SolaxMotionAccessory;
|
|
94
91
|
//# sourceMappingURL=motionAccessory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motionAccessory.js","sourceRoot":"","sources":["../src/motionAccessory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"motionAccessory.js","sourceRoot":"","sources":["../src/motionAccessory.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;GAEG;AACH,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB;;;;GA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QAE7D,IAAI,CAAC,aAAa;aACf,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,cAAc,CAAC;aAC7D,WAAW,CAAC,MAAM,CAAC,CAAC;QAEvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,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;QACzE,CAAC;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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Service, AccessoryPlugin, Logging, CharacteristicGetCallback, API } from 'homebridge';
|
|
2
|
-
import { SolaxPlatformAccessory } from './platformAccessory';
|
|
2
|
+
import { SolaxPlatformAccessory } from './platformAccessory.js';
|
|
3
3
|
/**
|
|
4
4
|
* Solax Outlet Accessory.
|
|
5
5
|
* Virtual outlet used to monitor and measure both power and total energy consumption from Solax devices.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outletAccessory.d.ts","sourceRoot":"","sources":["../src/outletAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAkB,yBAAyB,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAE/G,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
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