@pietrolubini/homebridge-ecoflow 1.6.0 → 1.7.0-alpha.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 +42 -0
- package/config.schema.json +1 -1
- package/dist/accessories/discovery/discoveryAccessory.d.ts +10 -0
- package/dist/accessories/discovery/discoveryAccessory.js +21 -0
- package/dist/accessories/discovery/discoveryAccessory.js.map +1 -0
- package/dist/accessories/discovery/discoveryAccessory.spec.d.ts +1 -0
- package/dist/accessories/discovery/interfaces/discoveryHttpApiContracts.d.ts +2 -0
- package/dist/accessories/discovery/interfaces/discoveryHttpApiContracts.js +3 -0
- package/dist/accessories/discovery/interfaces/discoveryHttpApiContracts.js.map +1 -0
- package/dist/accessories/discovery/simulations/discoverySimulator.d.ts +5 -0
- package/dist/accessories/discovery/simulations/discoverySimulator.js +17 -0
- package/dist/accessories/discovery/simulations/discoverySimulator.js.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/homebridge-ui/public/index.html +1 -1
- package/dist/homebridge-ui/public/index.js +1 -1
- package/dist/platform.js +6 -0
- package/dist/platform.js.map +1 -1
- package/junit.xml +716 -704
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@ The goal is to add HomeKit support to EcoFlow devices and make them fully contro
|
|
|
34
34
|
- [Delta Pro](#delta-pro)
|
|
35
35
|
- [Delta Pro 3](#delta-pro-3)
|
|
36
36
|
- [Delta Pro Ultra](#delta-pro-ultra)
|
|
37
|
+
- [Discovery](#discovery)
|
|
37
38
|
- [Glacier](#glacier)
|
|
38
39
|
- [PowerOcean](#powerocean)
|
|
39
40
|
- [PowerStream Micro-inverter](#powerstream-micro-inverter)
|
|
@@ -360,6 +361,45 @@ The following additional characteristics is available:
|
|
|
360
361
|
}
|
|
361
362
|
```
|
|
362
363
|
|
|
364
|
+
### Discovery
|
|
365
|
+
|
|
366
|
+
Type of device that helps to discover whether support for device that is not listed in [Ecoflow IoT Developer Platform](https://developer-eu.ecoflow.com/us/document/introduction) documentation could be added or not.
|
|
367
|
+
|
|
368
|
+
#### Steps
|
|
369
|
+
|
|
370
|
+
- Configure new device in UI with parameters:
|
|
371
|
+
```json
|
|
372
|
+
{
|
|
373
|
+
"name": "Test",
|
|
374
|
+
"model": "Discovery",
|
|
375
|
+
"serialNumber": "serial number of your device to be discovered",
|
|
376
|
+
"accessKey": "your access key",
|
|
377
|
+
"secretKey": "your secret key"
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
- Save configuration and restart homebridge / child bridge
|
|
381
|
+
- Note current time and change parameter inside EcoFlow App
|
|
382
|
+
- Repeat previous step for all parameters which support is expected to be added to the plugin
|
|
383
|
+
- Attach homebridge log and description of "time - performed action in EcoFlow App" to an issue in GitHub
|
|
384
|
+
|
|
385
|
+
#### Services
|
|
386
|
+
|
|
387
|
+
No services
|
|
388
|
+
|
|
389
|
+
#### Configuration
|
|
390
|
+
|
|
391
|
+
```json
|
|
392
|
+
{
|
|
393
|
+
...
|
|
394
|
+
"devices": [
|
|
395
|
+
{
|
|
396
|
+
...
|
|
397
|
+
"model": "Discovery"
|
|
398
|
+
}
|
|
399
|
+
],
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
|
|
363
403
|
### Glacier
|
|
364
404
|
|
|
365
405
|
> Not Activated (no testing is performed)
|
|
@@ -422,6 +462,8 @@ The following additional characteristics is available:
|
|
|
422
462
|
|
|
423
463
|
### PowerOcean
|
|
424
464
|
|
|
465
|
+
> Not Activated (no testing is performed)
|
|
466
|
+
|
|
425
467
|
#### Services
|
|
426
468
|
|
|
427
469
|
| EcoFlow Parameter | Service | Characteristic | Standard | Permission |
|
package/config.schema.json
CHANGED
|
@@ -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"]
|
|
35
|
+
"enum": ["Delta 2", "Delta 2 Max", "Delta Pro 3", "Discovery", "PowerStream", "Smart Plug"]
|
|
36
36
|
},
|
|
37
37
|
"serialNumber": {
|
|
38
38
|
"title": "Serial Number",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DiscoveryAllQuotaData } from '@ecoflow/accessories/discovery/interfaces/discoveryHttpApiContracts';
|
|
2
|
+
import { EcoFlowAccessoryWithQuotaBase } from '@ecoflow/accessories/ecoFlowAccessoryWithQuotaBase';
|
|
3
|
+
import { MqttQuotaMessage } from '@ecoflow/apis/interfaces/mqttApiContracts';
|
|
4
|
+
import { ServiceBase } from '@ecoflow/services/serviceBase';
|
|
5
|
+
export declare class DiscoveryAccessory extends EcoFlowAccessoryWithQuotaBase<DiscoveryAllQuotaData> {
|
|
6
|
+
protected getServices(): ServiceBase[];
|
|
7
|
+
protected processQuotaMessage(message: MqttQuotaMessage): void;
|
|
8
|
+
protected initializeQuota(quota: DiscoveryAllQuotaData | null): DiscoveryAllQuotaData;
|
|
9
|
+
protected updateInitialValues(initialData: DiscoveryAllQuotaData): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiscoveryAccessory = void 0;
|
|
4
|
+
const ecoFlowAccessoryWithQuotaBase_1 = require("@ecoflow/accessories/ecoFlowAccessoryWithQuotaBase");
|
|
5
|
+
class DiscoveryAccessory extends ecoFlowAccessoryWithQuotaBase_1.EcoFlowAccessoryWithQuotaBase {
|
|
6
|
+
getServices() {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
processQuotaMessage(message) {
|
|
10
|
+
this.log.info(`Received quota: ${JSON.stringify(message, null, 2)}`);
|
|
11
|
+
}
|
|
12
|
+
initializeQuota(quota) {
|
|
13
|
+
const result = quota ?? {};
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
updateInitialValues(initialData) {
|
|
17
|
+
this.log.info(`Received quota (initial): ${JSON.stringify(initialData, null, 2)}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.DiscoveryAccessory = DiscoveryAccessory;
|
|
21
|
+
//# sourceMappingURL=discoveryAccessory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discoveryAccessory.js","sourceRoot":"","sources":["../../../src/accessories/discovery/discoveryAccessory.ts"],"names":[],"mappings":";;;AACA,sGAAmG;AAInG,MAAa,kBAAmB,SAAQ,6DAAoD;IACvE,WAAW;QAC5B,OAAO,EAAE,CAAC;IACZ,CAAC;IAEkB,mBAAmB,CAAC,OAAyB;QAC9D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;IAEkB,eAAe,CAAC,KAAmC;QACpE,MAAM,MAAM,GAAG,KAAK,IAAK,EAA4B,CAAC;QACtD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEkB,mBAAmB,CAAC,WAAkC;QACvE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,6BAA6B,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACrF,CAAC;CACF;AAjBD,gDAiBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discoveryHttpApiContracts.js","sourceRoot":"","sources":["../../../../src/accessories/discovery/interfaces/discoveryHttpApiContracts.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiscoverySimulator = void 0;
|
|
4
|
+
const simulator_1 = require("@ecoflow/apis/simulations/simulator");
|
|
5
|
+
class DiscoverySimulator extends simulator_1.Simulator {
|
|
6
|
+
generateQuota() {
|
|
7
|
+
return {
|
|
8
|
+
discover: true,
|
|
9
|
+
simulated: true,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
generateSetReply(message) {
|
|
13
|
+
throw new Error(`SetReply command "${message}" is not supported for Discovery`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.DiscoverySimulator = DiscoverySimulator;
|
|
17
|
+
//# sourceMappingURL=discoverySimulator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discoverySimulator.js","sourceRoot":"","sources":["../../../../src/accessories/discovery/simulations/discoverySimulator.ts"],"names":[],"mappings":";;;AACA,mEAAgE;AAEhE,MAAa,kBAAmB,SAAQ,qBAAS;IAC/B,aAAa;QAC3B,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,IAAI;SACS,CAAC;IAC7B,CAAC;IAEe,gBAAgB,CAAC,OAAe;QAC9C,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,kCAAkC,CAAC,CAAC;IAClF,CAAC;CACF;AAXD,gDAWC"}
|
package/dist/config.d.ts
CHANGED
package/dist/config.js
CHANGED
|
@@ -8,6 +8,7 @@ var DeviceModel;
|
|
|
8
8
|
// DeltaPro = 'Delta Pro',
|
|
9
9
|
DeviceModel["DeltaPro3"] = "Delta Pro 3";
|
|
10
10
|
// DeltaProUltra = 'Delta Pro Ultra',
|
|
11
|
+
DeviceModel["Discovery"] = "Discovery";
|
|
11
12
|
DeviceModel["PowerStream"] = "PowerStream";
|
|
12
13
|
// PowerOcean = 'PowerOcean',
|
|
13
14
|
DeviceModel["SmartPlug"] = "Smart Plug";
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAOA,IAAY,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAOA,IAAY,WAWX;AAXD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,iCAAkB,CAAA;IAClB,0BAA0B;IAC1B,wCAAyB,CAAA;IACzB,qCAAqC;IACrC,sCAAuB,CAAA;IACvB,0CAA2B,CAAA;IAC3B,6BAA6B;IAC7B,uCAAwB,CAAA;IACxB,uBAAuB;AACzB,CAAC,EAXW,WAAW,2BAAX,WAAW,QAWtB;AAED,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,yBAAS,CAAA;IACT,yBAAS,CAAA;AACX,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAsCD,IAAY,yCAKX;AALD,WAAY,yCAAyC;IACnD,8EAAiC,CAAA;IACjC,6FAAgD,CAAA;IAChD,6EAAgC,CAAA;IAChC,oFAAuC,CAAA;AACzC,CAAC,EALW,yCAAyC,yDAAzC,yCAAyC,QAKpD;AAED,IAAY,kCAIX;AAJD,WAAY,kCAAkC;IAC5C,yEAAmC,CAAA;IACnC,yEAAmC,CAAA;IACnC,wFAAkD,CAAA;AACpD,CAAC,EAJW,kCAAkC,kDAAlC,kCAAkC,QAI7C;AAED,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,6EAAU,CAAA;IACV,6EAAU,CAAA;AACZ,CAAC,EAHW,0BAA0B,0CAA1B,0BAA0B,QAGrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var e={999:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ComponentRenderer=void 0,r.ComponentRenderer=class{renderTextBox(e,r,i,n,t){const o='\n <div class="form-group">\n <label for="device{id}" class="{requiredClass}">{title}</label>\n <input type="text" class="form-control" id="device{id}" placeholder="{description}" required="{required}" />\n </div>'.replace(/{id}/g,r).replace(/{title}/g,i.title).replace(/{description}/g,i.description??"").replace(/{requiredClass}/g,i.required?"required-label":"").replace(/{required}/g,(i.required??!1).toString());e.append(o);const a=e.find(`#device${r}`);a.val(n),a.on("change",(()=>t(a.val()?.toString()||"")))}renderDropDown(e,r,i,n,t){const o='\n <div class="form-group">\n <label for="device{id}" class="{requiredClass}">{title}</label>\n <select class="form-control" id="device{id}" required="{required}"></select>\n </div>'.replace(/{id}/g,r).replace(/{title}/g,i.title).replace(/{requiredClass}/g,i.required?"required-label":"").replace(/{required}/g,(i.required??!1).toString());e.append(o);const a=e.find(`#device${r}`);i.enum.forEach((e=>{const r=$("<option>").val(e).text(e);a.append(r)})),a.val(n),a.on("change",(()=>t(a.val()?.toString()||"")))}}},84:(e,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PluginConfigDevicesRenderer=void 0;const n=i(536);class t extends n.PluginConfigRendererBase{form;$tabs;$tabPanels;_hideDeviceSettingsPerModel;constructor(e){super(e),this.$tabs=$("#devicesTabs"),this.$tabPanels=$("#devicesPanels"),this._hideDeviceSettingsPerModel={"Delta 2":["powerStream","powerOcean","outlet"],"Delta 2 Max":["powerStream","powerOcean","outlet"],"Delta Pro":["powerStream","powerOcean","outlet"],"Delta Pro 3":["powerStream","powerOcean","outlet"],"Delta Pro Ultra":["powerStream","powerOcean","outlet"],PowerStream:["battery","powerOcean","outlet"],PowerOcean:["battery","powerStream","outlet"],"Smart Plug":["battery","powerStream","powerOcean"],Glacier:["powerStream","powerOcean","outlet"]}}get hideDeviceSettingsPerModel(){return this._hideDeviceSettingsPerModel}render(e){this.renderDevicesSettings({homebridgeProvider:e.homebridgeProvider,configSchema:e.configSchema,configuration:e.configuration,hideDeviceSettingsPerModel:this.hideDeviceSettingsPerModel})}renderDevicesSettings(e,r){$("#devicesLabel").text(e.configSchema.schema.properties.devices.title);const i=!r||r<0?0:r;this.renderDeviceTabs(e,i)}renderDeviceTabs(e,r){this.clearDeviceTabs();const i='\n <li class="nav-item">\n <a class="nav-link {activeClass}" data-toggle="tab" href="#deviceTabPanel{index}" id="deviceTab{index}">{name}</a>\n </li>\n ';e.configuration.devices.forEach(((n,t)=>{const o=i.replace(/{activeClass}/g,t===r?"active":"").replace(/{index}/g,t.toString()).replace(/{name}/g,n.name??`Device${t+1}`);this.$tabs.append(o),this.renderDeviceTabPanel(e,n,t,r,this.$tabs.find(`#deviceTab${t}`))})),this.renderAddNewDeviceTab(i,e)}clearDeviceTabs(){this.$tabs.empty(),this.$tabPanels.empty(),this.form?.end()}renderAddNewDeviceTab(e,r){const i=e.replace(/{activeClass}/g,"").replace(/{index}/g,"Add").replace(/{name}/g,"Add Device");this.$tabs.append(i),this.$tabs.find("#deviceTabAdd").on("click",(()=>{r.configuration.devices.push(this.getDefaultDeviceConfiguration(r.configSchema)),this.renderDevicesSettings(r,r.configuration.devices.length-1)}))}renderDeviceTabPanel(e,r,i,n,t){const o='\n <div class="tab-pane container fade {activeClass} card card-body list-group-item" id="deviceTabPanel{index}">\n <button type="button" class="close pull-right" id="deviceTabPanelClose{index}">\n <span>×</span>\n <span class="sr-only">Close</span>\n </button>\n </div>\n '.replace(/{activeClass}/g,i===n?"in show active":"").replace(/{index}/g,i.toString());this.$tabPanels.append(o);const a=this.$tabPanels.find(`#deviceTabPanel${i}`),s=this.clone(e.configSchema.schema.properties.devices.items),c=s.properties.model;this.renderModelDropDown(t,a,i,e,s,c,r),this.renderRemoveButton(a,i,e),this.renderForm(t,i,n,e,s,r)}renderModelDropDown(e,r,i,n,t,o,a){this.componentRenderer.renderDropDown(r,"model"+i,o,a.model,(r=>{a.model=r,this.renderForm(e,i,i,n,t,a)}))}renderRemoveButton(e,r,i){e.find(`#deviceTabPanelClose${r}`).on("click",(()=>{i.configuration.devices.splice(r,1),this.renderDevicesSettings(i,r-1)}))}renderForm(e,r,i,n,t,o){delete(t=this.clone(t)).properties.model,n.hideDeviceSettingsPerModel[o.model].forEach((e=>{delete t.properties[e]})),e.off("click").on("click",(()=>{this.form?.end(),this.form=n.homebridgeProvider.createForm({schema:t},o),this.form.onChange((async i=>{const t=n.configuration.devices[r].name;this.applyChanges(n.configuration.devices[r],i,["model"]),await this.updatePluginConfig(n),i.name!==t&&e.text(i.name)}))})),r===i&&e.trigger("click")}getDefaultDeviceConfiguration(e){const r={},i=e.schema.properties.devices.items.properties;return Object.keys(i).filter((e=>!!i[e]?.default)).forEach((e=>{r[e]=i[e]?.default})),r}applyChanges(e,r,i){Object.assign(e,r);for(const n in e)void 0!==r[n]||i.includes(n)||delete e[n]}}r.PluginConfigDevicesRenderer=t},102:(e,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PluginConfigNameRenderer=void 0;const n=i(536);class t extends n.PluginConfigRendererBase{render(e){this.componentRenderer.renderTextBox($("#generalSettings"),"name",e.configSchema.schema.properties.name,e.configuration.name,(async r=>{e.configuration.name=r,await this.updatePluginConfig(e)}))}}r.PluginConfigNameRenderer=t},653:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PluginConfigRenderer=void 0,r.PluginConfigRenderer=class{renderers;constructor(e){this.renderers=e}render(e){void 0===e.configuration&&(e.configuration={name:void 0,devices:[]}),this.renderers.forEach((r=>r.render(e)))}}},536:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PluginConfigRendererBase=void 0,r.PluginConfigRendererBase=class{componentRenderer;constructor(e){this.componentRenderer=e}async updatePluginConfig(e){const r=this.clone(e.configuration);delete r.platform,await e.homebridgeProvider.updatePluginConfig([r])}clone(e){return JSON.parse(JSON.stringify(e))}}}},r={};function i(n){var t=r[n];if(void 0!==t)return t.exports;var o=r[n]={exports:{}};return e[n](o,o.exports,i),o.exports}(()=>{const e=i(999),r=i(84),n=i(102),t=i(653);window.renderEcoFlowPluginConfig=async function(i){const o=await i.getPluginConfig(),a=await i.getPluginConfigSchema(),s=o[0],c=new e.ComponentRenderer;new t.PluginConfigRenderer([new n.PluginConfigNameRenderer(c),new r.PluginConfigDevicesRenderer(c)]).render({homebridgeProvider:i,configuration:s,configSchema:a})}})()})();
|
|
1
|
+
(()=>{"use strict";var e={999:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ComponentRenderer=void 0,r.ComponentRenderer=class{renderTextBox(e,r,i,n,t){const o='\n <div class="form-group">\n <label for="device{id}" class="{requiredClass}">{title}</label>\n <input type="text" class="form-control" id="device{id}" placeholder="{description}" required="{required}" />\n </div>'.replace(/{id}/g,r).replace(/{title}/g,i.title).replace(/{description}/g,i.description??"").replace(/{requiredClass}/g,i.required?"required-label":"").replace(/{required}/g,(i.required??!1).toString());e.append(o);const a=e.find(`#device${r}`);a.val(n),a.on("change",(()=>t(a.val()?.toString()||"")))}renderDropDown(e,r,i,n,t){const o='\n <div class="form-group">\n <label for="device{id}" class="{requiredClass}">{title}</label>\n <select class="form-control" id="device{id}" required="{required}"></select>\n </div>'.replace(/{id}/g,r).replace(/{title}/g,i.title).replace(/{requiredClass}/g,i.required?"required-label":"").replace(/{required}/g,(i.required??!1).toString());e.append(o);const a=e.find(`#device${r}`);i.enum.forEach((e=>{const r=$("<option>").val(e).text(e);a.append(r)})),a.val(n),a.on("change",(()=>t(a.val()?.toString()||"")))}}},84:(e,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PluginConfigDevicesRenderer=void 0;const n=i(536);class t extends n.PluginConfigRendererBase{form;$tabs;$tabPanels;_hideDeviceSettingsPerModel;constructor(e){super(e),this.$tabs=$("#devicesTabs"),this.$tabPanels=$("#devicesPanels"),this._hideDeviceSettingsPerModel={"Delta 2":["powerStream","powerOcean","outlet"],"Delta 2 Max":["powerStream","powerOcean","outlet"],"Delta Pro":["powerStream","powerOcean","outlet"],"Delta Pro 3":["powerStream","powerOcean","outlet"],"Delta Pro Ultra":["powerStream","powerOcean","outlet"],Discovery:["battery","powerStream","powerOcean","outlet"],PowerStream:["battery","powerOcean","outlet"],PowerOcean:["battery","powerStream","outlet"],"Smart Plug":["battery","powerStream","powerOcean"],Glacier:["powerStream","powerOcean","outlet"]}}get hideDeviceSettingsPerModel(){return this._hideDeviceSettingsPerModel}render(e){this.renderDevicesSettings({homebridgeProvider:e.homebridgeProvider,configSchema:e.configSchema,configuration:e.configuration,hideDeviceSettingsPerModel:this.hideDeviceSettingsPerModel})}renderDevicesSettings(e,r){$("#devicesLabel").text(e.configSchema.schema.properties.devices.title);const i=!r||r<0?0:r;this.renderDeviceTabs(e,i)}renderDeviceTabs(e,r){this.clearDeviceTabs();const i='\n <li class="nav-item">\n <a class="nav-link {activeClass}" data-toggle="tab" href="#deviceTabPanel{index}" id="deviceTab{index}">{name}</a>\n </li>\n ';e.configuration.devices.forEach(((n,t)=>{const o=i.replace(/{activeClass}/g,t===r?"active":"").replace(/{index}/g,t.toString()).replace(/{name}/g,n.name??`Device${t+1}`);this.$tabs.append(o),this.renderDeviceTabPanel(e,n,t,r,this.$tabs.find(`#deviceTab${t}`))})),this.renderAddNewDeviceTab(i,e)}clearDeviceTabs(){this.$tabs.empty(),this.$tabPanels.empty(),this.form?.end()}renderAddNewDeviceTab(e,r){const i=e.replace(/{activeClass}/g,"").replace(/{index}/g,"Add").replace(/{name}/g,"Add Device");this.$tabs.append(i),this.$tabs.find("#deviceTabAdd").on("click",(()=>{r.configuration.devices.push(this.getDefaultDeviceConfiguration(r.configSchema)),this.renderDevicesSettings(r,r.configuration.devices.length-1)}))}renderDeviceTabPanel(e,r,i,n,t){const o='\n <div class="tab-pane container fade {activeClass} card card-body list-group-item" id="deviceTabPanel{index}">\n <button type="button" class="close pull-right" id="deviceTabPanelClose{index}">\n <span>×</span>\n <span class="sr-only">Close</span>\n </button>\n </div>\n '.replace(/{activeClass}/g,i===n?"in show active":"").replace(/{index}/g,i.toString());this.$tabPanels.append(o);const a=this.$tabPanels.find(`#deviceTabPanel${i}`),s=this.clone(e.configSchema.schema.properties.devices.items),c=s.properties.model;this.renderModelDropDown(t,a,i,e,s,c,r),this.renderRemoveButton(a,i,e),this.renderForm(t,i,n,e,s,r)}renderModelDropDown(e,r,i,n,t,o,a){this.componentRenderer.renderDropDown(r,"model"+i,o,a.model,(r=>{a.model=r,this.renderForm(e,i,i,n,t,a)}))}renderRemoveButton(e,r,i){e.find(`#deviceTabPanelClose${r}`).on("click",(()=>{i.configuration.devices.splice(r,1),this.renderDevicesSettings(i,r-1)}))}renderForm(e,r,i,n,t,o){delete(t=this.clone(t)).properties.model,n.hideDeviceSettingsPerModel[o.model].forEach((e=>{delete t.properties[e]})),e.off("click").on("click",(()=>{this.form?.end(),this.form=n.homebridgeProvider.createForm({schema:t},o),this.form.onChange((async i=>{const t=n.configuration.devices[r].name;this.applyChanges(n.configuration.devices[r],i,["model"]),await this.updatePluginConfig(n),i.name!==t&&e.text(i.name)}))})),r===i&&e.trigger("click")}getDefaultDeviceConfiguration(e){const r={},i=e.schema.properties.devices.items.properties;return Object.keys(i).filter((e=>!!i[e]?.default)).forEach((e=>{r[e]=i[e]?.default})),r}applyChanges(e,r,i){Object.assign(e,r);for(const n in e)void 0!==r[n]||i.includes(n)||delete e[n]}}r.PluginConfigDevicesRenderer=t},102:(e,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PluginConfigNameRenderer=void 0;const n=i(536);class t extends n.PluginConfigRendererBase{render(e){this.componentRenderer.renderTextBox($("#generalSettings"),"name",e.configSchema.schema.properties.name,e.configuration.name,(async r=>{e.configuration.name=r,await this.updatePluginConfig(e)}))}}r.PluginConfigNameRenderer=t},653:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PluginConfigRenderer=void 0,r.PluginConfigRenderer=class{renderers;constructor(e){this.renderers=e}render(e){void 0===e.configuration&&(e.configuration={name:void 0,devices:[]}),this.renderers.forEach((r=>r.render(e)))}}},536:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PluginConfigRendererBase=void 0,r.PluginConfigRendererBase=class{componentRenderer;constructor(e){this.componentRenderer=e}async updatePluginConfig(e){const r=this.clone(e.configuration);delete r.platform,await e.homebridgeProvider.updatePluginConfig([r])}clone(e){return JSON.parse(JSON.stringify(e))}}}},r={};function i(n){var t=r[n];if(void 0!==t)return t.exports;var o=r[n]={exports:{}};return e[n](o,o.exports,i),o.exports}(()=>{const e=i(999),r=i(84),n=i(102),t=i(653);window.renderEcoFlowPluginConfig=async function(i){const o=await i.getPluginConfig(),a=await i.getPluginConfigSchema(),s=o[0],c=new e.ComponentRenderer;new t.PluginConfigRenderer([new n.PluginConfigNameRenderer(c),new r.PluginConfigDevicesRenderer(c)]).render({homebridgeProvider:i,configuration:s,configSchema:a})}})()})();
|
package/dist/platform.js
CHANGED
|
@@ -6,6 +6,8 @@ const delta2MaxAccessory_1 = require("@ecoflow/accessories/batteries/delta2/delt
|
|
|
6
6
|
const delta2Simulator_1 = require("@ecoflow/accessories/batteries/delta2/simulations/delta2Simulator");
|
|
7
7
|
const deltaPro3Accessory_1 = require("@ecoflow/accessories/batteries/deltapro3/deltaPro3Accessory");
|
|
8
8
|
const deltaPro3Simulator_1 = require("@ecoflow/accessories/batteries/deltapro3/simulations/deltaPro3Simulator");
|
|
9
|
+
const discoveryAccessory_1 = require("@ecoflow/accessories/discovery/discoveryAccessory");
|
|
10
|
+
const discoverySimulator_1 = require("@ecoflow/accessories/discovery/simulations/discoverySimulator");
|
|
9
11
|
const powerStreamAccessory_1 = require("@ecoflow/accessories/powerstream/powerStreamAccessory");
|
|
10
12
|
const powerStreamSimulator_1 = require("@ecoflow/accessories/powerstream/simulations/powerStreamSimulator");
|
|
11
13
|
const smartPlugSimulator_1 = require("@ecoflow/accessories/smartplug/simulations/smartPlugSimulator");
|
|
@@ -187,6 +189,10 @@ class EcoFlowHomebridgePlatform {
|
|
|
187
189
|
// EcoFlowAccessoryType = DeltaProUltraAccessory;
|
|
188
190
|
// EcoFlowAccessorySimulatorType = DeltaProUltraSimulator;
|
|
189
191
|
// break;
|
|
192
|
+
case config_1.DeviceModel.Discovery:
|
|
193
|
+
EcoFlowAccessoryType = discoveryAccessory_1.DiscoveryAccessory;
|
|
194
|
+
EcoFlowAccessorySimulatorType = discoverySimulator_1.DiscoverySimulator;
|
|
195
|
+
break;
|
|
190
196
|
// case DeviceModel.Glacier:
|
|
191
197
|
// EcoFlowAccessoryType = GlacierAccessory;
|
|
192
198
|
// EcoFlowAccessorySimulatorType = GlacierSimulator;
|
package/dist/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;AAYA,2FAAwF;AACxF,iGAA8F;AAC9F,uGAAoG;AACpG,oGAAiG;AACjG,gHAA6G;
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;AAYA,2FAAwF;AACxF,iGAA8F;AAC9F,uGAAoG;AACpG,oGAAiG;AACjG,gHAA6G;AAC7G,0FAAuF;AACvF,sGAAmG;AAEnG,gGAA6F;AAC7F,4GAAyG;AACzG,sGAAmG;AACnG,0FAAuF;AACvF,+EAA4E;AAC5E,+EAA4E;AAE5E,wFAMuD;AACvD,4CAA2E;AAC3E,kFAA+E;AAC/E,oDAAiD;AACjD,0EAAuE;AACvE,gDAA+D;AAU/D,MAAa,yBAAyB;IAiBjB;IACD;IACA;IAlBD,aAAa,CAAgB;IAC9B,OAAO,CAAiB;IACxB,cAAc,CAAwB;IAEtD,oDAAoD;IACpC,WAAW,GAAwB,EAAE,CAAC;IAErC,cAAc,GAA0B,IAAI,6CAAqB,EAAE,CAAC;IACpE,cAAc,GAA0B,IAAI,6CAAqB,CAChF,IAAI,CAAC,cAAc,EACnB,IAAI,qCAAiB,EAAE,CACxB,CAAC;IAEe,qBAAqB,GAA0B,IAAI,6CAAqB,EAAE,CAAC;IAE5F,YACmB,SAAkB,EACnB,MAAsB,EACtB,GAAQ;QAFP,cAAS,GAAT,SAAS,CAAS;QACnB,WAAM,GAAN,MAAM,CAAgB;QACtB,QAAG,GAAH,GAAG,CAAK;QAExB,yBAAyB,CAAC,yBAAyB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7D,IAAI,CAAC,aAAa,GAAG,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