@pietrolubini/homebridge-ecoflow 1.2.0 → 1.3.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 (205) hide show
  1. package/.gitattributes +7 -0
  2. package/.prettierrc.json +1 -0
  3. package/README.md +154 -24
  4. package/config.schema.json +73 -2
  5. package/dist/accessories/batteries/batteryAccessoryBase.d.ts +26 -0
  6. package/dist/accessories/batteries/batteryAccessoryBase.js +126 -0
  7. package/dist/accessories/batteries/batteryAccessoryBase.js.map +1 -0
  8. package/dist/accessories/batteries/batteryAccessoryBase.spec.d.ts +1 -0
  9. package/dist/accessories/batteries/delta2Accessory.d.ts +2 -2
  10. package/dist/accessories/batteries/delta2Accessory.js +6 -2
  11. package/dist/accessories/batteries/delta2Accessory.js.map +1 -1
  12. package/dist/accessories/batteries/delta2maxAccessory.d.ts +2 -2
  13. package/dist/accessories/batteries/delta2maxAccessory.js +6 -2
  14. package/dist/accessories/batteries/delta2maxAccessory.js.map +1 -1
  15. package/dist/accessories/batteries/interfaces/httpApiBatteryContracts.d.ts +33 -0
  16. package/dist/accessories/batteries/interfaces/httpApiBatteryContracts.js +3 -0
  17. package/dist/accessories/batteries/interfaces/httpApiBatteryContracts.js.map +1 -0
  18. package/dist/accessories/batteries/interfaces/mqttApiBatteryContracts.d.ts +36 -0
  19. package/dist/accessories/batteries/interfaces/mqttApiBatteryContracts.js +18 -0
  20. package/dist/accessories/batteries/interfaces/mqttApiBatteryContracts.js.map +1 -0
  21. package/dist/accessories/batteries/services/outletAcService.d.ts +8 -0
  22. package/dist/accessories/batteries/services/outletAcService.js +24 -0
  23. package/dist/accessories/batteries/services/outletAcService.js.map +1 -0
  24. package/dist/accessories/batteries/services/outletAcService.spec.d.ts +1 -0
  25. package/dist/accessories/batteries/services/outletBatteryServiceBase.d.ts +5 -0
  26. package/dist/accessories/batteries/services/outletBatteryServiceBase.js +18 -0
  27. package/dist/accessories/batteries/services/outletBatteryServiceBase.js.map +1 -0
  28. package/dist/accessories/batteries/services/outletCarService.d.ts +6 -0
  29. package/dist/accessories/batteries/services/outletCarService.js +17 -0
  30. package/dist/accessories/batteries/services/outletCarService.js.map +1 -0
  31. package/dist/accessories/batteries/services/outletCarService.spec.d.ts +1 -0
  32. package/dist/accessories/batteries/services/outletUsbService.d.ts +6 -0
  33. package/dist/accessories/batteries/services/outletUsbService.js +15 -0
  34. package/dist/accessories/batteries/services/outletUsbService.js.map +1 -0
  35. package/dist/accessories/batteries/services/outletUsbService.spec.d.ts +1 -0
  36. package/dist/accessories/batteries/simulations/batterySimulator.d.ts +6 -0
  37. package/dist/accessories/batteries/simulations/batterySimulator.js +60 -0
  38. package/dist/accessories/batteries/simulations/batterySimulator.js.map +1 -0
  39. package/dist/accessories/ecoFlowAccessoryBase.d.ts +41 -0
  40. package/dist/accessories/ecoFlowAccessoryBase.js +114 -0
  41. package/dist/accessories/ecoFlowAccessoryBase.js.map +1 -0
  42. package/dist/accessories/ecoFlowAccessoryBase.spec.d.ts +1 -0
  43. package/dist/accessories/ecoFlowAccessoryWithQuotaBase.d.ts +15 -0
  44. package/dist/accessories/ecoFlowAccessoryWithQuotaBase.js +34 -0
  45. package/dist/accessories/ecoFlowAccessoryWithQuotaBase.js.map +1 -0
  46. package/dist/accessories/ecoFlowAccessoryWithQuotaBase.spec.d.ts +1 -0
  47. package/dist/accessories/powerstream/interfaces/httpApiPowerStreamContracts.d.ts +16 -0
  48. package/dist/accessories/powerstream/interfaces/httpApiPowerStreamContracts.js +3 -0
  49. package/dist/accessories/powerstream/interfaces/httpApiPowerStreamContracts.js.map +1 -0
  50. package/dist/accessories/powerstream/interfaces/mqttApiPowerStreamContracts.d.ts +41 -0
  51. package/dist/accessories/powerstream/interfaces/mqttApiPowerStreamContracts.js +21 -0
  52. package/dist/accessories/powerstream/interfaces/mqttApiPowerStreamContracts.js.map +1 -0
  53. package/dist/accessories/powerstream/powerStreamAccessory.d.ts +26 -0
  54. package/dist/accessories/powerstream/powerStreamAccessory.js +113 -0
  55. package/dist/accessories/powerstream/powerStreamAccessory.js.map +1 -0
  56. package/dist/accessories/powerstream/powerStreamAccessory.spec.d.ts +1 -0
  57. package/dist/accessories/powerstream/services/brightnessService.d.ts +7 -0
  58. package/dist/accessories/powerstream/services/brightnessService.js +27 -0
  59. package/dist/accessories/powerstream/services/brightnessService.js.map +1 -0
  60. package/dist/accessories/powerstream/services/brightnessService.spec.d.ts +1 -0
  61. package/dist/accessories/powerstream/services/outletInvService.d.ts +7 -0
  62. package/dist/accessories/powerstream/services/outletInvService.js +14 -0
  63. package/dist/accessories/powerstream/services/outletInvService.js.map +1 -0
  64. package/dist/accessories/powerstream/services/outletInvService.spec.d.ts +1 -0
  65. package/dist/accessories/powerstream/services/outletService.d.ts +8 -0
  66. package/dist/accessories/powerstream/services/outletService.js +14 -0
  67. package/dist/accessories/powerstream/services/outletService.js.map +1 -0
  68. package/dist/accessories/powerstream/services/outletService.spec.d.ts +1 -0
  69. package/dist/accessories/powerstream/services/powerDemandService.d.ts +7 -0
  70. package/dist/accessories/powerstream/services/powerDemandService.js +27 -0
  71. package/dist/accessories/powerstream/services/powerDemandService.js.map +1 -0
  72. package/dist/accessories/powerstream/services/powerDemandService.spec.d.ts +1 -0
  73. package/dist/accessories/powerstream/simulations/powerStreamSimulator.d.ts +6 -0
  74. package/dist/accessories/powerstream/simulations/powerStreamSimulator.js +39 -0
  75. package/dist/accessories/powerstream/simulations/powerStreamSimulator.js.map +1 -0
  76. package/dist/apis/containers/deviceInfo.d.ts +13 -0
  77. package/dist/apis/containers/deviceInfo.js +23 -0
  78. package/dist/apis/containers/deviceInfo.js.map +1 -0
  79. package/dist/apis/containers/deviceInfo.spec.d.ts +1 -0
  80. package/dist/apis/containers/mqttClientContainer.d.ts +17 -0
  81. package/dist/apis/containers/mqttClientContainer.js +45 -0
  82. package/dist/apis/containers/mqttClientContainer.js.map +1 -0
  83. package/dist/apis/containers/mqttClientContainer.spec.d.ts +1 -0
  84. package/dist/apis/containers/mqttDevice.d.ts +15 -0
  85. package/dist/apis/containers/mqttDevice.js +43 -0
  86. package/dist/apis/containers/mqttDevice.js.map +1 -0
  87. package/dist/apis/containers/mqttDevice.spec.d.ts +1 -0
  88. package/dist/apis/ecoFlowHttpApiManager.d.ts +13 -0
  89. package/dist/apis/{ecoFlowHttpApi.js → ecoFlowHttpApiManager.js} +58 -44
  90. package/dist/apis/ecoFlowHttpApiManager.js.map +1 -0
  91. package/dist/apis/ecoFlowHttpApiManager.spec.d.ts +1 -0
  92. package/dist/apis/ecoFlowMqttApiManager.d.ts +25 -0
  93. package/dist/apis/ecoFlowMqttApiManager.js +152 -0
  94. package/dist/apis/ecoFlowMqttApiManager.js.map +1 -0
  95. package/dist/apis/ecoFlowMqttApiManager.spec.d.ts +1 -0
  96. package/dist/apis/interfaces/httpApiContracts.d.ts +30 -0
  97. package/dist/apis/interfaces/httpApiContracts.js +9 -0
  98. package/dist/apis/interfaces/httpApiContracts.js.map +1 -0
  99. package/dist/apis/interfaces/mqttApiContracts.d.ts +26 -0
  100. package/dist/apis/interfaces/mqttApiContracts.js +9 -0
  101. package/dist/apis/interfaces/mqttApiContracts.js.map +1 -0
  102. package/dist/apis/simulations/mockMqttClient.d.ts +15 -0
  103. package/dist/apis/simulations/mockMqttClient.js +59 -0
  104. package/dist/apis/simulations/mockMqttClient.js.map +1 -0
  105. package/dist/apis/simulations/mockMqttClient.spec.d.ts +1 -0
  106. package/dist/apis/simulations/simulator.d.ts +13 -0
  107. package/dist/apis/simulations/simulator.js +26 -0
  108. package/dist/apis/simulations/simulator.js.map +1 -0
  109. package/dist/characteristics/customCharacteristic.d.ts +18 -0
  110. package/dist/characteristics/customCharacteristic.js +94 -0
  111. package/dist/characteristics/customCharacteristic.js.map +1 -0
  112. package/dist/characteristics/customCharacteristic.spec.d.ts +1 -0
  113. package/dist/config.d.ts +33 -4
  114. package/dist/config.js +18 -4
  115. package/dist/config.js.map +1 -1
  116. package/dist/helpers/logger.js +5 -1
  117. package/dist/helpers/logger.js.map +1 -1
  118. package/dist/helpers/logger.spec.d.ts +1 -0
  119. package/dist/helpers/machineIdProvider.d.ts +4 -0
  120. package/dist/helpers/machineIdProvider.js +19 -0
  121. package/dist/helpers/machineIdProvider.js.map +1 -0
  122. package/dist/helpers/machineIdProvider.spec.d.ts +1 -0
  123. package/dist/helpers/tests/accessoryTestHelper.d.ts +5 -0
  124. package/dist/helpers/tests/serviceTestHelper.d.ts +6 -0
  125. package/dist/helpers/tests/sleep.d.ts +1 -0
  126. package/dist/homebridge-ui/public/index.d.ts +2 -0
  127. package/dist/homebridge-ui/public/index.html +6 -0
  128. package/dist/homebridge-ui/public/index.js +1 -0
  129. package/dist/homebridge-ui/public/index.spec.d.ts +1 -0
  130. package/dist/homebridge-ui/public/interfaces/contracts.d.ts +13 -0
  131. package/dist/homebridge-ui/public/interfaces/homebridge.d.ts +52 -0
  132. package/dist/homebridge-ui/public/renderers/componentRenderer.d.ts +6 -0
  133. package/dist/homebridge-ui/public/renderers/componentRenderer.spec.d.ts +1 -0
  134. package/dist/homebridge-ui/public/renderers/pluginConfigDevicesRenderer.d.ts +20 -0
  135. package/dist/homebridge-ui/public/renderers/pluginConfigDevicesRenderer.spec.d.ts +1 -0
  136. package/dist/homebridge-ui/public/renderers/pluginConfigNameRenderer.d.ts +5 -0
  137. package/dist/homebridge-ui/public/renderers/pluginConfigNameRenderer.spec.d.ts +1 -0
  138. package/dist/homebridge-ui/public/renderers/pluginConfigRenderer.d.ts +6 -0
  139. package/dist/homebridge-ui/public/renderers/pluginConfigRenderer.spec.d.ts +1 -0
  140. package/dist/homebridge-ui/public/renderers/pluginConfigRendererBase.d.ts +9 -0
  141. package/dist/index.js +7 -4
  142. package/dist/index.js.map +1 -1
  143. package/dist/index.spec.d.ts +1 -0
  144. package/dist/platform.d.ts +12 -8
  145. package/dist/platform.js +91 -30
  146. package/dist/platform.js.map +1 -1
  147. package/dist/platform.spec.d.ts +1 -0
  148. package/dist/services/accessoryInformationService.d.ts +5 -3
  149. package/dist/services/accessoryInformationService.js +15 -12
  150. package/dist/services/accessoryInformationService.js.map +1 -1
  151. package/dist/services/accessoryInformationService.spec.d.ts +1 -0
  152. package/dist/services/batteryStatusService.d.ts +6 -4
  153. package/dist/services/batteryStatusService.js +19 -17
  154. package/dist/services/batteryStatusService.js.map +1 -1
  155. package/dist/services/batteryStatusService.spec.d.ts +1 -0
  156. package/dist/services/fanServiceBase.d.ts +16 -0
  157. package/dist/services/fanServiceBase.js +42 -0
  158. package/dist/services/fanServiceBase.js.map +1 -0
  159. package/dist/services/fanServiceBase.spec.d.ts +1 -0
  160. package/dist/services/lightBulbServiceBase.d.ts +16 -0
  161. package/dist/services/lightBulbServiceBase.js +42 -0
  162. package/dist/services/lightBulbServiceBase.js.map +1 -0
  163. package/dist/services/lightBulbServiceBase.spec.d.ts +1 -0
  164. package/dist/services/outletServiceBase.d.ts +7 -15
  165. package/dist/services/outletServiceBase.js +20 -28
  166. package/dist/services/outletServiceBase.js.map +1 -1
  167. package/dist/services/outletServiceBase.spec.d.ts +1 -0
  168. package/dist/services/serviceBase.d.ts +10 -5
  169. package/dist/services/serviceBase.js +31 -8
  170. package/dist/services/serviceBase.js.map +1 -1
  171. package/dist/settings.js +5 -2
  172. package/dist/settings.js.map +1 -1
  173. package/docs/images/plugin_icon.png +0 -0
  174. package/jest.config.ts +46 -0
  175. package/junit.xml +843 -0
  176. package/package.json +42 -12
  177. package/tsconfig.build.json +5 -0
  178. package/tsconfig.spec.json +8 -0
  179. package/dist/accessories/batteries/batteryAccessory.d.ts +0 -59
  180. package/dist/accessories/batteries/batteryAccessory.js +0 -120
  181. package/dist/accessories/batteries/batteryAccessory.js.map +0 -1
  182. package/dist/accessories/ecoFlowAccessory.d.ts +0 -42
  183. package/dist/accessories/ecoFlowAccessory.js +0 -116
  184. package/dist/accessories/ecoFlowAccessory.js.map +0 -1
  185. package/dist/apis/ecoFlowHttpApi.d.ts +0 -46
  186. package/dist/apis/ecoFlowHttpApi.js.map +0 -1
  187. package/dist/apis/ecoFlowMqttApi.d.ts +0 -53
  188. package/dist/apis/ecoFlowMqttApi.js +0 -100
  189. package/dist/apis/ecoFlowMqttApi.js.map +0 -1
  190. package/dist/characteristics/CustomCharacteristic.d.ts +0 -16
  191. package/dist/characteristics/CustomCharacteristic.js +0 -78
  192. package/dist/characteristics/CustomCharacteristic.js.map +0 -1
  193. package/dist/helpers/machineId.d.ts +0 -2
  194. package/dist/helpers/machineId.js +0 -15
  195. package/dist/helpers/machineId.js.map +0 -1
  196. package/dist/helpers/machineIdHelper.cjs +0 -5
  197. package/dist/services/outletAcService.d.ts +0 -8
  198. package/dist/services/outletAcService.js +0 -17
  199. package/dist/services/outletAcService.js.map +0 -1
  200. package/dist/services/outletCarService.d.ts +0 -6
  201. package/dist/services/outletCarService.js +0 -12
  202. package/dist/services/outletCarService.js.map +0 -1
  203. package/dist/services/outletUsbService.d.ts +0 -6
  204. package/dist/services/outletUsbService.js +0 -10
  205. package/dist/services/outletUsbService.js.map +0 -1
@@ -0,0 +1,36 @@
1
+ import { MqttQuotaMessage, MqttQuotaMessageWithParams, MqttSetMessage, MqttSetMessageWithParams, MqttSetReplyMessage } from '@ecoflow/apis/interfaces/mqttApiContracts';
2
+ export declare enum MqttBatteryMessageType {
3
+ PD = "pdStatus",
4
+ MPPT = "mpptStatus",
5
+ INV = "invStatus",
6
+ BMS = "bmsStatus",
7
+ EMS = "emsStatus"
8
+ }
9
+ export interface MqttBatteryQuotaMessage extends MqttQuotaMessage {
10
+ typeCode: MqttBatteryMessageType;
11
+ }
12
+ export interface MqttBatteryQuotaMessageWithParams<TParams> extends MqttQuotaMessageWithParams<TParams>, MqttBatteryQuotaMessage {
13
+ }
14
+ export declare enum MqttBatterySetOperationType {
15
+ MpptCar = "mpptCar",
16
+ DcOutCfg = "dcOutCfg",
17
+ AcOutCfg = "acOutCfg"
18
+ }
19
+ export interface MqttBatterySetMessage extends MqttSetMessage {
20
+ operateType: MqttBatterySetOperationType;
21
+ moduleType: number;
22
+ }
23
+ export interface MqttBatterySetMessageWithParams<TParams> extends MqttSetMessageWithParams<TParams>, MqttBatterySetMessage {
24
+ }
25
+ export interface MqttBatterySetOnMessageParams {
26
+ enabled: number;
27
+ }
28
+ export interface MqttBatterySetAcOnMessageParams extends MqttBatterySetOnMessageParams {
29
+ out_voltage: number;
30
+ out_freq: number;
31
+ xboost: number;
32
+ }
33
+ export interface MqttBatterySetReplyMessage extends MqttSetReplyMessage {
34
+ operateType: MqttBatterySetOperationType;
35
+ moduleType: number;
36
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MqttBatterySetOperationType = exports.MqttBatteryMessageType = void 0;
4
+ var MqttBatteryMessageType;
5
+ (function (MqttBatteryMessageType) {
6
+ MqttBatteryMessageType["PD"] = "pdStatus";
7
+ MqttBatteryMessageType["MPPT"] = "mpptStatus";
8
+ MqttBatteryMessageType["INV"] = "invStatus";
9
+ MqttBatteryMessageType["BMS"] = "bmsStatus";
10
+ MqttBatteryMessageType["EMS"] = "emsStatus";
11
+ })(MqttBatteryMessageType || (exports.MqttBatteryMessageType = MqttBatteryMessageType = {}));
12
+ var MqttBatterySetOperationType;
13
+ (function (MqttBatterySetOperationType) {
14
+ MqttBatterySetOperationType["MpptCar"] = "mpptCar";
15
+ MqttBatterySetOperationType["DcOutCfg"] = "dcOutCfg";
16
+ MqttBatterySetOperationType["AcOutCfg"] = "acOutCfg";
17
+ })(MqttBatterySetOperationType || (exports.MqttBatterySetOperationType = MqttBatterySetOperationType = {}));
18
+ //# sourceMappingURL=mqttApiBatteryContracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mqttApiBatteryContracts.js","sourceRoot":"","sources":["../../../../src/accessories/batteries/interfaces/mqttApiBatteryContracts.ts"],"names":[],"mappings":";;;AAQA,IAAY,sBAMX;AAND,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,6CAAmB,CAAA;IACnB,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;AACnB,CAAC,EANW,sBAAsB,sCAAtB,sBAAsB,QAMjC;AAUD,IAAY,2BAIX;AAJD,WAAY,2BAA2B;IACrC,kDAAmB,CAAA;IACnB,oDAAqB,CAAA;IACrB,oDAAqB,CAAA;AACvB,CAAC,EAJW,2BAA2B,2CAA3B,2BAA2B,QAItC"}
@@ -0,0 +1,8 @@
1
+ import { BatteryAllQuotaData } from '@ecoflow/accessories/batteries/interfaces/httpApiBatteryContracts';
2
+ import { OutletBatteryServiceBase } from '@ecoflow/accessories/batteries/services/outletBatteryServiceBase';
3
+ import { EcoFlowAccessoryWithQuotaBase } from '@ecoflow/accessories/ecoFlowAccessoryWithQuotaBase';
4
+ export declare class OutletAcService extends OutletBatteryServiceBase {
5
+ protected readonly ecoFlowAccessory: EcoFlowAccessoryWithQuotaBase<BatteryAllQuotaData>;
6
+ constructor(ecoFlowAccessory: EcoFlowAccessoryWithQuotaBase<BatteryAllQuotaData>);
7
+ protected setOn(value: boolean, revert: () => void): Promise<void>;
8
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OutletAcService = void 0;
4
+ const mqttApiBatteryContracts_1 = require("@ecoflow/accessories/batteries/interfaces/mqttApiBatteryContracts");
5
+ const outletBatteryServiceBase_1 = require("@ecoflow/accessories/batteries/services/outletBatteryServiceBase");
6
+ class OutletAcService extends outletBatteryServiceBase_1.OutletBatteryServiceBase {
7
+ ecoFlowAccessory;
8
+ constructor(ecoFlowAccessory) {
9
+ super(ecoFlowAccessory, 'AC', ecoFlowAccessory.config.battery?.additionalCharacteristics);
10
+ this.ecoFlowAccessory = ecoFlowAccessory;
11
+ }
12
+ setOn(value, revert) {
13
+ return this.sendOn(3, mqttApiBatteryContracts_1.MqttBatterySetOperationType.AcOutCfg, {
14
+ out_voltage: this.ecoFlowAccessory.quota.inv.cfgAcOutVol !== undefined
15
+ ? this.ecoFlowAccessory.quota.inv.cfgAcOutVol
16
+ : 220000,
17
+ out_freq: this.ecoFlowAccessory.quota.inv.cfgAcOutFreq !== undefined ? this.ecoFlowAccessory.quota.inv.cfgAcOutFreq : 1,
18
+ xboost: Number(this.ecoFlowAccessory.quota.inv.cfgAcXboost !== undefined ? this.ecoFlowAccessory.quota.inv.cfgAcXboost : true),
19
+ enabled: Number(value),
20
+ }, revert);
21
+ }
22
+ }
23
+ exports.OutletAcService = OutletAcService;
24
+ //# sourceMappingURL=outletAcService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outletAcService.js","sourceRoot":"","sources":["../../../../src/accessories/batteries/services/outletAcService.ts"],"names":[],"mappings":";;;AACA,+GAG2E;AAC3E,+GAA4G;AAG5G,MAAa,eAAgB,SAAQ,mDAAwB;IAC5B;IAA/B,YAA+B,gBAAoE;QACjG,KAAK,CAAC,gBAAgB,EAAE,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC;QAD7D,qBAAgB,GAAhB,gBAAgB,CAAoD;IAEnG,CAAC;IAEkB,KAAK,CAAC,KAAc,EAAE,MAAkB;QACzD,OAAO,IAAI,CAAC,MAAM,CAChB,CAAC,EACD,qDAA2B,CAAC,QAAQ,EACpC;YACE,WAAW,EACT,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,KAAK,SAAS;gBACvD,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW;gBAC7C,CAAC,CAAC,MAAM;YACZ,QAAQ,EACN,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC/G,MAAM,EAAE,MAAM,CACZ,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAC/G;YACD,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC;SACvB,EACD,MAAM,CACP,CAAC;IACJ,CAAC;CACF;AAxBD,0CAwBC"}
@@ -0,0 +1,5 @@
1
+ import { MqttBatterySetOperationType } from '@ecoflow/accessories/batteries/interfaces/mqttApiBatteryContracts';
2
+ import { OutletServiceBase } from '@ecoflow/services/outletServiceBase';
3
+ export declare abstract class OutletBatteryServiceBase extends OutletServiceBase {
4
+ protected sendOn<TParams>(moduleType: number, operateType: MqttBatterySetOperationType, params: TParams, revert: () => void): Promise<void>;
5
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OutletBatteryServiceBase = void 0;
4
+ const outletServiceBase_1 = require("@ecoflow/services/outletServiceBase");
5
+ class OutletBatteryServiceBase extends outletServiceBase_1.OutletServiceBase {
6
+ sendOn(moduleType, operateType, params, revert) {
7
+ const message = {
8
+ id: 0,
9
+ version: '',
10
+ moduleType,
11
+ operateType,
12
+ params,
13
+ };
14
+ return this.ecoFlowAccessory.sendSetCommand(message, revert);
15
+ }
16
+ }
17
+ exports.OutletBatteryServiceBase = OutletBatteryServiceBase;
18
+ //# sourceMappingURL=outletBatteryServiceBase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outletBatteryServiceBase.js","sourceRoot":"","sources":["../../../../src/accessories/batteries/services/outletBatteryServiceBase.ts"],"names":[],"mappings":";;;AAIA,2EAAwE;AAExE,MAAsB,wBAAyB,SAAQ,qCAAiB;IAC5D,MAAM,CACd,UAAkB,EAClB,WAAwC,EACxC,MAAe,EACf,MAAkB;QAElB,MAAM,OAAO,GAA6C;YACxD,EAAE,EAAE,CAAC;YACL,OAAO,EAAE,EAAE;YACX,UAAU;YACV,WAAW;YACX,MAAM;SACP,CAAC;QAEF,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;CACF;AAjBD,4DAiBC"}
@@ -0,0 +1,6 @@
1
+ import { OutletBatteryServiceBase } from '@ecoflow/accessories/batteries/services/outletBatteryServiceBase';
2
+ import { EcoFlowAccessoryBase } from '@ecoflow/accessories/ecoFlowAccessoryBase';
3
+ export declare class OutletCarService extends OutletBatteryServiceBase {
4
+ constructor(ecoFlowAccessory: EcoFlowAccessoryBase);
5
+ protected setOn(value: boolean, revert: () => void): Promise<void>;
6
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OutletCarService = void 0;
4
+ const mqttApiBatteryContracts_1 = require("@ecoflow/accessories/batteries/interfaces/mqttApiBatteryContracts");
5
+ const outletBatteryServiceBase_1 = require("@ecoflow/accessories/batteries/services/outletBatteryServiceBase");
6
+ class OutletCarService extends outletBatteryServiceBase_1.OutletBatteryServiceBase {
7
+ constructor(ecoFlowAccessory) {
8
+ super(ecoFlowAccessory, 'CAR', ecoFlowAccessory.config.battery?.additionalCharacteristics);
9
+ }
10
+ setOn(value, revert) {
11
+ return this.sendOn(5, mqttApiBatteryContracts_1.MqttBatterySetOperationType.MpptCar, {
12
+ enabled: Number(value),
13
+ }, revert);
14
+ }
15
+ }
16
+ exports.OutletCarService = OutletCarService;
17
+ //# sourceMappingURL=outletCarService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outletCarService.js","sourceRoot":"","sources":["../../../../src/accessories/batteries/services/outletCarService.ts"],"names":[],"mappings":";;;AAAA,+GAG2E;AAC3E,+GAA4G;AAG5G,MAAa,gBAAiB,SAAQ,mDAAwB;IAC5D,YAAY,gBAAsC;QAChD,KAAK,CAAC,gBAAgB,EAAE,KAAK,EAAE,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC;IAC7F,CAAC;IAEkB,KAAK,CAAC,KAAc,EAAE,MAAkB;QACzD,OAAO,IAAI,CAAC,MAAM,CAChB,CAAC,EACD,qDAA2B,CAAC,OAAO,EACnC;YACE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC;SACvB,EACD,MAAM,CACP,CAAC;IACJ,CAAC;CACF;AAfD,4CAeC"}
@@ -0,0 +1,6 @@
1
+ import { OutletBatteryServiceBase } from '@ecoflow/accessories/batteries/services/outletBatteryServiceBase';
2
+ import { EcoFlowAccessoryBase } from '@ecoflow/accessories/ecoFlowAccessoryBase';
3
+ export declare class OutletUsbService extends OutletBatteryServiceBase {
4
+ constructor(ecoFlowAccessory: EcoFlowAccessoryBase);
5
+ protected setOn(value: boolean, revert: () => void): Promise<void>;
6
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OutletUsbService = void 0;
4
+ const mqttApiBatteryContracts_1 = require("@ecoflow/accessories/batteries/interfaces/mqttApiBatteryContracts");
5
+ const outletBatteryServiceBase_1 = require("@ecoflow/accessories/batteries/services/outletBatteryServiceBase");
6
+ class OutletUsbService extends outletBatteryServiceBase_1.OutletBatteryServiceBase {
7
+ constructor(ecoFlowAccessory) {
8
+ super(ecoFlowAccessory, 'USB', ecoFlowAccessory.config.battery?.additionalCharacteristics);
9
+ }
10
+ setOn(value, revert) {
11
+ return this.sendOn(1, mqttApiBatteryContracts_1.MqttBatterySetOperationType.DcOutCfg, { enabled: Number(value) }, revert);
12
+ }
13
+ }
14
+ exports.OutletUsbService = OutletUsbService;
15
+ //# sourceMappingURL=outletUsbService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outletUsbService.js","sourceRoot":"","sources":["../../../../src/accessories/batteries/services/outletUsbService.ts"],"names":[],"mappings":";;;AAAA,+GAG2E;AAC3E,+GAA4G;AAG5G,MAAa,gBAAiB,SAAQ,mDAAwB;IAC5D,YAAY,gBAAsC;QAChD,KAAK,CAAC,gBAAgB,EAAE,KAAK,EAAE,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC;IAC7F,CAAC;IAEkB,KAAK,CAAC,KAAc,EAAE,MAAkB;QACzD,OAAO,IAAI,CAAC,MAAM,CAChB,CAAC,EACD,qDAA2B,CAAC,QAAQ,EACpC,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,EAC1B,MAAM,CACP,CAAC;IACJ,CAAC;CACF;AAbD,4CAaC"}
@@ -0,0 +1,6 @@
1
+ import { MqttBatterySetMessage } from '@ecoflow/accessories/batteries/interfaces/mqttApiBatteryContracts';
2
+ import { SimulatorTyped } from '@ecoflow/apis/simulations/simulator';
3
+ export declare class BatterySimulator extends SimulatorTyped<MqttBatterySetMessage> {
4
+ generateQuota(): object;
5
+ generateSetReplyTyped(message: MqttBatterySetMessage): object;
6
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BatterySimulator = void 0;
4
+ const mqttApiBatteryContracts_1 = require("@ecoflow/accessories/batteries/interfaces/mqttApiBatteryContracts");
5
+ const simulator_1 = require("@ecoflow/apis/simulations/simulator");
6
+ class BatterySimulator extends simulator_1.SimulatorTyped {
7
+ generateQuota() {
8
+ const quotaType = this.getRandomNumber(0, 100);
9
+ if (quotaType >= 0 && quotaType < 33) {
10
+ const quotaBmsStatus = {
11
+ typeCode: mqttApiBatteryContracts_1.MqttBatteryMessageType.EMS,
12
+ params: {
13
+ f32LcdShowSoc: this.getRandomNumber(0, 100),
14
+ },
15
+ };
16
+ return quotaBmsStatus;
17
+ }
18
+ else if (quotaType >= 33 && quotaType < 66) {
19
+ const quotaInvStatus = {
20
+ typeCode: mqttApiBatteryContracts_1.MqttBatteryMessageType.INV,
21
+ params: {
22
+ cfgAcEnabled: this.getRandomBoolean(),
23
+ cfgAcOutFreq: 50,
24
+ cfgAcOutVol: 220000,
25
+ cfgAcXboost: this.getRandomBoolean(),
26
+ inputWatts: this.getRandomNumber(0, 1000),
27
+ outputWatts: this.getRandomNumber(0, 1000),
28
+ },
29
+ };
30
+ return quotaInvStatus;
31
+ }
32
+ else {
33
+ const quotaPdStatus = {
34
+ typeCode: mqttApiBatteryContracts_1.MqttBatteryMessageType.PD,
35
+ params: {
36
+ carState: this.getRandomBoolean(),
37
+ carWatts: this.getRandomNumber(0, 1000),
38
+ dcOutState: this.getRandomBoolean(),
39
+ typec1Watts: this.getRandomNumber(0, 100),
40
+ typec2Watts: this.getRandomNumber(0, 100),
41
+ },
42
+ };
43
+ return quotaPdStatus;
44
+ }
45
+ }
46
+ generateSetReplyTyped(message) {
47
+ const reply = {
48
+ id: message.id,
49
+ version: message.version,
50
+ moduleType: message.moduleType,
51
+ operateType: message.operateType,
52
+ data: {
53
+ ack: false,
54
+ },
55
+ };
56
+ return reply;
57
+ }
58
+ }
59
+ exports.BatterySimulator = BatterySimulator;
60
+ //# sourceMappingURL=batterySimulator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batterySimulator.js","sourceRoot":"","sources":["../../../../src/accessories/batteries/simulations/batterySimulator.ts"],"names":[],"mappings":";;;AACA,+GAK2E;AAC3E,mEAAqE;AAErE,MAAa,gBAAiB,SAAQ,0BAAqC;IACzD,aAAa;QAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC/C,IAAI,SAAS,IAAI,CAAC,IAAI,SAAS,GAAG,EAAE,EAAE,CAAC;YACrC,MAAM,cAAc,GAAiD;gBACnE,QAAQ,EAAE,gDAAsB,CAAC,GAAG;gBACpC,MAAM,EAAE;oBACN,aAAa,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,GAAG,CAAC;iBAC5C;aACF,CAAC;YACF,OAAO,cAAc,CAAC;QACxB,CAAC;aAAM,IAAI,SAAS,IAAI,EAAE,IAA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 @@
1
+ import { DeviceInfo } from '@ecoflow/apis/containers/deviceInfo';
2
+ import { EcoFlowHttpApiManager } from '@ecoflow/apis/ecoFlowHttpApiManager';
3
+ import { EcoFlowMqttApiManager } from '@ecoflow/apis/ecoFlowMqttApiManager';
4
+ import { MqttQuotaMessage, MqttSetMessage, MqttSetReplyMessage } from '@ecoflow/apis/interfaces/mqttApiContracts';
5
+ import { DeviceConfig } from '@ecoflow/config';
6
+ import { EcoFlowHomebridgePlatform } from '@ecoflow/platform';
7
+ import { ServiceBase } from '@ecoflow/services/serviceBase';
8
+ import { Logging, PlatformAccessory } from 'homebridge';
9
+ import { Subscription } from 'rxjs';
10
+ export declare abstract class EcoFlowAccessoryBase {
11
+ readonly platform: EcoFlowHomebridgePlatform;
12
+ readonly accessory: PlatformAccessory;
13
+ readonly config: DeviceConfig;
14
+ readonly log: Logging;
15
+ protected readonly httpApiManager: EcoFlowHttpApiManager;
16
+ protected readonly mqttApiManager: EcoFlowMqttApiManager;
17
+ private _services;
18
+ private reconnectMqttTimeoutId;
19
+ private isMqttConnected;
20
+ private subscriptions;
21
+ protected readonly deviceInfo: DeviceInfo;
22
+ readonly setReplies: Record<string, {
23
+ requestMessage: MqttSetMessage;
24
+ revert: () => void;
25
+ }>;
26
+ constructor(platform: EcoFlowHomebridgePlatform, accessory: PlatformAccessory, config: DeviceConfig, log: Logging, httpApiManager: EcoFlowHttpApiManager, mqttApiManager: EcoFlowMqttApiManager);
27
+ get services(): ServiceBase[];
28
+ initialize(): Promise<void>;
29
+ abstract initializeDefaultValues(): Promise<void>;
30
+ cleanupServices(): void;
31
+ destroy(): void;
32
+ sendSetCommand(message: MqttSetMessage, revert: () => void): Promise<void>;
33
+ protected abstract getServices(): ServiceBase[];
34
+ protected subscribeOnParameterUpdates(): Subscription[];
35
+ protected abstract processQuotaMessage(message: MqttQuotaMessage): void;
36
+ protected processSetReplyMessage(message: MqttSetReplyMessage): void;
37
+ private getMqttSetMessageKey;
38
+ private initializeServices;
39
+ private connectMqtt;
40
+ private initMqtt;
41
+ }
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EcoFlowAccessoryBase = void 0;
4
+ const deviceInfo_1 = require("@ecoflow/apis/containers/deviceInfo");
5
+ const accessoryInformationService_1 = require("@ecoflow/services/accessoryInformationService");
6
+ class EcoFlowAccessoryBase {
7
+ platform;
8
+ accessory;
9
+ config;
10
+ log;
11
+ httpApiManager;
12
+ mqttApiManager;
13
+ _services = [];
14
+ reconnectMqttTimeoutId = null;
15
+ isMqttConnected = false;
16
+ subscriptions = [];
17
+ deviceInfo;
18
+ setReplies = {};
19
+ constructor(platform, accessory, config, log, httpApiManager, mqttApiManager) {
20
+ this.platform = platform;
21
+ this.accessory = accessory;
22
+ this.config = config;
23
+ this.log = log;
24
+ this.httpApiManager = httpApiManager;
25
+ this.mqttApiManager = mqttApiManager;
26
+ this.deviceInfo = new deviceInfo_1.DeviceInfo(config, log);
27
+ }
28
+ // Getter for services
29
+ get services() {
30
+ return this._services;
31
+ }
32
+ async initialize() {
33
+ this._services = this.getServices();
34
+ this._services.push(new accessoryInformationService_1.AccessoryInformationService(this));
35
+ this.initializeServices();
36
+ await this.connectMqtt();
37
+ }
38
+ cleanupServices() {
39
+ const services = this.services.map(service => service.service);
40
+ this.accessory.services
41
+ .filter(service => !services.includes(service))
42
+ .forEach(service => {
43
+ this.log.warn('Removing obsolete service from accessory:', service.displayName === undefined || service.displayName === '' ? service.name : service.displayName);
44
+ this.accessory.removeService(service);
45
+ });
46
+ this.services
47
+ .filter(service => this.accessory.services.includes(service.service))
48
+ .forEach(service => service.cleanupCharacteristics());
49
+ }
50
+ destroy() {
51
+ if (this.reconnectMqttTimeoutId !== null) {
52
+ clearTimeout(this.reconnectMqttTimeoutId);
53
+ this.reconnectMqttTimeoutId = null;
54
+ }
55
+ this.subscriptions.forEach(subscription => subscription.unsubscribe());
56
+ }
57
+ async sendSetCommand(message, revert) {
58
+ message.id = Math.floor(Math.random() * 1000000);
59
+ message.version = '1.0';
60
+ this.setReplies[this.getMqttSetMessageKey(message)] = { requestMessage: message, revert };
61
+ await this.mqttApiManager.sendSetCommand(this.deviceInfo, message);
62
+ }
63
+ subscribeOnParameterUpdates() {
64
+ const subscriptions = [
65
+ this.mqttApiManager.subscribeOnQuotaMessage(this.deviceInfo, this.processQuotaMessage.bind(this)),
66
+ this.mqttApiManager.subscribeOnSetReplyMessage(this.deviceInfo, this.processSetReplyMessage.bind(this)),
67
+ ];
68
+ return subscriptions.filter(subscription => !!subscription);
69
+ }
70
+ processSetReplyMessage(message) {
71
+ const messageKey = this.getMqttSetMessageKey(message);
72
+ const command = this.setReplies[messageKey];
73
+ if (!command) {
74
+ this.log.debug('Received "SetReply" response was not sent by accessory. Ignore it:', message);
75
+ return;
76
+ }
77
+ this.log.debug('Received "SetReply" response:', message);
78
+ delete this.setReplies[messageKey];
79
+ if (message.data.ack) {
80
+ this.log.warn('Failed to set a value. Reverts value back for:', command.requestMessage.id);
81
+ command.revert();
82
+ }
83
+ else {
84
+ this.log.debug('Setting of a value was successful for:', command.requestMessage.id);
85
+ }
86
+ }
87
+ getMqttSetMessageKey(message) {
88
+ return message.id.toString();
89
+ }
90
+ initializeServices() {
91
+ this.services.forEach(service => {
92
+ service.initialize();
93
+ });
94
+ }
95
+ async connectMqtt() {
96
+ await this.initMqtt();
97
+ this.reconnectMqttTimeoutId = setInterval(async () => {
98
+ // Check MQTT is connected every minute
99
+ if (!this.isMqttConnected) {
100
+ await this.initMqtt();
101
+ }
102
+ }, this.config.reconnectMqttTimeoutMs ?? 60000);
103
+ }
104
+ async initMqtt() {
105
+ this.isMqttConnected =
106
+ (await this.mqttApiManager.subscribeOnQuotaTopic(this.deviceInfo)) &&
107
+ (await this.mqttApiManager.subscribeOnSetReplyTopic(this.deviceInfo));
108
+ if (this.isMqttConnected) {
109
+ this.subscriptions = this.subscribeOnParameterUpdates();
110
+ }
111
+ }
112
+ }
113
+ exports.EcoFlowAccessoryBase = EcoFlowAccessoryBase;
114
+ //# sourceMappingURL=ecoFlowAccessoryBase.js.map
@@ -0,0 +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,EAAE,GAAG,CAAC,CAAC;IAChD,CAAC;IAED,sBAAsB;IACtB,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACpC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,yDAA2B,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3D,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC;IAIM,eAAe;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,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oryBase';
2
+ import { EcoFlowHttpApiManager } from '@ecoflow/apis/ecoFlowHttpApiManager';
3
+ import { EcoFlowMqttApiManager } from '@ecoflow/apis/ecoFlowMqttApiManager';
4
+ import { DeviceConfig } from '@ecoflow/config';
5
+ import { EcoFlowHomebridgePlatform } from '@ecoflow/platform';
6
+ import { Logging, PlatformAccessory } from 'homebridge';
7
+ export declare abstract class EcoFlowAccessoryWithQuotaBase<TAllQuotaData> extends EcoFlowAccessoryBase {
8
+ private _quota;
9
+ constructor(platform: EcoFlowHomebridgePlatform, accessory: PlatformAccessory, config: DeviceConfig, log: Logging, httpApiManager: EcoFlowHttpApiManager, mqttApiManager: EcoFlowMqttApiManager);
10
+ initializeDefaultValues(shouldUpdateInitialValues?: boolean): Promise<void>;
11
+ get quota(): TAllQuotaData;
12
+ protected abstract updateInitialValues(quota: TAllQuotaData): void;
13
+ protected abstract initializeQuota(quota: TAllQuotaData | null): TAllQuotaData;
14
+ protected sum(...values: (number | undefined)[]): number;
15
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EcoFlowAccessoryWithQuotaBase = void 0;
4
+ const ecoFlowAccessoryBase_1 = require("@ecoflow/accessories/ecoFlowAccessoryBase");
5
+ class EcoFlowAccessoryWithQuotaBase extends ecoFlowAccessoryBase_1.EcoFlowAccessoryBase {
6
+ _quota = null;
7
+ constructor(platform, accessory, config, log, httpApiManager, mqttApiManager) {
8
+ super(platform, accessory, config, log, httpApiManager, mqttApiManager);
9
+ }
10
+ async initializeDefaultValues(shouldUpdateInitialValues = true) {
11
+ if (!this._quota) {
12
+ this._quota = await this.httpApiManager.getAllQuotas(this.deviceInfo);
13
+ }
14
+ const quotaReceived = !!this._quota;
15
+ this._quota = this.initializeQuota(this._quota);
16
+ if (!quotaReceived) {
17
+ this.log.warn('Quotas were not received');
18
+ }
19
+ if (quotaReceived && shouldUpdateInitialValues) {
20
+ this.updateInitialValues(this.quota);
21
+ }
22
+ }
23
+ get quota() {
24
+ if (!this._quota) {
25
+ this._quota = this.initializeQuota(this._quota);
26
+ }
27
+ return this._quota;
28
+ }
29
+ sum(...values) {
30
+ return values.filter(value => value !== undefined).reduce((sum, value) => sum + value, 0);
31
+ }
32
+ }
33
+ exports.EcoFlowAccessoryWithQuotaBase = EcoFlowAccessoryWithQuotaBase;
34
+ //# sourceMappingURL=ecoFlowAccessoryWithQuotaBase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecoFlowAccessoryWithQuotaBase.js","sourceRoot":"","sources":["../../src/accessories/ecoFlowAccessoryWithQuotaBase.ts"],"names":[],"mappings":";;;AAAA,oFAAiF;AAOjF,MAAsB,6BAA6C,SAAQ,2CAAoB;IACrF,MAAM,GAAyB,IAAI,CAAC;IAE5C,YACE,QAAmC,EACnC,SAA4B,EAC5B,MAAoB,EACpB,GAAY,EACZ,cAAqC,EACrC,cAAqC;QAErC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;IAC1E,CAAC;IAEe,KAAK,CAAC,uBAAuB,CAAC,4BAAqC,IAAI;QACrF,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,CAAgB,IAAI,CAAC,UAAU,CAAC,CAAC;QACvF,CAAC;QACD,MAAM,aAAa,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChD,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI,aAAa,IAAI,yBAAyB,EAAE,CAAC;YAC/C,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,IAAW,KAAK;QACd,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClD,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAMS,GAAG,CAAC,GAAG,MAA8B;QAC7C,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC;IAC5F,CAAC;CACF;AA1CD,sEA0CC"}
@@ -0,0 +1,16 @@
1
+ export interface Heartbeat {
2
+ pv1InputWatts?: number;
3
+ pv2InputWatts?: number;
4
+ batInputWatts?: number;
5
+ batSoc?: number;
6
+ invOutputWatts?: number;
7
+ invOnOff?: boolean;
8
+ invBrightness?: number;
9
+ supplyPriority?: number;
10
+ permanentWatts?: number;
11
+ upperLimit?: number;
12
+ lowerLimit?: number;
13
+ }
14
+ export interface PowerStreamAllQuotaData {
15
+ '20_1': Heartbeat;
16
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=httpApiPowerStreamContracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpApiPowerStreamContracts.js","sourceRoot":"","sources":["../../../../src/accessories/powerstream/interfaces/httpApiPowerStreamContracts.ts"],"names":[],"mappings":""}
@@ -0,0 +1,41 @@
1
+ import { MqttQuotaMessage, MqttQuotaMessageWithParam, MqttSetMessage, MqttSetMessageWithParams } from '@ecoflow/apis/interfaces/mqttApiContracts';
2
+ export declare enum MqttPowerStreamMessageType {
3
+ Heartbeat = 1,
4
+ Task = 134
5
+ }
6
+ export declare enum MqttPowerStreamMessageFuncType {
7
+ Func20 = 20
8
+ }
9
+ export interface MqttPowerStreamQuotaMessage extends MqttQuotaMessage {
10
+ cmdId: MqttPowerStreamMessageType;
11
+ cmdFunc: MqttPowerStreamMessageFuncType;
12
+ }
13
+ export interface MqttPowerStreamQuotaMessageWithParams<TParams> extends MqttQuotaMessageWithParam<TParams>, MqttPowerStreamQuotaMessage {
14
+ }
15
+ export declare enum MqttPowerStreamSetCmdCodeType {
16
+ WN511_SET_SUPPLY_PRIORITY_PACK = "WN511_SET_SUPPLY_PRIORITY_PACK",
17
+ WN511_SET_PERMANENT_WATTS_PACK = "WN511_SET_PERMANENT_WATTS_PACK",
18
+ WN511_SET_BAT_LOWER_PACK = "WN511_SET_BAT_LOWER_PACK",
19
+ WN511_SET_BAT_UPPER_PACK = "WN511_SET_BAT_UPPER_PACK",
20
+ WN511_SET_BRIGHTNESS_PACK = "WN511_SET_BRIGHTNESS_PACK"
21
+ }
22
+ export interface MqttPowerStreamSetMessage extends MqttSetMessage {
23
+ cmdCode: MqttPowerStreamSetCmdCodeType;
24
+ }
25
+ export interface MqttPowerStreamSetMessageWithParams<TParams> extends MqttSetMessageWithParams<TParams>, MqttPowerStreamSetMessage {
26
+ }
27
+ export interface MqttPowerStreamSetSupplyPriorityMessageParams {
28
+ supplyPriority: boolean;
29
+ }
30
+ export interface MqttPowerStreamSetPermanentWattsMessageParams {
31
+ permanentWatts: number;
32
+ }
33
+ export interface MqttPowerStreamSetLowerLimitMessageParams {
34
+ lowerLimit: number;
35
+ }
36
+ export interface MqttPowerStreamSetUpperLimitMessageParams {
37
+ upperLimit: number;
38
+ }
39
+ export interface MqttPowerStreamSetBrightnessMessageParams {
40
+ brightness: number;
41
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MqttPowerStreamSetCmdCodeType = exports.MqttPowerStreamMessageFuncType = exports.MqttPowerStreamMessageType = void 0;
4
+ var MqttPowerStreamMessageType;
5
+ (function (MqttPowerStreamMessageType) {
6
+ MqttPowerStreamMessageType[MqttPowerStreamMessageType["Heartbeat"] = 1] = "Heartbeat";
7
+ MqttPowerStreamMessageType[MqttPowerStreamMessageType["Task"] = 134] = "Task";
8
+ })(MqttPowerStreamMessageType || (exports.MqttPowerStreamMessageType = MqttPowerStreamMessageType = {}));
9
+ var MqttPowerStreamMessageFuncType;
10
+ (function (MqttPowerStreamMessageFuncType) {
11
+ MqttPowerStreamMessageFuncType[MqttPowerStreamMessageFuncType["Func20"] = 20] = "Func20";
12
+ })(MqttPowerStreamMessageFuncType || (exports.MqttPowerStreamMessageFuncType = MqttPowerStreamMessageFuncType = {}));
13
+ var MqttPowerStreamSetCmdCodeType;
14
+ (function (MqttPowerStreamSetCmdCodeType) {
15
+ MqttPowerStreamSetCmdCodeType["WN511_SET_SUPPLY_PRIORITY_PACK"] = "WN511_SET_SUPPLY_PRIORITY_PACK";
16
+ MqttPowerStreamSetCmdCodeType["WN511_SET_PERMANENT_WATTS_PACK"] = "WN511_SET_PERMANENT_WATTS_PACK";
17
+ MqttPowerStreamSetCmdCodeType["WN511_SET_BAT_LOWER_PACK"] = "WN511_SET_BAT_LOWER_PACK";
18
+ MqttPowerStreamSetCmdCodeType["WN511_SET_BAT_UPPER_PACK"] = "WN511_SET_BAT_UPPER_PACK";
19
+ MqttPowerStreamSetCmdCodeType["WN511_SET_BRIGHTNESS_PACK"] = "WN511_SET_BRIGHTNESS_PACK";
20
+ })(MqttPowerStreamSetCmdCodeType || (exports.MqttPowerStreamSetCmdCodeType = MqttPowerStreamSetCmdCodeType = {}));
21
+ //# sourceMappingURL=mqttApiPowerStreamContracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mqttApiPowerStreamContracts.js","sourceRoot":"","sources":["../../../../src/accessories/powerstream/interfaces/mqttApiPowerStreamContracts.ts"],"names":[],"mappings":";;;AAOA,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,qFAAa,CAAA;IACb,6EAAU,CAAA;AACZ,CAAC,EAHW,0BAA0B,0CAA1B,0BAA0B,QAGrC;AAED,IAAY,8BAEX;AAFD,WAAY,8BAA8B;IACxC,wFAAW,CAAA;AACb,CAAC,EAFW,8BAA8B,8CAA9B,8BAA8B,QAEzC;AAWD,IAAY,6BAMX;AAND,WAAY,6BAA6B;IACvC,kGAAiE,CAAA;IACjE,kGAAiE,CAAA;IACjE,sFAAqD,CAAA;IACrD,sFAAqD,CAAA;IACrD,wFAAuD,CAAA;AACzD,CAAC,EANW,6BAA6B,6CAA7B,6BAA6B,QAMxC"}
@@ -0,0 +1,26 @@
1
+ import { EcoFlowAccessoryWithQuotaBase } from '@ecoflow/accessories/ecoFlowAccessoryWithQuotaBase';
2
+ import { PowerStreamAllQuotaData } from '@ecoflow/accessories/powerstream/interfaces/httpApiPowerStreamContracts';
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 { EcoFlowHomebridgePlatform } from '@ecoflow/platform';
8
+ import { ServiceBase } from '@ecoflow/services/serviceBase';
9
+ import { Logging, PlatformAccessory } from 'homebridge';
10
+ export declare class PowerStreamAccessory extends EcoFlowAccessoryWithQuotaBase<PowerStreamAllQuotaData> {
11
+ private readonly inverterOutletService;
12
+ private readonly solarOutletService;
13
+ private readonly batteryOutletService;
14
+ private readonly inverterBrightnessService;
15
+ private readonly inverterPowerDemandService;
16
+ constructor(platform: EcoFlowHomebridgePlatform, accessory: PlatformAccessory, config: DeviceConfig, log: Logging, httpApiManager: EcoFlowHttpApiManager, mqttApiManager: EcoFlowMqttApiManager);
17
+ protected getServices(): ServiceBase[];
18
+ protected processQuotaMessage(message: MqttQuotaMessage): void;
19
+ protected initializeQuota(quota: PowerStreamAllQuotaData | null): PowerStreamAllQuotaData;
20
+ protected updateInitialValues(initialData: PowerStreamAllQuotaData): void;
21
+ private updateHeartbeatInitialValues;
22
+ private updateHeartbeatValues;
23
+ private updateSolarValues;
24
+ private updateBatteryValues;
25
+ private updateInverterValues;
26
+ }