@pietrolubini/homebridge-ecoflow 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/config.schema.json +17 -0
- package/dist/accessories/batteries/batteryAccessory.js +11 -5
- package/dist/accessories/batteries/batteryAccessory.js.map +1 -1
- package/dist/accessories/ecoFlowAccessory.js +3 -0
- package/dist/accessories/ecoFlowAccessory.js.map +1 -1
- package/dist/apis/ecoFlowHttpApi.js +0 -1
- package/dist/apis/ecoFlowHttpApi.js.map +1 -1
- package/dist/characteristics/CustomCharacteristic.d.ts +16 -0
- package/dist/characteristics/CustomCharacteristic.js +78 -0
- package/dist/characteristics/CustomCharacteristic.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.js +6 -0
- package/dist/config.js.map +1 -1
- package/dist/helpers/logger.js +6 -6
- package/dist/helpers/logger.js.map +1 -1
- package/dist/platform.d.ts +6 -3
- package/dist/platform.js +23 -11
- package/dist/platform.js.map +1 -1
- package/dist/services/accessoryInformationService.d.ts +2 -1
- package/dist/services/accessoryInformationService.js +16 -8
- package/dist/services/accessoryInformationService.js.map +1 -1
- package/dist/services/{batteryService.d.ts → batteryStatusService.d.ts} +3 -2
- package/dist/services/batteryStatusService.js +32 -0
- package/dist/services/batteryStatusService.js.map +1 -0
- package/dist/services/outletServiceBase.d.ts +11 -4
- package/dist/services/outletServiceBase.js +43 -19
- package/dist/services/outletServiceBase.js.map +1 -1
- package/dist/services/serviceBase.d.ts +14 -1
- package/dist/services/serviceBase.js +35 -0
- package/dist/services/serviceBase.js.map +1 -1
- package/docs/images/BatteryAdditionalCharacteristics.jpg +0 -0
- package/package.json +1 -1
- package/dist/services/batteryService.js +0 -29
- package/dist/services/batteryService.js.map +0 -1
package/README.md
CHANGED
|
@@ -64,6 +64,37 @@ Example configuration:
|
|
|
64
64
|
}
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
+
### Battery-specific Configuration
|
|
68
|
+
|
|
69
|
+
If `devices`.`model` is one of [`Delta 2`, `Delta 2 Max`] it is possible to set turn on/off additional characteristics:
|
|
70
|
+
|
|
71
|
+
- Input Consumption, W
|
|
72
|
+
- Output Consumption, W
|
|
73
|
+
- Battery Level, %
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
{
|
|
77
|
+
...
|
|
78
|
+
"devices": [
|
|
79
|
+
{
|
|
80
|
+
...,
|
|
81
|
+
"model": "Delta 2 Max",
|
|
82
|
+
"battery": {
|
|
83
|
+
"additionalCharacteristics": [
|
|
84
|
+
"Battery Level, %",
|
|
85
|
+
"Input Consumption, W",
|
|
86
|
+
"Output Consumption, W"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The characteristics could be used as conditions in HomeKit Automation that uses Shortcuts:
|
|
95
|
+
|
|
96
|
+
<img src="docs/images/BatteryAdditionalCharacteristics.jpg" alt="Battery Additional Characteristics" width="300">
|
|
97
|
+
|
|
67
98
|
### AccessKey and SecretKey
|
|
68
99
|
|
|
69
100
|
For the plugin to work EcoFlow account's `AccessKey` and `SecretKey` is required. To retrieve them
|
package/config.schema.json
CHANGED
|
@@ -47,6 +47,23 @@
|
|
|
47
47
|
"type": "string",
|
|
48
48
|
"required": true,
|
|
49
49
|
"description": "Secret Key from \"EcoFlow IoT Developer Platform\" (https://developer-eu.ecoflow.com)"
|
|
50
|
+
},
|
|
51
|
+
"battery": {
|
|
52
|
+
"title": "Battery Settings",
|
|
53
|
+
"type": "object",
|
|
54
|
+
"properties": {
|
|
55
|
+
"additionalCharacteristics": {
|
|
56
|
+
"title": "Additional characteristics",
|
|
57
|
+
"description": "List of additional characteristics for battery",
|
|
58
|
+
"type": "array",
|
|
59
|
+
"uniqueItems": true,
|
|
60
|
+
"items": {
|
|
61
|
+
"title": "Characteristic",
|
|
62
|
+
"type": "string",
|
|
63
|
+
"enum": ["Battery Level, %", "Input Consumption, W", "Output Consumption, W"]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
50
67
|
}
|
|
51
68
|
}
|
|
52
69
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MqttMessageType } from '../../apis/ecoFlowMqttApi.js';
|
|
2
|
-
import {
|
|
2
|
+
import { BatteryStatusService } from '../../services/batteryStatusService.js';
|
|
3
3
|
import { OutletAcService } from '../../services/outletAcService.js';
|
|
4
4
|
import { OutletCarService } from '../../services/outletCarService.js';
|
|
5
5
|
import { OutletUsbService } from '../../services/outletUsbService.js';
|
|
@@ -11,7 +11,7 @@ export class BatteryAccessory extends EcoFlowAccessoryWithQuota {
|
|
|
11
11
|
outletCarService;
|
|
12
12
|
constructor(platform, accessory, config, log) {
|
|
13
13
|
super(platform, accessory, config, log);
|
|
14
|
-
this.batteryService = new
|
|
14
|
+
this.batteryService = new BatteryStatusService(this);
|
|
15
15
|
this.outletUsbService = new OutletUsbService(this);
|
|
16
16
|
this.outletAcService = new OutletAcService(this);
|
|
17
17
|
this.outletCarService = new OutletCarService(this);
|
|
@@ -69,17 +69,23 @@ export class BatteryAccessory extends EcoFlowAccessoryWithQuota {
|
|
|
69
69
|
if (params.f32ShowSoc !== undefined) {
|
|
70
70
|
this.batteryService.updateStatusLowBattery(params.f32ShowSoc);
|
|
71
71
|
this.batteryService.updateBatteryLevel(params.f32ShowSoc);
|
|
72
|
+
this.outletAcService.updateBatteryLevel(params.f32ShowSoc);
|
|
73
|
+
this.outletUsbService.updateBatteryLevel(params.f32ShowSoc);
|
|
74
|
+
this.outletCarService.updateBatteryLevel(params.f32ShowSoc);
|
|
72
75
|
}
|
|
73
76
|
}
|
|
74
77
|
updateInvValues(params) {
|
|
75
78
|
if (params.inputWatts !== undefined) {
|
|
76
79
|
this.batteryService.updateChargingState(params.inputWatts);
|
|
80
|
+
this.outletAcService.updateInputConsumption(params.inputWatts);
|
|
81
|
+
this.outletUsbService.updateInputConsumption(params.inputWatts);
|
|
82
|
+
this.outletCarService.updateInputConsumption(params.inputWatts);
|
|
77
83
|
}
|
|
78
84
|
if (params.cfgAcEnabled !== undefined) {
|
|
79
85
|
this.outletAcService.updateState(params.cfgAcEnabled);
|
|
80
86
|
}
|
|
81
87
|
if (params.outputWatts !== undefined) {
|
|
82
|
-
this.outletAcService.
|
|
88
|
+
this.outletAcService.updateOutputConsumption(params.outputWatts);
|
|
83
89
|
}
|
|
84
90
|
}
|
|
85
91
|
updatePdValues(params) {
|
|
@@ -87,7 +93,7 @@ export class BatteryAccessory extends EcoFlowAccessoryWithQuota {
|
|
|
87
93
|
this.outletCarService.updateState(params.carState);
|
|
88
94
|
}
|
|
89
95
|
if (params.carWatts !== undefined) {
|
|
90
|
-
this.outletCarService.
|
|
96
|
+
this.outletCarService.updateOutputConsumption(params.carWatts);
|
|
91
97
|
}
|
|
92
98
|
if (params.dcOutState !== undefined) {
|
|
93
99
|
this.outletUsbService.updateState(params.dcOutState);
|
|
@@ -99,7 +105,7 @@ export class BatteryAccessory extends EcoFlowAccessoryWithQuota {
|
|
|
99
105
|
params.typec1Watts !== undefined ||
|
|
100
106
|
params.typec2Watts !== undefined) {
|
|
101
107
|
const usbWatts = this.getUsbWatts(params.usb1Watts, params.usb2Watts, params.qcUsb1Watts, params.qcUsb2Watts, params.typec1Watts, params.typec2Watts);
|
|
102
|
-
this.outletUsbService.
|
|
108
|
+
this.outletUsbService.updateOutputConsumption(usbWatts);
|
|
103
109
|
}
|
|
104
110
|
}
|
|
105
111
|
getUsbWatts(usb1Watts, usb2Watts, qcUsb1Watts, qcUsb2Watts, typec1Watts, typec2Watts) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batteryAccessory.js","sourceRoot":"","sources":["../../../src/accessories/batteries/batteryAccessory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAgD,MAAM,8BAA8B,CAAC;AAG7G,OAAO,EAAE,
|
|
1
|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,CAAC,WAAW,EAClB,MAAM,CAAC,WAAW,CACnB,CAAC;YACF,IAAI,CAAC,gBAAiB,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAEO,WAAW,CACjB,SAAkB,EAClB,SAAkB,EAClB,WAAoB,EACpB,WAAoB,EACpB,WAAoB,EACpB,WAAoB;QAEpB,OAAO,CACL,CAAC,SAAS,IAAI,CAAC,CAAC;YAChB,CAAC,SAAS,IAAI,CAAC,CAAC;YAChB,CAAC,WAAW,IAAI,CAAC,CAAC;YAClB,CAAC,WAAW,IAAI,CAAC,CAAC;YAClB,CAAC,WAAW,IAAI,CAAC,CAAC;YAClB,CAAC,WAAW,IAAI,CAAC,CAAC,CACnB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -81,6 +81,9 @@ export class EcoFlowAccessory {
|
|
|
81
81
|
this.log.info('Removing obsolete service from accessory:', service.displayName);
|
|
82
82
|
this.accessory.removeService(service);
|
|
83
83
|
});
|
|
84
|
+
this.services
|
|
85
|
+
.filter(service => this.accessory.services.includes(service.service))
|
|
86
|
+
.forEach(service => service.cleanupCharacteristics());
|
|
84
87
|
}
|
|
85
88
|
async connectMqtt() {
|
|
86
89
|
await this.initMqtt();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecoFlowAccessory.js","sourceRoot":"","sources":["../../src/accessories/ecoFlowAccessory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EACL,cAAc,GAKf,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAGzF,MAAM,OAAgB,gBAAgB;IAUlB;IACA;IACA;IACA;IAZC,OAAO,CAAiB;IACxB,OAAO,CAAiB;IACnC,QAAQ,GAAkB,EAAE,CAAC;IAC7B,sBAAsB,GAA0B,IAAI,CAAC;IACrD,eAAe,GAAY,KAAK,CAA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pB,IAAI,CAAC,eAAe;YAClB,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;gBAC/D,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IACvE,CAAC;CACF;AAED,MAAM,OAAgB,yBAAyC,SAAQ,gBAAgB;IAC7E,MAAM,GAAyB,IAAI,CAAC;IAE5B,KAAK,CAAC,UAAU;QAC9B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,EAAiB,CAAC;QACjE,CAAC;QACD,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC;QACzB,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAO,CAAC;IACtB,CAAC;CAGF"}
|
|
@@ -48,7 +48,6 @@ export class EcoFlowHttpApi {
|
|
|
48
48
|
this.log.debug('Acquire certificate for MQTT connection');
|
|
49
49
|
const response = await this.execute(CertificatePath, HttpMethod.Get);
|
|
50
50
|
if (!response.failed) {
|
|
51
|
-
this.log.debug('Certificate data:', response.data);
|
|
52
51
|
return response.data;
|
|
53
52
|
}
|
|
54
53
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecoFlowHttpApi.js","sourceRoot":"","sources":["../../src/apis/ecoFlowHttpApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAIjC,MAAM,MAAM,GAAG,2BAA2B,CAAC;AAC3C,MAAM,SAAS,GAAG,6BAA6B,CAAC;AAChD,MAAM,YAAY,GAAG,iCAAiC,CAAC;AACvD,MAAM,eAAe,GAAG,8BAA8B,CAAC;AA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AAM,aAAa,GAEf,EAAE,CAAC;QACN,OAAO,CAAC,OAAmB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAClD,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,MAAM,UAAU,GAAG;YACjB,GAAG,OAAO;YACV,OAAO,EAAE,aAAa;SACvB,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IAEO,WAAW,CAAQ,IAAU;QACnC,MAAM,MAAM,GAAS,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC9B,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC5B,IAAI,OAAO,GAAG,MAAM,CAAC;YAErB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;gBACxB,IAAI,KAAK,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC9B,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;gBACzB,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;oBAC9B,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;gBACvB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,MAAe,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Characteristic } from 'hap-nodejs';
|
|
2
|
+
export declare class InputConsumptionWatt extends Characteristic {
|
|
3
|
+
static readonly UUID: string;
|
|
4
|
+
constructor();
|
|
5
|
+
}
|
|
6
|
+
export declare class OutputConsumptionWatt extends Characteristic {
|
|
7
|
+
static readonly UUID: string;
|
|
8
|
+
constructor();
|
|
9
|
+
}
|
|
10
|
+
export declare class PowerConsumption {
|
|
11
|
+
static readonly InputConsumptionWatts: typeof InputConsumptionWatt;
|
|
12
|
+
static readonly OutputConsumptionWatts: typeof OutputConsumptionWatt;
|
|
13
|
+
}
|
|
14
|
+
export declare class CustomCharacteristic {
|
|
15
|
+
static readonly PowerConsumption: typeof PowerConsumption;
|
|
16
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Characteristic } from 'hap-nodejs';
|
|
2
|
+
export class InputConsumptionWatt extends Characteristic {
|
|
3
|
+
static UUID = '13172B0A-D346-4730-9732-32EF5B6EF8B7';
|
|
4
|
+
constructor() {
|
|
5
|
+
super('Input Consumption', InputConsumptionWatt.UUID, {
|
|
6
|
+
description: 'Input Consumption, W',
|
|
7
|
+
format: "float" /* Formats.FLOAT */,
|
|
8
|
+
perms: ["ev" /* Perms.NOTIFY */, "pr" /* Perms.PAIRED_READ */],
|
|
9
|
+
minValue: 0,
|
|
10
|
+
minStep: 1,
|
|
11
|
+
unit: "celsius" /* Units.CELSIUS */, // To allow setting numeric value for conditions in ShortCuts
|
|
12
|
+
});
|
|
13
|
+
this.value = this.getDefaultValue();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class OutputConsumptionWatt extends Characteristic {
|
|
17
|
+
// Eve characteristic
|
|
18
|
+
static UUID = 'E863F10D-079E-48FF-8F27-9C2605A29F52';
|
|
19
|
+
constructor() {
|
|
20
|
+
super('Output Consumption', OutputConsumptionWatt.UUID, {
|
|
21
|
+
description: 'Output Consumption, W',
|
|
22
|
+
format: "float" /* Formats.FLOAT */,
|
|
23
|
+
perms: ["ev" /* Perms.NOTIFY */, "pr" /* Perms.PAIRED_READ */],
|
|
24
|
+
unit: "celsius" /* Units.CELSIUS */, // To allow setting numeric value for conditions in ShortCuts
|
|
25
|
+
minValue: 0,
|
|
26
|
+
minStep: 1,
|
|
27
|
+
});
|
|
28
|
+
this.value = this.getDefaultValue();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// https://gist.github.com/simont77/3f4d4330fa55b83f8ca96388d9004e7d
|
|
32
|
+
// export class PowerConsumptionVolt extends Characteristic {
|
|
33
|
+
// public static readonly UUID: string = 'E863F10A-079E-48FF-8F27-9C2605A29F52';
|
|
34
|
+
// constructor() {
|
|
35
|
+
// super('Voltage', PowerConsumptionVolt.UUID, {
|
|
36
|
+
// description: '"Voltage, V" in Eve App',
|
|
37
|
+
// format: Formats.FLOAT,
|
|
38
|
+
// perms: [Perms.NOTIFY, Perms.PAIRED_READ],
|
|
39
|
+
// minValue: 0,
|
|
40
|
+
// maxValue: 300,
|
|
41
|
+
// });
|
|
42
|
+
// this.value = this.getDefaultValue();
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
45
|
+
// export class PowerConsumptionAmpere extends Characteristic {
|
|
46
|
+
// public static readonly UUID: string = 'E863F126-079E-48FF-8F27-9C2605A29F52';
|
|
47
|
+
// constructor() {
|
|
48
|
+
// super('Current', PowerConsumptionAmpere.UUID, {
|
|
49
|
+
// description: '"Current, A" in Eve App',
|
|
50
|
+
// format: Formats.FLOAT,
|
|
51
|
+
// perms: [Perms.NOTIFY, Perms.PAIRED_READ],
|
|
52
|
+
// minValue: 0,
|
|
53
|
+
// maxValue: 100,
|
|
54
|
+
// });
|
|
55
|
+
// this.value = this.getDefaultValue();
|
|
56
|
+
// }
|
|
57
|
+
// }
|
|
58
|
+
// export class PowerConsumptionKilowattHour extends Characteristic {
|
|
59
|
+
// public static readonly UUID: string = 'E863F10C-079E-48FF-8F27-9C2605A29F52';
|
|
60
|
+
// constructor() {
|
|
61
|
+
// super('Total Consumption', PowerConsumptionKilowattHour.UUID, {
|
|
62
|
+
// description: '"Total Consumption, kW/h" in Eve App',
|
|
63
|
+
// format: Formats.FLOAT,
|
|
64
|
+
// perms: [Perms.NOTIFY, Perms.PAIRED_READ],
|
|
65
|
+
// minValue: 0,
|
|
66
|
+
// maxValue: 50,
|
|
67
|
+
// });
|
|
68
|
+
// this.value = this.getDefaultValue();
|
|
69
|
+
// }
|
|
70
|
+
// }
|
|
71
|
+
export class PowerConsumption {
|
|
72
|
+
static InputConsumptionWatts = InputConsumptionWatt;
|
|
73
|
+
static OutputConsumptionWatts = OutputConsumptionWatt;
|
|
74
|
+
}
|
|
75
|
+
export class CustomCharacteristic {
|
|
76
|
+
static PowerConsumption = PowerConsumption;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=CustomCharacteristic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomCharacteristic.js","sourceRoot":"","sources":["../../src/characteristics/CustomCharacteristic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,MAAM,OAAO,oBAAqB,SAAQ,cAAc;IAC/C,MAAM,CAAU,IAAI,GAAW,sCAAsC,CAAC;IAC7E;QACE,KAAK,CAAC,mBAAmB,EAAE,oBAAoB,CAAC,IAAI,EAAE;YACpD,WAAW,EAAE,sBAAsB;YACnC,MAAM,6BAAe;YACrB,KAAK,EAAE,uDAAiC;YACxC,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,CAAC;YACV,IAAI,+BAAe,EAAE,6DAA6D;SACnF,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;IACtC,CAAC;;AAGH,MAAM,OAAO,qBAAsB,SAAQ,cAAc;IACvD,qBAAqB;IACd,MAAM,CAAU,IAAI,GAAW,sCAAsC,CAAC;IAC7E;QACE,KAAK,CAAC,oBAAoB,EAAE,qBAAqB,CAAC,IAAI,EAAE;YACtD,WAAW,EAAE,uBAAuB;YACpC,MAAM,6BAAe;YACrB,KAAK,EAAE,uDAAiC;YACxC,IAAI,+BAAe,EAAE,6DAA6D;YAClF,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,CAAC;SACX,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;IACtC,CAAC;;AAGH,oEAAoE;AACpE,6DAA6D;AAC7D,kFAAkF;AAClF,oBAAoB;AACpB,oDAAoD;AACpD,gDAAgD;AAChD,+BAA+B;AAC/B,kDAAkD;AAClD,qBAAqB;AACrB,uBAAuB;AACvB,UAAU;AACV,2CAA2C;AAC3C,MAAM;AACN,IAAI;AAEJ,+DAA+D;AAC/D,kFAAkF;AAClF,oBAAoB;AACpB,sDAAsD;AACtD,gDAAgD;AAChD,+BAA+B;AAC/B,kDAAkD;AAClD,qBAAqB;AACrB,uBAAuB;AACvB,UAAU;AACV,2CAA2C;AAC3C,MAAM;AACN,IAAI;AAEJ,qEAAqE;AACrE,kFAAkF;AAClF,oBAAoB;AACpB,sEAAsE;AACtE,6DAA6D;AAC7D,+BAA+B;AAC/B,kDAAkD;AAClD,qBAAqB;AACrB,sBAAsB;AACtB,UAAU;AACV,2CAA2C;AAC3C,MAAM;AACN,IAAI;AAEJ,MAAM,OAAO,gBAAgB;IACpB,MAAM,CAAU,qBAAqB,GAAgC,oBAAoB,CAAC;IAC1F,MAAM,CAAU,sBAAsB,GAAiC,qBAAqB,CAAC;;AAGtG,MAAM,OAAO,oBAAoB;IACxB,MAAM,CAAU,gBAAgB,GAA4B,gBAAgB,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -11,4 +11,13 @@ export interface DeviceConfig extends AccessoryConfig {
|
|
|
11
11
|
serialNumber: string;
|
|
12
12
|
accessKey: string;
|
|
13
13
|
secretKey: string;
|
|
14
|
+
battery?: BatteryDeviceConfig;
|
|
15
|
+
}
|
|
16
|
+
export interface BatteryDeviceConfig {
|
|
17
|
+
additionalCharacteristics: AdditionalBatteryCharacteristicType[];
|
|
18
|
+
}
|
|
19
|
+
export declare enum AdditionalBatteryCharacteristicType {
|
|
20
|
+
BatteryLevel = "Battery Level, %",
|
|
21
|
+
InputConsumptionInWatts = "Input Consumption, W",
|
|
22
|
+
OutputConsumptionInWatts = "Output Consumption, W"
|
|
14
23
|
}
|
package/dist/config.js
CHANGED
|
@@ -3,4 +3,10 @@ export var DeviceModel;
|
|
|
3
3
|
DeviceModel["Delta2Max"] = "Delta 2 Max";
|
|
4
4
|
DeviceModel["Delta2"] = "Delta 2";
|
|
5
5
|
})(DeviceModel || (DeviceModel = {}));
|
|
6
|
+
export var AdditionalBatteryCharacteristicType;
|
|
7
|
+
(function (AdditionalBatteryCharacteristicType) {
|
|
8
|
+
AdditionalBatteryCharacteristicType["BatteryLevel"] = "Battery Level, %";
|
|
9
|
+
AdditionalBatteryCharacteristicType["InputConsumptionInWatts"] = "Input Consumption, W";
|
|
10
|
+
AdditionalBatteryCharacteristicType["OutputConsumptionInWatts"] = "Output Consumption, W";
|
|
11
|
+
})(AdditionalBatteryCharacteristicType || (AdditionalBatteryCharacteristicType = {}));
|
|
6
12
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAMA,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,iCAAkB,CAAA;AACpB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB"}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAMA,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,iCAAkB,CAAA;AACpB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB;AAcD,MAAM,CAAN,IAAY,mCAIX;AAJD,WAAY,mCAAmC;IAC7C,wEAAiC,CAAA;IACjC,uFAAgD,CAAA;IAChD,yFAAkD,CAAA;AACpD,CAAC,EAJW,mCAAmC,KAAnC,mCAAmC,QAI9C"}
|
package/dist/helpers/logger.js
CHANGED
|
@@ -13,27 +13,27 @@ export class Logger {
|
|
|
13
13
|
}
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
15
|
info(message, ...parameters) {
|
|
16
|
-
this.logger.info(this.wrapMessage(message), parameters);
|
|
16
|
+
this.logger.info(this.wrapMessage(message), ...parameters);
|
|
17
17
|
}
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
19
|
success(message, ...parameters) {
|
|
20
|
-
this.logger.success(this.wrapMessage(message), parameters);
|
|
20
|
+
this.logger.success(this.wrapMessage(message), ...parameters);
|
|
21
21
|
}
|
|
22
22
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
23
|
warn(message, ...parameters) {
|
|
24
|
-
this.logger.warn(this.wrapMessage(message), parameters);
|
|
24
|
+
this.logger.warn(this.wrapMessage(message), ...parameters);
|
|
25
25
|
}
|
|
26
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
27
|
error(message, ...parameters) {
|
|
28
|
-
this.logger.error(this.wrapMessage(message), parameters);
|
|
28
|
+
this.logger.error(this.wrapMessage(message), ...parameters);
|
|
29
29
|
}
|
|
30
30
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
31
|
debug(message, ...parameters) {
|
|
32
|
-
this.logger.debug(this.wrapMessage(message), parameters);
|
|
32
|
+
this.logger.debug(this.wrapMessage(message), ...parameters);
|
|
33
33
|
}
|
|
34
34
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
35
|
log(level, message, ...parameters) {
|
|
36
|
-
this.logger.log(level, this.wrapMessage(message), parameters);
|
|
36
|
+
this.logger.log(level, this.wrapMessage(message), ...parameters);
|
|
37
37
|
}
|
|
38
38
|
wrapMessage(message) {
|
|
39
39
|
return `[${this.deviceName}] ${message}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/helpers/logger.ts"],"names":[],"mappings":"AAEA,MA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G,UAAU,CAAC,CAAC;IAChE,CAAC;IAED,8DAA8D;IACvD,IAAI,CAAC,OAAe,EAAE,GAAG,UAAiB;QAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC,CAAC;IAC7D,CAAC;IAED,8DAA8D;IACvD,KAAK,CAAC,OAAe,EAAE,GAAG,UAAiB;QAChD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC,CAAC;IAC9D,CAAC;IAED,8DAA8D;IACvD,KAAK,CAAC,OAAe,EAAE,GAAG,UAAiB;QAChD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC,CAAC;IAC9D,CAAC;IAED,8DAA8D;IACvD,GAAG,CAAC,KAAe,EAAE,OAAe,EAAE,GAAG,UAAiB;QAC/D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC,CAAC;IACnE,CAAC;IAEO,WAAW,CAAC,OAAe;QACjC,OAAO,IAAI,IAAI,CAAC,UAAU,KAAK,OAAO,EAAE,CAAC;IAC3C,CAAC;CACF"}
|
package/dist/platform.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { API, Characteristic, DynamicPlatformPlugin, Logging, PlatformAccessory, PlatformConfig, Service, UnknownContext } from 'homebridge';
|
|
2
|
+
import { EcoFlowAccessory } from './accessories/ecoFlowAccessory.js';
|
|
3
|
+
import { CustomCharacteristic } from './characteristics/CustomCharacteristic.js';
|
|
2
4
|
import { DeviceConfig } from './config.js';
|
|
3
5
|
/**
|
|
4
6
|
* HomebridgePlatform
|
|
5
7
|
* This class is the main constructor for your plugin, this is where you should
|
|
6
8
|
* parse the user config and discover/register accessories with Homebridge.
|
|
7
9
|
*/
|
|
10
|
+
export type EcoFlowCharacteristic = typeof Characteristic & typeof CustomCharacteristic;
|
|
8
11
|
export declare class EcoFlowHomebridgePlatform implements DynamicPlatformPlugin {
|
|
9
12
|
private readonly commonLog;
|
|
10
13
|
readonly config: PlatformConfig;
|
|
11
14
|
readonly api: API;
|
|
12
15
|
private readonly ecoFlowConfig;
|
|
13
16
|
readonly Service: typeof Service;
|
|
14
|
-
readonly Characteristic:
|
|
17
|
+
readonly Characteristic: EcoFlowCharacteristic;
|
|
15
18
|
readonly accessories: PlatformAccessory[];
|
|
16
19
|
constructor(commonLog: Logging, config: PlatformConfig, api: API);
|
|
17
20
|
/**
|
|
@@ -20,6 +23,6 @@ export declare class EcoFlowHomebridgePlatform implements DynamicPlatformPlugin
|
|
|
20
23
|
*/
|
|
21
24
|
configureAccessory(accessory: PlatformAccessory): void;
|
|
22
25
|
registerDevices(): void;
|
|
23
|
-
cleanupDevices(configuredAccessories: PlatformAccessory[], logs: Record<string, Logging>): void;
|
|
24
|
-
createAccessory(accessory: PlatformAccessory<UnknownContext>, config: DeviceConfig, log: Logging):
|
|
26
|
+
cleanupDevices(configuredAccessories: PlatformAccessory[], configuredEcoFlowAccessories: EcoFlowAccessory[], logs: Record<string, Logging>): void;
|
|
27
|
+
createAccessory(accessory: PlatformAccessory<UnknownContext>, config: DeviceConfig, log: Logging): EcoFlowAccessory | null;
|
|
25
28
|
}
|
package/dist/platform.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { Delta2Accessory } from './accessories/batteries/delta2Accessory.js';
|
|
2
2
|
import { Delta2MaxAccessory } from './accessories/batteries/delta2maxAccessory.js';
|
|
3
|
+
import { CustomCharacteristic } from './characteristics/CustomCharacteristic.js';
|
|
3
4
|
import { DeviceModel } from './config.js';
|
|
4
5
|
import { Logger } from './helpers/logger.js';
|
|
5
6
|
import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js';
|
|
6
|
-
/**
|
|
7
|
-
* HomebridgePlatform
|
|
8
|
-
* This class is the main constructor for your plugin, this is where you should
|
|
9
|
-
* parse the user config and discover/register accessories with Homebridge.
|
|
10
|
-
*/
|
|
11
7
|
export class EcoFlowHomebridgePlatform {
|
|
12
8
|
commonLog;
|
|
13
9
|
config;
|
|
@@ -23,7 +19,10 @@ export class EcoFlowHomebridgePlatform {
|
|
|
23
19
|
this.api = api;
|
|
24
20
|
this.ecoFlowConfig = this.config;
|
|
25
21
|
this.Service = api.hap.Service;
|
|
26
|
-
this.Characteristic =
|
|
22
|
+
this.Characteristic = {
|
|
23
|
+
...api.hap.Characteristic,
|
|
24
|
+
...CustomCharacteristic,
|
|
25
|
+
};
|
|
27
26
|
this.commonLog.debug('Finished initializing platform:', this.config.platform);
|
|
28
27
|
// Homebridge 1.8.0 introduced a `log.success` method that can be used to log success messages
|
|
29
28
|
// For users that are on a version prior to 1.8.0, we need a 'polyfill' for this method
|
|
@@ -51,6 +50,7 @@ export class EcoFlowHomebridgePlatform {
|
|
|
51
50
|
registerDevices() {
|
|
52
51
|
const logs = {};
|
|
53
52
|
const configuredAccessories = [];
|
|
53
|
+
const configuredEcoFlowAccessories = [];
|
|
54
54
|
if (!this.ecoFlowConfig.devices) {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
@@ -68,29 +68,41 @@ export class EcoFlowHomebridgePlatform {
|
|
|
68
68
|
// see if an accessory with the same uuid has already been registered and restored from
|
|
69
69
|
// the cached devices we stored in the `configureAccessory` method above
|
|
70
70
|
let accessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
71
|
+
let ecoFlowAccessory = null;
|
|
71
72
|
if (accessory) {
|
|
72
73
|
log.info('Restoring existing accessory from cache');
|
|
73
|
-
this.createAccessory(accessory, config, log);
|
|
74
|
+
ecoFlowAccessory = this.createAccessory(accessory, config, log);
|
|
74
75
|
}
|
|
75
76
|
else {
|
|
76
77
|
log.info('Adding new accessory');
|
|
77
78
|
accessory = new this.api.platformAccessory(config.name, uuid);
|
|
78
79
|
accessory.context.deviceConfig = config;
|
|
79
|
-
this.createAccessory(accessory, config, log);
|
|
80
|
+
ecoFlowAccessory = this.createAccessory(accessory, config, log);
|
|
80
81
|
// link the accessory to your platform
|
|
81
82
|
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
82
83
|
}
|
|
83
84
|
configuredAccessories.push(accessory);
|
|
85
|
+
if (ecoFlowAccessory) {
|
|
86
|
+
configuredEcoFlowAccessories.push(ecoFlowAccessory);
|
|
87
|
+
}
|
|
84
88
|
logs[accessory.displayName] = log;
|
|
85
89
|
}
|
|
86
|
-
this.cleanupDevices(configuredAccessories, logs);
|
|
90
|
+
this.cleanupDevices(configuredAccessories, configuredEcoFlowAccessories, logs);
|
|
87
91
|
}
|
|
88
|
-
cleanupDevices(configuredAccessories, logs) {
|
|
92
|
+
cleanupDevices(configuredAccessories, configuredEcoFlowAccessories, logs) {
|
|
93
|
+
const removedAccessories = [];
|
|
89
94
|
this.accessories
|
|
90
95
|
.filter(accessory => !configuredAccessories.includes(accessory))
|
|
91
96
|
.forEach(accessory => {
|
|
92
97
|
logs[accessory.displayName].info('Removing obsolete accessory');
|
|
93
98
|
this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
99
|
+
removedAccessories.push(accessory);
|
|
100
|
+
});
|
|
101
|
+
configuredEcoFlowAccessories
|
|
102
|
+
.filter(ecoFlowAccessory => !removedAccessories.includes(ecoFlowAccessory.accessory))
|
|
103
|
+
.forEach(ecoFlowAccessory => {
|
|
104
|
+
logs[ecoFlowAccessory.accessory.displayName].info('Initializing accessory');
|
|
105
|
+
ecoFlowAccessory.initialize();
|
|
94
106
|
});
|
|
95
107
|
}
|
|
96
108
|
createAccessory(accessory, config, log) {
|
|
@@ -105,7 +117,7 @@ export class EcoFlowHomebridgePlatform {
|
|
|
105
117
|
default:
|
|
106
118
|
log.warn(`"${config.model}" is not supported. Ignoring the device`);
|
|
107
119
|
}
|
|
108
|
-
ecoFlowAccessory
|
|
120
|
+
return ecoFlowAccessory;
|
|
109
121
|
}
|
|
110
122
|
}
|
|
111
123
|
//# sourceMappingURL=platform.js.map
|
package/dist/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAEnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAgB,WAAW,EAAiB,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAU3D,MAAM,OAAO,yBAAyB;IASjB;IACD;IACA;IAVD,aAAa,CAAgB;IAC9B,OAAO,CAAiB;IACxB,cAAc,CAAwB;IAEtD,oDAAoD;IACpC,WAAW,GAAwB,EAAE,CAAC;IAEtD,YACmB,SAAkB,EACnB,MAAsB,EACtB,GAAQ;QAFP,cAAS,GAAT,SAAS,CAAS;QACnB,WAAM,GAAN,MAAM,CAAgB;QACtB,QAAG,GAAH,GAAG,CAAK;QAExB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,MAAuB,CAAC;QAClD,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG;YACpB,GAAG,GAAG,CAAC,GAAG,CAAC,c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C,KAAK,EAAE,CAAC;YACrB,KAAK,WAAW,CAAC,SAAS;gBACxB,gBAAgB,GAAG,IAAI,kBAAkB,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;gBACxE,MAAM;YACR,KAAK,WAAW,CAAC,MAAM;gBACrB,gBAAgB,GAAG,IAAI,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;gBACrE,MAAM;YACR;gBACE,GAAG,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,KAAK,yCAAyC,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Service } from 'homebridge';
|
|
1
|
+
import { Characteristic, Service } from 'homebridge';
|
|
2
2
|
import { ServiceBase } from './serviceBase.js';
|
|
3
3
|
export declare class AccessoryInformationService extends ServiceBase {
|
|
4
4
|
protected createService(): Service;
|
|
5
|
+
protected addCharacteristics(): Characteristic[];
|
|
5
6
|
private getVersion;
|
|
6
7
|
}
|
|
@@ -4,14 +4,22 @@ import { fileURLToPath } from 'url';
|
|
|
4
4
|
import { ServiceBase } from './serviceBase.js';
|
|
5
5
|
export class AccessoryInformationService extends ServiceBase {
|
|
6
6
|
createService() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.
|
|
12
|
-
.
|
|
13
|
-
.
|
|
14
|
-
|
|
7
|
+
return this.getOrAddService(this.platform.Service.AccessoryInformation, 'Information');
|
|
8
|
+
}
|
|
9
|
+
addCharacteristics() {
|
|
10
|
+
const characteristics = [
|
|
11
|
+
this.addCharacteristic(this.platform.Characteristic.Manufacturer),
|
|
12
|
+
this.addCharacteristic(this.platform.Characteristic.Model),
|
|
13
|
+
this.addCharacteristic(this.platform.Characteristic.SerialNumber),
|
|
14
|
+
this.addCharacteristic(this.platform.Characteristic.FirmwareRevision),
|
|
15
|
+
this.addCharacteristic(this.platform.Characteristic.Identify),
|
|
16
|
+
];
|
|
17
|
+
this.service
|
|
18
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'EcoFlow')
|
|
19
|
+
.setCharacteristic(this.platform.Characteristic.Model, this.ecoFlowAccessory.config.model)
|
|
20
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, this.ecoFlowAccessory.config.serialNumber)
|
|
21
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.getVersion());
|
|
22
|
+
return characteristics;
|
|
15
23
|
}
|
|
16
24
|
getVersion() {
|
|
17
25
|
const filename = fileURLToPath(import.meta.url);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessoryInformationService.js","sourceRoot":"","sources":["../../src/services/accessoryInformationService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,OAAO,2BAA4B,SAAQ,WAAW;IACvC,aAAa;QAC9B,
|
|
1
|
+
{"version":3,"file":"accessoryInformationService.js","sourceRoot":"","sources":["../../src/services/accessoryInformationService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,OAAO,2BAA4B,SAAQ,WAAW;IACvC,aAAa;QAC9B,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC;IACzF,CAAC;IAEkB,kBAAkB;QACnC,MAAM,eAAe,GAAG;YACt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AAE,MAAM,CAAC,CAAC,CAAC;QACzE,OAAO,WAAW,EAAE,OAAO,CAAC;IAC9B,CAAC;CACF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Service } from 'homebridge';
|
|
1
|
+
import { Characteristic, Service } from 'homebridge';
|
|
2
2
|
import { ServiceBase } from './serviceBase.js';
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class BatteryStatusService extends ServiceBase {
|
|
4
4
|
protected createService(): Service;
|
|
5
|
+
protected addCharacteristics(): Characteristic[];
|
|
5
6
|
updateStatusLowBattery(batteryLevel: number): void;
|
|
6
7
|
updateBatteryLevel(batteryLevel: number): void;
|
|
7
8
|
updateChargingState(chargingPower: number): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ServiceBase } from './serviceBase.js';
|
|
2
|
+
export class BatteryStatusService extends ServiceBase {
|
|
3
|
+
createService() {
|
|
4
|
+
return this.getOrAddService(this.platform.Service.Battery, this.ecoFlowAccessory.config.name);
|
|
5
|
+
}
|
|
6
|
+
addCharacteristics() {
|
|
7
|
+
return [
|
|
8
|
+
this.addCharacteristic(this.platform.Characteristic.StatusLowBattery),
|
|
9
|
+
this.addCharacteristic(this.platform.Characteristic.BatteryLevel),
|
|
10
|
+
this.addCharacteristic(this.platform.Characteristic.ChargingState),
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
updateStatusLowBattery(batteryLevel) {
|
|
14
|
+
const statusLowBattery = batteryLevel < 20;
|
|
15
|
+
this.log.debug('Status Low Battery ->', statusLowBattery);
|
|
16
|
+
this.service
|
|
17
|
+
.getCharacteristic(this.platform.Characteristic.StatusLowBattery)
|
|
18
|
+
.updateValue(statusLowBattery
|
|
19
|
+
? this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
|
|
20
|
+
: this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL);
|
|
21
|
+
}
|
|
22
|
+
updateBatteryLevel(batteryLevel) {
|
|
23
|
+
this.log.debug('BatteryLevel ->', batteryLevel);
|
|
24
|
+
this.service.getCharacteristic(this.platform.Characteristic.BatteryLevel).updateValue(batteryLevel);
|
|
25
|
+
}
|
|
26
|
+
updateChargingState(chargingPower) {
|
|
27
|
+
const isCharging = chargingPower > 0;
|
|
28
|
+
this.log.debug('ChargingState ->', isCharging);
|
|
29
|
+
this.service.getCharacteristic(this.platform.Characteristic.ChargingState).updateValue(isCharging);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=batteryStatusService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batteryStatusService.js","sourceRoot":"","sources":["../../src/services/batteryStatusService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IAChC,aAAa;QAC9B,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChG,CAAC;IAEkB,kBAAkB;QACnC,OAAO;YACL,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC;YACrE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,CAAC;YACjE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,aAAa,CAAC;SACnE,CAAC;IACJ,CAAC;IAEM,sBAAsB,CAAC,YAAoB;QAChD,MAAM,gBAAgB,GAAG,YAAY,GAAG,EAAE,CAAC;QAC3C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,uBAAuB,EAAE,gBAAgB,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO;aACT,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC;aAChE,WAAW,CACV,gBAAgB;YACd,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC,iBAAiB;YACjE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC,oBAAoB,CACvE,CAAC;IACN,CAAC;IAEM,kBAAkB,CAAC,YAAoB;QAC5C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;QAChD,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IACtG,CAAC;IAEM,mBAAmB,CAAC,aAAqB;QAC9C,MAAM,UAAU,GAAG,aAAa,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACrG,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Service } from 'homebridge';
|
|
1
|
+
import { Characteristic, CharacteristicValue, Service, WithUUID } from 'homebridge';
|
|
2
2
|
import { EcoFlowAccessory } from '../accessories/ecoFlowAccessory.js';
|
|
3
3
|
import { ServiceBase } from './serviceBase.js';
|
|
4
4
|
export interface MqttSetEnabledMessageParams {
|
|
@@ -8,10 +8,17 @@ export declare abstract class OutletsServiceBase extends ServiceBase {
|
|
|
8
8
|
private readonly serviceSubType;
|
|
9
9
|
constructor(serviceSubType: string, ecoFlowAccessory: EcoFlowAccessory);
|
|
10
10
|
updateState(state: boolean): void;
|
|
11
|
-
|
|
11
|
+
updateOutputConsumption(watt: number): void;
|
|
12
|
+
updateInputConsumption(watt: number): void;
|
|
13
|
+
updateBatteryLevel(batteryLevel: number): void;
|
|
12
14
|
protected createService(): Service;
|
|
15
|
+
protected addCharacteristics(): Characteristic[];
|
|
13
16
|
protected abstract setOn(value: boolean, revert: () => void): Promise<void>;
|
|
14
17
|
protected sendOn<TParams>(moduleType: number, operateType: string, params: TParams, revert: () => void): Promise<void>;
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
protected updateCharacteristic(characteristic: WithUUID<{
|
|
19
|
+
new (): Characteristic;
|
|
20
|
+
}>, name: string, value: CharacteristicValue): void;
|
|
21
|
+
private tryAddCustomCharacteristic;
|
|
22
|
+
private updateCustomCharacteristic;
|
|
23
|
+
private get serviceName();
|
|
17
24
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AdditionalBatteryCharacteristicType as CharacteristicType } from '../config.js';
|
|
1
2
|
import { ServiceBase } from './serviceBase.js';
|
|
2
3
|
export class OutletsServiceBase extends ServiceBase {
|
|
3
4
|
serviceSubType;
|
|
@@ -6,33 +7,56 @@ export class OutletsServiceBase extends ServiceBase {
|
|
|
6
7
|
this.serviceSubType = serviceSubType;
|
|
7
8
|
}
|
|
8
9
|
updateState(state) {
|
|
9
|
-
this.
|
|
10
|
-
this.service.getCharacteristic(this.ecoFlowAccessory.platform.Characteristic.On).updateValue(state);
|
|
10
|
+
this.updateCharacteristic(this.platform.Characteristic.On, 'State', state);
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
12
|
+
updateOutputConsumption(watt) {
|
|
13
|
+
this.updateCharacteristic(this.platform.Characteristic.OutletInUse, 'InUse', watt > 0);
|
|
14
|
+
this.updateCustomCharacteristic(this.platform.Characteristic.PowerConsumption.OutputConsumptionWatts, 'Output Consumption, W', watt, CharacteristicType.OutputConsumptionInWatts);
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.addCharacteristics(service);
|
|
19
|
-
return service;
|
|
16
|
+
updateInputConsumption(watt) {
|
|
17
|
+
this.updateCustomCharacteristic(this.platform.Characteristic.PowerConsumption.InputConsumptionWatts, 'Input Consumption, W', watt, CharacteristicType.InputConsumptionInWatts);
|
|
20
18
|
}
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
updateBatteryLevel(batteryLevel) {
|
|
20
|
+
this.updateCustomCharacteristic(this.platform.Characteristic.BatteryLevel, 'Battery Level, %', batteryLevel, CharacteristicType.BatteryLevel);
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
createService() {
|
|
23
|
+
return this.getOrAddServiceById(this.platform.Service.Outlet, this.serviceName, this.serviceSubType);
|
|
24
|
+
}
|
|
25
|
+
addCharacteristics() {
|
|
26
|
+
const onCharacteristic = this.addCharacteristic(this.platform.Characteristic.On);
|
|
27
|
+
onCharacteristic.onSet(value => {
|
|
26
28
|
const newValue = value;
|
|
27
29
|
this.setOn(newValue, () => this.updateState(!newValue));
|
|
28
30
|
});
|
|
31
|
+
const characteristics = [
|
|
32
|
+
this.addCharacteristic(this.platform.Characteristic.OutletInUse),
|
|
33
|
+
onCharacteristic,
|
|
34
|
+
this.tryAddCustomCharacteristic(this.platform.Characteristic.PowerConsumption.InputConsumptionWatts, CharacteristicType.InputConsumptionInWatts),
|
|
35
|
+
this.tryAddCustomCharacteristic(this.platform.Characteristic.PowerConsumption.OutputConsumptionWatts, CharacteristicType.OutputConsumptionInWatts),
|
|
36
|
+
this.tryAddCustomCharacteristic(this.platform.Characteristic.BatteryLevel, CharacteristicType.BatteryLevel),
|
|
37
|
+
];
|
|
38
|
+
this.service.setCharacteristic(this.platform.Characteristic.Name, this.serviceName);
|
|
39
|
+
return characteristics.filter(characteristic => characteristic !== null);
|
|
40
|
+
}
|
|
41
|
+
sendOn(moduleType, operateType, params, revert) {
|
|
42
|
+
return this.ecoFlowAccessory.sendSetCommand(moduleType, operateType, params, revert);
|
|
43
|
+
}
|
|
44
|
+
updateCharacteristic(characteristic, name, value) {
|
|
45
|
+
super.updateCharacteristic(characteristic, `${this.serviceSubType} ${name}`, value);
|
|
46
|
+
}
|
|
47
|
+
tryAddCustomCharacteristic(characteristic, characteristicType) {
|
|
48
|
+
if (this.ecoFlowAccessory.config.battery?.additionalCharacteristics?.includes(characteristicType)) {
|
|
49
|
+
return this.addCharacteristic(characteristic);
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
updateCustomCharacteristic(characteristic, name, value, characteristicType) {
|
|
54
|
+
if (this.ecoFlowAccessory.config.battery?.additionalCharacteristics?.includes(characteristicType)) {
|
|
55
|
+
super.updateCharacteristic(characteristic, name, value);
|
|
56
|
+
}
|
|
29
57
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const service = this.ecoFlowAccessory.accessory.getServiceById(this.ecoFlowAccessory.platform.Service.Outlet, serviceSubType) ||
|
|
33
|
-
this.ecoFlowAccessory.accessory.addService(this.ecoFlowAccessory.platform.Service.Outlet, serviceName, serviceSubType);
|
|
34
|
-
service.setCharacteristic(this.ecoFlowAccessory.platform.Characteristic.Name, serviceName);
|
|
35
|
-
return service;
|
|
58
|
+
get serviceName() {
|
|
59
|
+
return `${this.ecoFlowAccessory.config.name} ${this.serviceSubType}`;
|
|
36
60
|
}
|
|
37
61
|
}
|
|
38
62
|
//# sourceMappingURL=outletServiceBase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outletServiceBase.js","sourceRoot":"","sources":["../../src/services/outletServiceBase.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAM/C,MAAM,OAAgB,kBAAmB,SAAQ,WAAW;IAEvC;IADnB,YACmB,cAAsB,EACvC,gBAAkC;QAElC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAHP,mBAAc,GAAd,cAAc,CAAQ;IAIzC,CAAC;IAEM,WAAW,CAAC,KAAc;QAC/B,IAAI,CAAC,
|
|
1
|
+
{"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;IAIS,MAAM,CACd,UAAkB,EAClB,WAAmB,EACnB,MAAe,EACf,MAAkB;QAElB,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACvF,CAAC;IAEkB,oBAAoB,CACrC,cAAoD,EACpD,IAAY,EACZ,KAA0B;QAE1B,KAAK,CAAC,oBAAoB,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC,cAAc,IAAI,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACtF,CAAC;IAEO,0BAA0B,CAChC,cAAoD,EACpD,kBAAsC;QAEtC,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,yBAAyB,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAClG,OAAO,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,0BAA0B,CAChC,cAAoD,EACpD,IAAY,EACZ,KAA0B,EAC1B,kBAAsC;QAEtC,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,yBAAyB,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAClG,KAAK,CAAC,oBAAoB,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,IAAY,WAAW;QACrB,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;IACvE,CAAC;CACF"}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
import { Logging, Service } from 'homebridge';
|
|
1
|
+
import { Characteristic, CharacteristicValue, Logging, Service, WithUUID } from 'homebridge';
|
|
2
2
|
import { EcoFlowAccessory } from '../accessories/ecoFlowAccessory.js';
|
|
3
|
+
import { EcoFlowHomebridgePlatform } from '../platform.js';
|
|
3
4
|
export declare abstract class ServiceBase {
|
|
4
5
|
protected readonly ecoFlowAccessory: EcoFlowAccessory;
|
|
5
6
|
protected readonly log: Logging;
|
|
7
|
+
protected readonly platform: EcoFlowHomebridgePlatform;
|
|
8
|
+
protected characteristics: Characteristic[];
|
|
6
9
|
private _service;
|
|
7
10
|
constructor(ecoFlowAccessory: EcoFlowAccessory);
|
|
8
11
|
initialize(): void;
|
|
12
|
+
cleanupCharacteristics(): void;
|
|
9
13
|
get service(): Service;
|
|
10
14
|
protected abstract createService(): Service;
|
|
15
|
+
protected abstract addCharacteristics(): Characteristic[];
|
|
16
|
+
protected addCharacteristic(characteristic: WithUUID<{
|
|
17
|
+
new (): Characteristic;
|
|
18
|
+
}>): Characteristic;
|
|
19
|
+
protected getOrAddService(service: WithUUID<typeof Service>, displayName?: string): Service;
|
|
20
|
+
protected getOrAddServiceById(service: WithUUID<typeof Service>, serviceName: string, serviceSubType: string): Service;
|
|
21
|
+
protected updateCharacteristic(characteristic: WithUUID<{
|
|
22
|
+
new (): Characteristic;
|
|
23
|
+
}>, name: string, value: CharacteristicValue): void;
|
|
11
24
|
}
|
|
@@ -1,17 +1,52 @@
|
|
|
1
1
|
export class ServiceBase {
|
|
2
2
|
ecoFlowAccessory;
|
|
3
3
|
log;
|
|
4
|
+
platform;
|
|
5
|
+
characteristics = [];
|
|
4
6
|
_service = null;
|
|
5
7
|
constructor(ecoFlowAccessory) {
|
|
6
8
|
this.ecoFlowAccessory = ecoFlowAccessory;
|
|
7
9
|
this.log = ecoFlowAccessory.log;
|
|
10
|
+
this.platform = ecoFlowAccessory.platform;
|
|
8
11
|
}
|
|
9
12
|
initialize() {
|
|
10
13
|
this._service = this.createService();
|
|
14
|
+
this.characteristics = this.addCharacteristics();
|
|
15
|
+
this.characteristics.push(this.addCharacteristic(this.platform.Characteristic.Name));
|
|
16
|
+
}
|
|
17
|
+
cleanupCharacteristics() {
|
|
18
|
+
this.service.characteristics
|
|
19
|
+
.filter(characteristic => !this.characteristics.includes(characteristic))
|
|
20
|
+
.forEach(characteristic => {
|
|
21
|
+
this.log.warn(`[${this.service.displayName}] Removing obsolete characteristic:`, characteristic.displayName);
|
|
22
|
+
this.service.removeCharacteristic(characteristic);
|
|
23
|
+
});
|
|
11
24
|
}
|
|
12
25
|
// Getter for service
|
|
13
26
|
get service() {
|
|
14
27
|
return this._service;
|
|
15
28
|
}
|
|
29
|
+
addCharacteristic(characteristic) {
|
|
30
|
+
const existingCharacteristic = this.service.getCharacteristic(characteristic);
|
|
31
|
+
if (!existingCharacteristic) {
|
|
32
|
+
return this.service.addCharacteristic(characteristic);
|
|
33
|
+
}
|
|
34
|
+
return existingCharacteristic;
|
|
35
|
+
}
|
|
36
|
+
getOrAddService(service, displayName) {
|
|
37
|
+
const result = this.ecoFlowAccessory.accessory.getService(service) ||
|
|
38
|
+
this.ecoFlowAccessory.accessory.addService(service, displayName, service.UUID);
|
|
39
|
+
result.displayName = displayName ?? result.displayName;
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
getOrAddServiceById(service, serviceName, serviceSubType) {
|
|
43
|
+
const result = this.ecoFlowAccessory.accessory.getServiceById(service, serviceSubType) ||
|
|
44
|
+
this.ecoFlowAccessory.accessory.addService(service, serviceName, serviceSubType);
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
updateCharacteristic(characteristic, name, value) {
|
|
48
|
+
this.log.debug(`${name} ->`, value);
|
|
49
|
+
this.service.getCharacteristic(characteristic).updateValue(value);
|
|
50
|
+
}
|
|
16
51
|
}
|
|
17
52
|
//# sourceMappingURL=serviceBase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceBase.js","sourceRoot":"","sources":["../../src/services/serviceBase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serviceBase.js","sourceRoot":"","sources":["../../src/services/serviceBase.ts"],"names":[],"mappings":"AAIA,MAAM,OAAgB,WAAW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,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;QACxD,CAAC;QAED,OAAO,sBAAsB,CAAC;IAChC,CAAC;IAES,eAAe,CAAC,OAAiC,EAAE,WAAoB;QAC/E,MAAM,MAAM,GACV,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC;YACnD,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACjF,MAAM,CAAC,WAAW,GAAG,WAAW,IAAI,MAAM,CAAC,WAAW,CAAC;QAEvD,OAAO,MAAM,CAAC;IAChB,CAAC;IAES,mBAAmB,CAC3B,OAAiC,EACjC,WAAmB,EACnB,cAAsB;QAEtB,MAAM,MAAM,GACV,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC;YACvE,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;QAEnF,OAAO,MAAM,CAAC;IAChB,CAAC;IAES,oBAAoB,CAC5B,cAAoD,EACpD,IAAY,EACZ,KAA0B;QAE1B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,KAAK,EAAE,KAAK,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;CACF"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ServiceBase } from './serviceBase.js';
|
|
2
|
-
export class BatteryService extends ServiceBase {
|
|
3
|
-
createService() {
|
|
4
|
-
const service = this.ecoFlowAccessory.accessory.getService(this.ecoFlowAccessory.platform.Service.Battery) ||
|
|
5
|
-
this.ecoFlowAccessory.accessory.addService(this.ecoFlowAccessory.platform.Service.Battery, this.ecoFlowAccessory.config.name);
|
|
6
|
-
return service;
|
|
7
|
-
}
|
|
8
|
-
updateStatusLowBattery(batteryLevel) {
|
|
9
|
-
const statusLowBattery = batteryLevel < 20;
|
|
10
|
-
this.log.debug('Status Low Battery ->', statusLowBattery);
|
|
11
|
-
this.service
|
|
12
|
-
.getCharacteristic(this.ecoFlowAccessory.platform.Characteristic.StatusLowBattery)
|
|
13
|
-
.updateValue(statusLowBattery
|
|
14
|
-
? this.ecoFlowAccessory.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
|
|
15
|
-
: this.ecoFlowAccessory.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL);
|
|
16
|
-
}
|
|
17
|
-
updateBatteryLevel(batteryLevel) {
|
|
18
|
-
this.log.debug('BatteryLevel ->', batteryLevel);
|
|
19
|
-
this.service
|
|
20
|
-
.getCharacteristic(this.ecoFlowAccessory.platform.Characteristic.BatteryLevel)
|
|
21
|
-
.updateValue(batteryLevel);
|
|
22
|
-
}
|
|
23
|
-
updateChargingState(chargingPower) {
|
|
24
|
-
const isCharging = chargingPower > 0;
|
|
25
|
-
this.log.debug('ChargingState ->', isCharging);
|
|
26
|
-
this.service.getCharacteristic(this.ecoFlowAccessory.platform.Characteristic.ChargingState).updateValue(isCharging);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=batteryService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"batteryService.js","sourceRoot":"","sources":["../../src/services/batteryService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC1B,aAAa;QAC9B,MAAM,OAAO,GACX,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CA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