@pietrolubini/homebridge-ecoflow 1.6.0-alpha.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/.gitattributes +1 -0
  2. package/README.md +132 -63
  3. package/config.schema.json +46 -1
  4. package/dist/accessories/ecoFlowAccessoryBase.d.ts +4 -1
  5. package/dist/accessories/ecoFlowAccessoryBase.js +27 -2
  6. package/dist/accessories/ecoFlowAccessoryBase.js.map +1 -1
  7. package/dist/accessories/powerocean/interfaces/powerOceanHttpApiContracts.d.ts +7 -0
  8. package/dist/accessories/powerocean/interfaces/powerOceanHttpApiContracts.js +3 -0
  9. package/dist/accessories/powerocean/interfaces/powerOceanHttpApiContracts.js.map +1 -0
  10. package/dist/accessories/powerocean/interfaces/powerOceanMqttApiContracts.d.ts +5 -0
  11. package/dist/accessories/powerocean/interfaces/powerOceanMqttApiContracts.js +3 -0
  12. package/dist/accessories/powerocean/interfaces/powerOceanMqttApiContracts.js.map +1 -0
  13. package/dist/accessories/powerocean/powerOceanAccessory.d.ts +24 -0
  14. package/dist/accessories/powerocean/powerOceanAccessory.js +87 -0
  15. package/dist/accessories/powerocean/powerOceanAccessory.js.map +1 -0
  16. package/dist/accessories/powerocean/simulations/powerOceanSimulator.d.ts +5 -0
  17. package/dist/accessories/powerocean/simulations/powerOceanSimulator.js +23 -0
  18. package/dist/accessories/powerocean/simulations/powerOceanSimulator.js.map +1 -0
  19. package/dist/accessories/powerstream/powerStreamAccessory.js +4 -5
  20. package/dist/accessories/powerstream/powerStreamAccessory.js.map +1 -1
  21. package/dist/apis/containers/mqttDevice.d.ts +2 -0
  22. package/dist/apis/containers/mqttDevice.js +7 -0
  23. package/dist/apis/containers/mqttDevice.js.map +1 -1
  24. package/dist/apis/ecoFlowMqttApiManager.d.ts +2 -0
  25. package/dist/apis/ecoFlowMqttApiManager.js +6 -0
  26. package/dist/apis/ecoFlowMqttApiManager.js.map +1 -1
  27. package/dist/apis/interfaces/mqttApiContracts.d.ts +11 -1
  28. package/dist/apis/interfaces/mqttApiContracts.js +1 -0
  29. package/dist/apis/interfaces/mqttApiContracts.js.map +1 -1
  30. package/dist/apis/simulations/mockMqttClient.d.ts +3 -1
  31. package/dist/apis/simulations/mockMqttClient.js +24 -5
  32. package/dist/apis/simulations/mockMqttClient.js.map +1 -1
  33. package/dist/apis/simulations/simulator.d.ts +2 -1
  34. package/dist/apis/simulations/simulator.js +12 -0
  35. package/dist/apis/simulations/simulator.js.map +1 -1
  36. package/dist/config.d.ts +7 -3
  37. package/dist/config.js +2 -1
  38. package/dist/config.js.map +1 -1
  39. package/dist/homebridge-ui/public/index.html +1 -1
  40. package/dist/homebridge-ui/public/index.js +1 -1
  41. package/dist/platform.js +8 -6
  42. package/dist/platform.js.map +1 -1
  43. package/dist/services/contactSensorService.d.ts +1 -0
  44. package/dist/services/contactSensorService.js +6 -3
  45. package/dist/services/contactSensorService.js.map +1 -1
  46. package/dist/services/fanServiceBase.d.ts +3 -1
  47. package/dist/services/fanServiceBase.js +21 -15
  48. package/dist/services/fanServiceBase.js.map +1 -1
  49. package/dist/services/lightBulbServiceBase.d.ts +3 -1
  50. package/dist/services/lightBulbServiceBase.js +21 -15
  51. package/dist/services/lightBulbServiceBase.js.map +1 -1
  52. package/dist/{accessories/powerstream/services/outletInvService.d.ts → services/outletReadOnlyService.d.ts} +2 -2
  53. package/dist/{accessories/powerstream/services/outletService.js → services/outletReadOnlyService.js} +4 -4
  54. package/dist/services/outletReadOnlyService.js.map +1 -0
  55. package/dist/services/outletServiceBase.d.ts +1 -0
  56. package/dist/services/outletServiceBase.js +8 -5
  57. package/dist/services/outletServiceBase.js.map +1 -1
  58. package/dist/services/serviceBase.d.ts +6 -1
  59. package/dist/services/serviceBase.js +23 -10
  60. package/dist/services/serviceBase.js.map +1 -1
  61. package/dist/services/switchServiceBase.d.ts +1 -0
  62. package/dist/services/switchServiceBase.js +8 -5
  63. package/dist/services/switchServiceBase.js.map +1 -1
  64. package/dist/services/temperatureSensorService.d.ts +1 -1
  65. package/dist/services/temperatureSensorService.js +4 -3
  66. package/dist/services/temperatureSensorService.js.map +1 -1
  67. package/dist/services/thermostatFridgeServiceBase.d.ts +6 -3
  68. package/dist/services/thermostatFridgeServiceBase.js +50 -30
  69. package/dist/services/thermostatFridgeServiceBase.js.map +1 -1
  70. package/junit.xml +1042 -834
  71. package/package.json +1 -1
  72. package/dist/accessories/powerstream/services/outletInvService.js +0 -14
  73. package/dist/accessories/powerstream/services/outletInvService.js.map +0 -1
  74. package/dist/accessories/powerstream/services/outletService.d.ts +0 -9
  75. package/dist/accessories/powerstream/services/outletService.js.map +0 -1
  76. /package/dist/accessories/{powerstream/services/outletInvService.spec.d.ts → powerocean/powerOceanAccessory.spec.d.ts} +0 -0
  77. /package/dist/{accessories/powerstream/services/outletService.spec.d.ts → services/outletReadOnlyService.spec.d.ts} +0 -0
package/.gitattributes CHANGED
@@ -5,3 +5,4 @@
5
5
  *.jpeg binary -crlf
6
6
  *.gif binary -crlf
7
7
  *.pdf binary -crlf
8
+ *.wasm binary -crlf
package/README.md CHANGED
@@ -25,6 +25,7 @@ The goal is to add HomeKit support to EcoFlow devices and make them fully contro
25
25
  - Integrates EcoFlow devices into HomeKit
26
26
  - Fully customizable HomeKit accessories
27
27
  - HomeKit automations for your EcoFlow devices
28
+ - Detection of whether EcoFlow accessory is online/offline
28
29
 
29
30
  ## Supported Device Types
30
31
 
@@ -33,9 +34,10 @@ The goal is to add HomeKit support to EcoFlow devices and make them fully contro
33
34
  - [Delta Pro](#delta-pro)
34
35
  - [Delta Pro 3](#delta-pro-3)
35
36
  - [Delta Pro Ultra](#delta-pro-ultra)
37
+ - [Glacier](#glacier)
38
+ - [PowerOcean](#powerocean)
36
39
  - [PowerStream Micro-inverter](#powerstream-micro-inverter)
37
40
  - [Smart Plug](#smart-plug)
38
- - [Glacier](#glacier)
39
41
 
40
42
  For a full list of devices that could be potentially added check [here](https://developer-eu.ecoflow.com/us/document/introduction)
41
43
 
@@ -130,8 +132,8 @@ Quota is sent every 10 seconds with random values in this mode.
130
132
  | Output | Outlet AC | Output Consumption, W | 🔲 | Read |
131
133
  | Charging State | Outlet AC | ChargingState, Yes/No | 🔲 | Read |
132
134
  | Battery Level | Outlet AC | StatusLowBattery, Yes/No | 🔲 | Read |
133
- | 12V DC | Outlet CAR | On | ✅ | Read/Write |
134
- | 12V DC Output | Outlet CAR | OutletInUse | ✅ | Read |
135
+ | DC 12V | Outlet CAR | On | ✅ | Read/Write |
136
+ | DC 12V Output | Outlet CAR | OutletInUse | ✅ | Read |
135
137
  | Battery Level | Outlet CAR | Battery Level, % | 🔲 | Read |
136
138
  | Input | Outlet CAR | Input Consumption, W | 🔲 | Read |
137
139
  | Output | Outlet CAR | Output Consumption, W | 🔲 | Read |
@@ -203,8 +205,8 @@ Supported services and configuration are the same as for [Delta 2](#delta-2)
203
205
  | Output | Outlet AC | Output Consumption, W | 🔲 | Read |
204
206
  | Charging State | Outlet AC | ChargingState, Yes/No | 🔲 | Read |
205
207
  | Battery Level | Outlet AC | StatusLowBattery, Yes/No | 🔲 | Read |
206
- | 12V DC | Outlet CAR | On | ✅ | Read/Write |
207
- | 12V DC Output | Outlet CAR | OutletInUse | ✅ | Read |
208
+ | DC 12V | Outlet CAR | On | ✅ | Read/Write |
209
+ | DC 12V Output | Outlet CAR | OutletInUse | ✅ | Read |
208
210
  | Battery Level | Outlet CAR | Battery Level, % | 🔲 | Read |
209
211
  | Input | Outlet CAR | Input Consumption, W | 🔲 | Read |
210
212
  | Output | Outlet CAR | Output Consumption, W | 🔲 | Read |
@@ -358,6 +360,131 @@ The following additional characteristics is available:
358
360
  }
359
361
  ```
360
362
 
363
+ ### Glacier
364
+
365
+ > Not Activated (no testing is performed)
366
+
367
+ #### Services
368
+
369
+ | EcoFlow Parameter | Service | Characteristic | Standard | Permission |
370
+ | ----------------------------------- | --------------------- | -------------------------- | -------- | -------------------------------------------------------------------------------------------------------- |
371
+ | Battery | Outlet | On | ✅ | Read (Battery Discharging > 0: ON) |
372
+ | Battery Discharging | Outlet | OutletInUse | ✅ | Read |
373
+ | Battery Level | Outlet | Battery Level, % | 🔲 | Read |
374
+ | Battery Charging | Outlet | Input Consumption, W | 🔲 | Read |
375
+ | Battery Discharging | Outlet | Output Consumption, W | 🔲 | Read |
376
+ | Battery Charging State | Outlet | ChargingState, Yes/No | 🔲 | Read |
377
+ | Battery Level | Outlet | StatusLowBattery, Yes/No | 🔲 | Read |
378
+ | ECO mode | Switch | On | ✅ | Read/Write |
379
+ | Door Opened | ContactSensor | ContactSensorState | ✅ | Read |
380
+ | Make ice (small cubes) | Switch | On | ✅ | Read/Write (allowed when `Detach Ice` or `Make ice (large cubes)` options are not activated) |
381
+ | Make ice (large cubes) | Switch | On | ✅ | Read/Write (allowed when `Detach Ice` or `Make ice (small cubes)` options are not activated) |
382
+ | Detach ice | Switch | On | ✅ | Read/Write (allowed when `Make ice (small cubes)` or `Make ice (large cubes)` options are not activated) |
383
+ | Dual Left Zone Current Temperature | Thermostat Dual Left | CurrentTemperature | ✅ | Read |
384
+ | Dual Left Zone Target Temperature | Thermostat Dual Left | TargetTemperature | ✅ | Read/write (allowed when zone partition is installed) |
385
+ | Device is ON/OFF | Thermostat Dual Left | CurrentHeatingCoolingState | ✅ | Read |
386
+ | Device is ON/OFF | Thermostat Dual Left | TargetHeatingCoolingState | ✅ | Read |
387
+ | Dual Right Zone Current Temperature | Thermostat Dual Right | CurrentTemperature | ✅ | Read |
388
+ | Dual Right Zone Target Temperature | Thermostat Dual Right | TargetTemperature | ✅ | Read/write (allowed when zone partition is installed) |
389
+ | Device is ON/OFF | Thermostat Dual Right | CurrentHeatingCoolingState | ✅ | Read |
390
+ | Device is ON/OFF | Thermostat Dual Right | TargetHeatingCoolingState | ✅ | Read |
391
+ | Single Zone Current Temperature | Thermostat Single | CurrentTemperature | ✅ | Read |
392
+ | Single Zone Target Temperature | Thermostat Single | TargetTemperature | ✅ | Read/write (allowed when zone partition is removed) |
393
+ | Device is ON/OFF | Thermostat Single | CurrentHeatingCoolingState | ✅ | Read |
394
+ | Device is ON/OFF | Thermostat Single | TargetHeatingCoolingState | ✅ | Read |
395
+
396
+ #### Configuration
397
+
398
+ The following additional characteristics is available:
399
+
400
+ - Battery Level, %
401
+ - Input Consumption, W
402
+ - Output Consumption, W
403
+
404
+ ```json
405
+ {
406
+ ...
407
+ "devices": [
408
+ {
409
+ ...
410
+ "model": "Glacier",
411
+ "battery": {
412
+ "additionalCharacteristics": [
413
+ "Battery Level, %",
414
+ "Input Consumption, W",
415
+ "Output Consumption, W"
416
+ ]
417
+ }
418
+ }
419
+ ],
420
+ }
421
+ ```
422
+
423
+ ### PowerOcean
424
+
425
+ #### Services
426
+
427
+ | EcoFlow Parameter | Service | Characteristic | Standard | Permission |
428
+ | ---------------------- | ---------- | ------------------------ | -------- | ---------------------------------- |
429
+ | Inverter | Outlet INV | On | ✅ | Read (Inverter AC Output > 0: ON) |
430
+ | Inverter AC Output | Outlet INV | OutletInUse | ✅ | Read |
431
+ | Inverter AC Input | Outlet INV | Input Consumption, W | 🔲 | Read |
432
+ | Inverter AC Output | Outlet INV | Output Consumption, W | 🔲 | Read |
433
+ | Solar | Outlet PV | On | ✅ | Read (Solar Generation > 0: ON) |
434
+ | Solar Generation | Outlet PV | OutletInUse | ✅ | Read |
435
+ | Solar Generation | Outlet PV | Output Consumption, W | 🔲 | Read |
436
+ | Battery | Outlet BAT | On | ✅ | Read (Battery Discharging > 0: ON) |
437
+ | Battery Discharging | Outlet BAT | OutletInUse | ✅ | Read |
438
+ | Battery Level | Outlet BAT | Battery Level, % | 🔲 | Read |
439
+ | Battery Charging | Outlet BAT | Input Consumption, W | 🔲 | Read |
440
+ | Battery Discharging | Outlet BAT | Output Consumption, W | 🔲 | Read |
441
+ | Battery Charging State | Outlet BAT | ChargingState, Yes/No | 🔲 | Read |
442
+ | Battery Level | Outlet BAT | StatusLowBattery, Yes/No | 🔲 | Read |
443
+
444
+ #### Configuration
445
+
446
+ The following additional characteristics is available:
447
+
448
+ - battery:
449
+ - Battery Level, %
450
+ - Input Consumption, W
451
+ - Output Consumption, W
452
+ - Charging State
453
+ - Status Low Battery
454
+ - pv:
455
+ - Output Consumption, W
456
+ - inverter:
457
+ - Input Consumption, W
458
+ - Output Consumption, W
459
+
460
+ ```json
461
+ {
462
+ ...
463
+ "devices": [
464
+ {
465
+ ...
466
+ "model": "PowerOcean",
467
+ "powerStream": {
468
+ "batteryAdditionalCharacteristics": [
469
+ "Battery Level, %",
470
+ "Input Consumption, W",
471
+ "Output Consumption, W",
472
+ "Charging State",
473
+ "Status Low Battery"
474
+ ],
475
+ "pvAdditionalCharacteristics": [
476
+ "Output Consumption, W"
477
+ ],
478
+ "inverterAdditionalCharacteristics": [
479
+ "Input Consumption, W",
480
+ "Output Consumption, W"
481
+ ]
482
+ }
483
+ }
484
+ ],
485
+ }
486
+ ```
487
+
361
488
  ### PowerStream Micro-inverter
362
489
 
363
490
  #### Services
@@ -471,64 +598,6 @@ The following additional characteristics is available:
471
598
  }
472
599
  ```
473
600
 
474
- ### Glacier
475
-
476
- #### Services
477
-
478
- | EcoFlow Parameter | Service | Characteristic | Standard | Permission |
479
- | ----------------------------------- | --------------------- | -------------------------- | -------- | -------------------------------------------------------------------------------------------------------- |
480
- | Battery | Outlet | On | ✅ | Read (Battery Discharging > 0: ON) |
481
- | Battery Discharging | Outlet | OutletInUse | ✅ | Read |
482
- | Battery Level | Outlet | Battery Level, % | 🔲 | Read |
483
- | Battery Charging | Outlet | Input Consumption, W | 🔲 | Read |
484
- | Battery Discharging | Outlet | Output Consumption, W | 🔲 | Read |
485
- | Battery Charging State | Outlet | ChargingState, Yes/No | 🔲 | Read |
486
- | Battery Level | Outlet | StatusLowBattery, Yes/No | 🔲 | Read |
487
- | ECO mode | Switch | On | ✅ | Read/Write |
488
- | Door Opened | ContactSensor | ContactSensorState | ✅ | Read |
489
- | Make ice (small cubes) | Switch | On | ✅ | Read/Write (allowed when `Detach Ice` or `Make ice (large cubes)` options are not activated) |
490
- | Make ice (large cubes) | Switch | On | ✅ | Read/Write (allowed when `Detach Ice` or `Make ice (small cubes)` options are not activated) |
491
- | Detach ice | Switch | On | ✅ | Read/Write (allowed when `Make ice (small cubes)` or `Make ice (large cubes)` options are not activated) |
492
- | Dual Left Zone Current Temperature | Thermostat Dual Left | CurrentTemperature | ✅ | Read |
493
- | Dual Left Zone Target Temperature | Thermostat Dual Left | TargetTemperature | ✅ | Read/write (allowed when zone partition is installed) |
494
- | Device is ON/OFF | Thermostat Dual Left | CurrentHeatingCoolingState | ✅ | Read |
495
- | Device is ON/OFF | Thermostat Dual Left | TargetHeatingCoolingState | ✅ | Read |
496
- | Dual Right Zone Current Temperature | Thermostat Dual Right | CurrentTemperature | ✅ | Read |
497
- | Dual Right Zone Target Temperature | Thermostat Dual Right | TargetTemperature | ✅ | Read/write (allowed when zone partition is installed) |
498
- | Device is ON/OFF | Thermostat Dual Right | CurrentHeatingCoolingState | ✅ | Read |
499
- | Device is ON/OFF | Thermostat Dual Right | TargetHeatingCoolingState | ✅ | Read |
500
- | Single Zone Current Temperature | Thermostat Single | CurrentTemperature | ✅ | Read |
501
- | Single Zone Target Temperature | Thermostat Single | TargetTemperature | ✅ | Read/write (allowed when zone partition is removed) |
502
- | Device is ON/OFF | Thermostat Single | CurrentHeatingCoolingState | ✅ | Read |
503
- | Device is ON/OFF | Thermostat Single | TargetHeatingCoolingState | ✅ | Read |
504
-
505
- #### Configuration
506
-
507
- The following additional characteristics is available:
508
-
509
- - Battery Level, %
510
- - Input Consumption, W
511
- - Output Consumption, W
512
-
513
- ```json
514
- {
515
- ...
516
- "devices": [
517
- {
518
- ...
519
- "model": "Glacier",
520
- "battery": {
521
- "additionalCharacteristics": [
522
- "Battery Level, %",
523
- "Input Consumption, W",
524
- "Output Consumption, W"
525
- ]
526
- }
527
- }
528
- ],
529
- }
530
- ```
531
-
532
601
  ## Troubleshooting
533
602
 
534
603
  ### Debug
@@ -32,7 +32,7 @@
32
32
  "type": "string",
33
33
  "default": "Delta 2",
34
34
  "required": true,
35
- "enum": ["Delta 2", "Delta 2 Max", "Delta Pro 3", "PowerStream", "Smart Plug", "Glacier"]
35
+ "enum": ["Delta 2", "Delta 2 Max", "Delta Pro 3", "PowerStream", "Smart Plug"]
36
36
  },
37
37
  "serialNumber": {
38
38
  "title": "Serial Number",
@@ -148,6 +148,51 @@
148
148
  }
149
149
  }
150
150
  },
151
+ "powerOcean": {
152
+ "title": "PowerOcean Settings",
153
+ "type": "object",
154
+ "properties": {
155
+ "batteryAdditionalCharacteristics": {
156
+ "title": "Battery Additional Characteristics",
157
+ "description": "List of additional characteristics for Battery connected to PowerStream",
158
+ "type": "array",
159
+ "uniqueItems": true,
160
+ "items": {
161
+ "title": "Characteristic",
162
+ "type": "string",
163
+ "enum": [
164
+ "Battery Level, %",
165
+ "Input Consumption, W",
166
+ "Output Consumption, W",
167
+ "Charging State",
168
+ "Status Low Battery"
169
+ ]
170
+ }
171
+ },
172
+ "pvAdditionalCharacteristics": {
173
+ "title": "PV Additional Characteristics",
174
+ "description": "List of additional characteristics for PVs connected for PowerStream",
175
+ "type": "array",
176
+ "uniqueItems": true,
177
+ "items": {
178
+ "title": "Characteristic",
179
+ "type": "string",
180
+ "enum": ["Output Consumption, W"]
181
+ }
182
+ },
183
+ "inverterAdditionalCharacteristics": {
184
+ "title": "Inverter Additional Characteristics",
185
+ "description": "List of additional characteristics for PowerStream",
186
+ "type": "array",
187
+ "uniqueItems": true,
188
+ "items": {
189
+ "title": "Characteristic",
190
+ "type": "string",
191
+ "enum": ["Input Consumption, W", "Output Consumption, W"]
192
+ }
193
+ }
194
+ }
195
+ },
151
196
  "outlet": {
152
197
  "title": "Outlet Settings",
153
198
  "type": "object",
@@ -1,7 +1,7 @@
1
1
  import { DeviceInfo } from '@ecoflow/apis/containers/deviceInfo';
2
2
  import { EcoFlowHttpApiManager } from '@ecoflow/apis/ecoFlowHttpApiManager';
3
3
  import { EcoFlowMqttApiManager } from '@ecoflow/apis/ecoFlowMqttApiManager';
4
- import { MqttQuotaMessage, MqttSetMessage, MqttSetReplyMessage } from '@ecoflow/apis/interfaces/mqttApiContracts';
4
+ import { MqttQuotaMessage, MqttSetMessage, MqttSetReplyMessage, MqttStatusMessage } from '@ecoflow/apis/interfaces/mqttApiContracts';
5
5
  import { DeviceConfig } from '@ecoflow/config';
6
6
  import { EcoFlowHomebridgePlatform } from '@ecoflow/platform';
7
7
  import { ServiceBase } from '@ecoflow/services/serviceBase';
@@ -22,6 +22,7 @@ export declare abstract class EcoFlowAccessoryBase {
22
22
  readonly setReplies: Record<string, {
23
23
  requestMessage: MqttSetMessage;
24
24
  revert: () => void;
25
+ timeoutId: NodeJS.Timeout;
25
26
  }>;
26
27
  constructor(platform: EcoFlowHomebridgePlatform, accessory: PlatformAccessory, config: DeviceConfig, log: Logging, httpApiManager: EcoFlowHttpApiManager, mqttApiManager: EcoFlowMqttApiManager);
27
28
  get services(): ServiceBase[];
@@ -33,9 +34,11 @@ export declare abstract class EcoFlowAccessoryBase {
33
34
  protected abstract getServices(): ServiceBase[];
34
35
  protected subscribeOnParameterUpdates(): Subscription[];
35
36
  protected abstract processQuotaMessage(message: MqttQuotaMessage): void;
37
+ protected processStatusMessage(message: MqttStatusMessage): void;
36
38
  protected processSetReplyMessage(message: MqttSetReplyMessage): void;
37
39
  private getMqttSetMessageKey;
38
40
  private initializeServices;
39
41
  private connectMqtt;
40
42
  private initMqtt;
43
+ private setStatus;
41
44
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EcoFlowAccessoryBase = void 0;
4
4
  const deviceInfo_1 = require("@ecoflow/apis/containers/deviceInfo");
5
+ const characteristicContracts_1 = require("@ecoflow/characteristics/characteristicContracts");
5
6
  const accessoryInformationService_1 = require("@ecoflow/services/accessoryInformationService");
6
7
  class EcoFlowAccessoryBase {
7
8
  platform;
@@ -57,16 +58,34 @@ class EcoFlowAccessoryBase {
57
58
  async sendSetCommand(message, revert) {
58
59
  message.id = Math.floor(Math.random() * 1000000);
59
60
  message.version = '1.0';
60
- this.setReplies[this.getMqttSetMessageKey(message)] = { requestMessage: message, revert };
61
+ const messageKey = this.getMqttSetMessageKey(message);
62
+ const timeoutId = setTimeout(() => {
63
+ const command = this.setReplies[messageKey];
64
+ if (!command) {
65
+ this.log.debug('Timed out message is already processed. Ignore it:', message.id);
66
+ }
67
+ else {
68
+ this.log.warn('Sending of command is timed out. Reverts value back for:', message.id);
69
+ revert();
70
+ this.setStatus(false);
71
+ delete this.setReplies[messageKey];
72
+ }
73
+ }, this.config.setReplyWaitResponseTimeoutMs ?? 3000);
74
+ this.setReplies[messageKey] = { requestMessage: message, revert, timeoutId };
61
75
  await this.mqttApiManager.sendSetCommand(this.deviceInfo, message);
62
76
  }
63
77
  subscribeOnParameterUpdates() {
64
78
  const subscriptions = [
65
79
  this.mqttApiManager.subscribeOnQuotaMessage(this.deviceInfo, this.processQuotaMessage.bind(this)),
66
80
  this.mqttApiManager.subscribeOnSetReplyMessage(this.deviceInfo, this.processSetReplyMessage.bind(this)),
81
+ this.mqttApiManager.subscribeOnStatusMessage(this.deviceInfo, this.processStatusMessage.bind(this)),
67
82
  ];
68
83
  return subscriptions.filter(subscription => !!subscription);
69
84
  }
85
+ processStatusMessage(message) {
86
+ const online = message.params.status === characteristicContracts_1.EnableType.On;
87
+ this.setStatus(online);
88
+ }
70
89
  processSetReplyMessage(message) {
71
90
  const messageKey = this.getMqttSetMessageKey(message);
72
91
  const command = this.setReplies[messageKey];
@@ -74,6 +93,7 @@ class EcoFlowAccessoryBase {
74
93
  this.log.debug('Received "SetReply" response was not sent by accessory. Ignore it:', message);
75
94
  return;
76
95
  }
96
+ clearTimeout(command.timeoutId);
77
97
  this.log.debug('Received "SetReply" response:', message);
78
98
  delete this.setReplies[messageKey];
79
99
  // Detect whether response is successfull for different contracts (e.g. data.ack, data.result, data.configOk)
@@ -108,11 +128,16 @@ class EcoFlowAccessoryBase {
108
128
  async initMqtt() {
109
129
  this.isMqttConnected =
110
130
  (await this.mqttApiManager.subscribeOnQuotaTopic(this.deviceInfo)) &&
111
- (await this.mqttApiManager.subscribeOnSetReplyTopic(this.deviceInfo));
131
+ (await this.mqttApiManager.subscribeOnSetReplyTopic(this.deviceInfo)) &&
132
+ (await this.mqttApiManager.subscribeOnStatusTopic(this.deviceInfo));
112
133
  if (this.isMqttConnected) {
113
134
  this.subscriptions = this.subscribeOnParameterUpdates();
114
135
  }
115
136
  }
137
+ setStatus(online) {
138
+ this.log.warn(`Device is ${online ? 'online' : 'offline'}`);
139
+ this.services.forEach(service => service.updateReachability(online));
140
+ }
116
141
  }
117
142
  exports.EcoFlowAccessoryBase = EcoFlowAccessoryBase;
118
143
  //# sourceMappingURL=ecoFlowAccessoryBase.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ecoFlowAccessoryBase.js","sourceRoot":"","sources":["../../src/accessories/ecoFlowAccessoryBase.ts"],"names":[],"mappings":";;;AAAA,oEAAiE;AAMjE,+FAA4F;AAK5F,MAAsB,oBAAoB;IAStB;IACA;IACA;IACA;IACG;IACA;IAbb,SAAS,GAAkB,EAAE,CAAC;IAC9B,sBAAsB,GAA0B,IAAI,CAAC;IACrD,eAAe,GAAY,KAAK,CAAC;IACjC,aAAa,GAAmB,EAAE,CAAC;IACxB,UAAU,CAAa;IAC1B,UAAU,GAA2E,EAAE,CAAC;IAExG,YACkB,QAAmC,EACnC,SAA4B,EAC5B,MAAoB,EACpB,GAAY,EACT,cAAqC,EACrC,cAAqC;QALxC,aAAQ,GAAR,QAAQ,CAA2B;QACnC,cAAS,GAAT,SAAS,CAAmB;QAC5B,WAAM,GAAN,MAAM,CAAc;QACpB,QAAG,GAAH,GAAG,CAAS;QACT,mBAAc,GAAd,cAAc,CAAuB;QACrC,mBAAc,GAAd,cAAc,CAAuB;QAExD,IAAI,CAAC,UAAU,GAAG,IAAI,uBAAU,CAAC,MAAM,EA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JC"}
@@ -0,0 +1,7 @@
1
+ export interface PowerOceanAllQuotaData {
2
+ evPwr?: number;
3
+ bpPwr?: number;
4
+ bpSoc?: number;
5
+ sysLoadPwr?: number;
6
+ sysGridPwr?: number;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=powerOceanHttpApiContracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powerOceanHttpApiContracts.js","sourceRoot":"","sources":["../../../../src/accessories/powerocean/interfaces/powerOceanHttpApiContracts.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { MqttQuotaMessage, MqttQuotaMessageWithParams } from '@ecoflow/apis/interfaces/mqttApiContracts';
2
+ export interface PowerOceanMqttQuotaMessage extends MqttQuotaMessage {
3
+ }
4
+ export interface PowerOceanMqttQuotaMessageWithParams<TParams> extends MqttQuotaMessageWithParams<TParams>, PowerOceanMqttQuotaMessage {
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=powerOceanMqttApiContracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powerOceanMqttApiContracts.js","sourceRoot":"","sources":["../../../../src/accessories/powerocean/interfaces/powerOceanMqttApiContracts.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ import { EcoFlowAccessoryWithQuotaBase } from '@ecoflow/accessories/ecoFlowAccessoryWithQuotaBase';
2
+ import { PowerOceanAllQuotaData } from '@ecoflow/accessories/powerocean/interfaces/powerOceanHttpApiContracts';
3
+ import { EcoFlowHttpApiManager } from '@ecoflow/apis/ecoFlowHttpApiManager';
4
+ import { EcoFlowMqttApiManager } from '@ecoflow/apis/ecoFlowMqttApiManager';
5
+ import { MqttQuotaMessage } from '@ecoflow/apis/interfaces/mqttApiContracts';
6
+ import { DeviceConfig } from '@ecoflow/config';
7
+ import { BatteryStatusProvider } from '@ecoflow/helpers/batteryStatusProvider';
8
+ import { EcoFlowHomebridgePlatform } from '@ecoflow/platform';
9
+ import { ServiceBase } from '@ecoflow/services/serviceBase';
10
+ import { Logging, PlatformAccessory } from 'homebridge';
11
+ export declare class PowerOceanAccessory extends EcoFlowAccessoryWithQuotaBase<PowerOceanAllQuotaData> {
12
+ private readonly inverterOutletService;
13
+ private readonly solarOutletService;
14
+ private readonly batteryOutletService;
15
+ constructor(platform: EcoFlowHomebridgePlatform, accessory: PlatformAccessory, config: DeviceConfig, log: Logging, httpApiManager: EcoFlowHttpApiManager, mqttApiManager: EcoFlowMqttApiManager, batteryStatusProvider: BatteryStatusProvider);
16
+ protected getServices(): ServiceBase[];
17
+ protected processQuotaMessage(message: MqttQuotaMessage): void;
18
+ protected initializeQuota(quota: PowerOceanAllQuotaData | null): PowerOceanAllQuotaData;
19
+ protected updateInitialValues(initialData: PowerOceanAllQuotaData): void;
20
+ private updateValues;
21
+ private updateSolarValues;
22
+ private updateBatteryValues;
23
+ private updateInverterValues;
24
+ }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PowerOceanAccessory = void 0;
4
+ const ecoFlowAccessoryWithQuotaBase_1 = require("@ecoflow/accessories/ecoFlowAccessoryWithQuotaBase");
5
+ const outletReadOnlyService_1 = require("@ecoflow/services/outletReadOnlyService");
6
+ class PowerOceanAccessory extends ecoFlowAccessoryWithQuotaBase_1.EcoFlowAccessoryWithQuotaBase {
7
+ inverterOutletService;
8
+ solarOutletService;
9
+ batteryOutletService;
10
+ constructor(platform, accessory, config, log, httpApiManager, mqttApiManager, batteryStatusProvider) {
11
+ super(platform, accessory, config, log, httpApiManager, mqttApiManager);
12
+ this.inverterOutletService = new outletReadOnlyService_1.OutletReadOnlyService(this, batteryStatusProvider, 'INV', config.powerOcean?.inverterAdditionalCharacteristics);
13
+ this.solarOutletService = new outletReadOnlyService_1.OutletReadOnlyService(this, batteryStatusProvider, 'PV', config.powerOcean?.pvAdditionalCharacteristics);
14
+ this.batteryOutletService = new outletReadOnlyService_1.OutletReadOnlyService(this, batteryStatusProvider, 'BAT', config.powerOcean?.batteryAdditionalCharacteristics);
15
+ }
16
+ getServices() {
17
+ return [this.inverterOutletService, this.solarOutletService, this.batteryOutletService];
18
+ }
19
+ processQuotaMessage(message) {
20
+ const params = message.params;
21
+ if (params.bpPwr !== undefined) {
22
+ this.quota.bpPwr = params.bpPwr;
23
+ }
24
+ if (params.bpSoc !== undefined) {
25
+ this.quota.bpSoc = params.bpSoc;
26
+ }
27
+ if (params.evPwr !== undefined) {
28
+ this.quota.evPwr = params.evPwr;
29
+ }
30
+ if (params.sysGridPwr !== undefined) {
31
+ this.quota.sysGridPwr = params.sysGridPwr;
32
+ }
33
+ if (params.sysLoadPwr !== undefined) {
34
+ this.quota.sysLoadPwr = params.sysLoadPwr;
35
+ }
36
+ this.updateValues(params);
37
+ }
38
+ initializeQuota(quota) {
39
+ const result = quota ?? {};
40
+ return result;
41
+ }
42
+ updateInitialValues(initialData) {
43
+ const message = {
44
+ params: initialData,
45
+ };
46
+ this.processQuotaMessage(message);
47
+ }
48
+ updateValues(params) {
49
+ this.updateSolarValues(params);
50
+ this.updateBatteryValues(params);
51
+ this.updateInverterValues(params);
52
+ }
53
+ updateSolarValues(params) {
54
+ if (params.evPwr !== undefined) {
55
+ this.solarOutletService.updateState(params.evPwr > 0);
56
+ this.solarOutletService.updateOutputConsumption(params.evPwr);
57
+ }
58
+ }
59
+ updateBatteryValues(params) {
60
+ if (params.bpPwr !== undefined) {
61
+ if (params.bpPwr >= 0) {
62
+ this.batteryOutletService.updateState(params.bpPwr > 0);
63
+ this.batteryOutletService.updateChargingState(false);
64
+ this.batteryOutletService.updateOutputConsumption(params.bpPwr);
65
+ }
66
+ if (params.bpPwr <= 0) {
67
+ const watts = Math.abs(params.bpPwr);
68
+ this.batteryOutletService.updateChargingState(watts > 0);
69
+ this.batteryOutletService.updateInputConsumption(watts);
70
+ }
71
+ }
72
+ if (params.bpSoc !== undefined) {
73
+ this.batteryOutletService.updateBatteryLevel(params.bpSoc, 20);
74
+ }
75
+ }
76
+ updateInverterValues(params) {
77
+ if (params.sysLoadPwr !== undefined) {
78
+ this.inverterOutletService.updateOutputConsumption(params.sysLoadPwr);
79
+ this.inverterOutletService.updateState(true);
80
+ }
81
+ if (params.sysGridPwr !== undefined) {
82
+ this.inverterOutletService.updateInputConsumption(params.sysGridPwr);
83
+ }
84
+ }
85
+ }
86
+ exports.PowerOceanAccessory = PowerOceanAccessory;
87
+ //# sourceMappingURL=powerOceanAccessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powerOceanAccessory.js","sourceRoot":"","sources":["../../../src/accessories/powerocean/powerOceanAccessory.ts"],"names":[],"mappings":";;;AAAA,sGAAmG;AASnG,mFAAgF;AAIhF,MAAa,mBAAoB,SAAQ,6DAAqD;IAC3E,qBAAqB,CAAwB;IAC7C,kBAAkB,CAAwB;IAC1C,oBAAoB,CAAwB;IAE7D,YACE,QAAmC,EACnC,SAA4B,EAC5B,MAAoB,EACpB,GAAY,EACZ,cAAqC,EACrC,cAAqC,EACrC,qBAA4C;QAE5C,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;QAExE,IAAI,CAAC,qBAAqB,GAAG,IAAI,6CAAqB,CACpD,IAAI,EACJ,qBAAqB,EACrB,KAAK,EACL,MAAM,CAAC,UAAU,EAAE,iCAAiC,CACrD,CAAC;QACF,IAAI,CAAC,kBAAkB,GAAG,IAAI,6CAAqB,CACjD,IAAI,EACJ,qBAAqB,EACrB,IAAI,EACJ,MAAM,CAAC,UAAU,EAAE,2BAA2B,CAC/C,CAAC;QACF,IAAI,CAAC,oBAAoB,GAAG,IAAI,6CAAqB,CACnD,IAAI,EACJ,qBAAqB,EACrB,KAAK,EACL,MAAM,CAAC,UAAU,EAAE,gCAAgC,CACpD,CAAC;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,KAAK,EAAE,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAEO,oBAAoB,CAAC,MAA8B;QACzD,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,qBAAqB,CAAC,uBAAuB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YACtE,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,qBAAqB,CAAC,sBAAsB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;CACF;AAjHD,kDAiHC"}
@@ -0,0 +1,5 @@
1
+ import { Simulator } from '@ecoflow/apis/simulations/simulator';
2
+ export declare class PowerOceanSimulator extends Simulator {
3
+ generateQuota(): object;
4
+ generateSetReply(message: string): object;
5
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PowerOceanSimulator = void 0;
4
+ const simulator_1 = require("@ecoflow/apis/simulations/simulator");
5
+ class PowerOceanSimulator extends simulator_1.Simulator {
6
+ generateQuota() {
7
+ const quota = {
8
+ params: {
9
+ evPwr: this.getRandomNumber(1, 10000),
10
+ bpPwr: this.getRandomNumber(-10000, 10000),
11
+ bpSoc: this.getRandomNumber(0, 100),
12
+ sysGridPwr: this.getRandomNumber(1, 10000),
13
+ sysLoadPwr: this.getRandomNumber(1, 10000),
14
+ },
15
+ };
16
+ return quota;
17
+ }
18
+ generateSetReply(message) {
19
+ throw new Error(`SetReply command "${message}" is not supported for PowerOcean`);
20
+ }
21
+ }
22
+ exports.PowerOceanSimulator = PowerOceanSimulator;
23
+ //# sourceMappingURL=powerOceanSimulator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powerOceanSimulator.js","sourceRoot":"","sources":["../../../../src/accessories/powerocean/simulations/powerOceanSimulator.ts"],"names":[],"mappings":";;;AAEA,mEAAgE;AAEhE,MAAa,mBAAoB,SAAQ,qBAAS;IAChC,aAAa;QAC3B,MAAM,KAAK,GAAiE;YAC1E,MAAM,EAAE;gBACN,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,KAAK,CAAC;gBACrC,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC;gBAC1C,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,GAAG,CAAC;gBACnC,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,KAAK,CAAC;gBAC1C,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,KAAK,CAAC;aAC3C;SACF,CAAC;QACF,OAAO,KAAK,CAAC;IACf,CAAC;IAEe,gBAAgB,CAAC,OAAe;QAC9C,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,mCAAmC,CAAC,CAAC;IACnF,CAAC;CACF;AAjBD,kDAiBC"}