diff --git a/app.json b/app.json index 5eeff50..ca8fd2c 100644 --- a/app.json +++ b/app.json @@ -1234,6 +1234,15 @@ }, "value": false }, + { + "id": "showCurrent", + "type": "checkbox", + "label": { + "en": "Show current per phase", + "no": "Vis strøm per fase" + }, + "value": true + }, { "id": "firmware", "type": "label", @@ -1432,6 +1441,15 @@ }, "value": false }, + { + "id": "showCurrent", + "type": "checkbox", + "label": { + "en": "Show current per phase", + "no": "Vis strøm per fase" + }, + "value": true + }, { "id": "firmware", "type": "label", @@ -1630,6 +1648,15 @@ }, "value": false }, + { + "id": "showCurrent", + "type": "checkbox", + "label": { + "en": "Show current per phase", + "no": "Vis strøm per fase" + }, + "value": true + }, { "id": "firmware", "type": "label", diff --git a/drivers/go/device.ts b/drivers/go/device.ts index 1ab3b7e..95a9953 100644 --- a/drivers/go/device.ts +++ b/drivers/go/device.ts @@ -85,6 +85,15 @@ export class GoCharger extends Homey.Device { await this.removeCapability('measure_voltage.phase2'); await this.removeCapability('measure_voltage.phase3'); } + if (this.getSetting('showCurrent')){ + await this.addCapability('measure_current.phase1'); + await this.addCapability('measure_current.phase2'); + await this.addCapability('measure_current.phase3'); + }else{ + await this.removeCapability('measure_current.phase1'); + await this.removeCapability('measure_current.phase2'); + await this.removeCapability('measure_current.phase3'); + } } /** @@ -171,6 +180,18 @@ export class GoCharger extends Homey.Device { await this.removeCapability('measure_voltage.phase3'); } } + // Allow user to select if they want phase current as a capability or not. + if (changes.changedKeys.some((k) => k === 'showCurrent')) { + if (changes.newSettings.showCurrent) { + await this.addCapability('measure_current.phase1'); + await this.addCapability('measure_current.phase2'); + await this.addCapability('measure_current.phase3'); + } else { + await this.removeCapability('measure_current.phase1'); + await this.removeCapability('measure_current.phase2'); + await this.removeCapability('measure_current.phase3'); + } + } } /** diff --git a/drivers/go/driver.settings.compose.json b/drivers/go/driver.settings.compose.json index 59214a3..bc90b45 100644 --- a/drivers/go/driver.settings.compose.json +++ b/drivers/go/driver.settings.compose.json @@ -15,6 +15,15 @@ }, "value": false }, + { + "id": "showCurrent", + "type": "checkbox", + "label": { + "en": "Show current per phase", + "no": "Vis strøm per fase" + }, + "value": true + }, { "id": "firmware", "type": "label", diff --git a/drivers/home/device.ts b/drivers/home/device.ts index 08c4046..ad39cdb 100644 --- a/drivers/home/device.ts +++ b/drivers/home/device.ts @@ -85,6 +85,15 @@ export class HomeCharger extends Homey.Device { await this.removeCapability('measure_voltage.phase2'); await this.removeCapability('measure_voltage.phase3'); } + if (this.getSetting('showCurrent')){ + await this.addCapability('measure_current.phase1'); + await this.addCapability('measure_current.phase2'); + await this.addCapability('measure_current.phase3'); + }else{ + await this.removeCapability('measure_current.phase1'); + await this.removeCapability('measure_current.phase2'); + await this.removeCapability('measure_current.phase3'); + } } /** @@ -163,6 +172,18 @@ export class HomeCharger extends Homey.Device { await this.removeCapability('measure_voltage.phase3'); } } + // Allow user to select if they want phase current as a capability or not. + if (changes.changedKeys.some((k) => k === 'showCurrent')) { + if (changes.newSettings.showCurrent) { + await this.addCapability('measure_current.phase1'); + await this.addCapability('measure_current.phase2'); + await this.addCapability('measure_current.phase3'); + } else { + await this.removeCapability('measure_current.phase1'); + await this.removeCapability('measure_current.phase2'); + await this.removeCapability('measure_current.phase3'); + } + } } /** diff --git a/drivers/home/driver.settings.compose.json b/drivers/home/driver.settings.compose.json index c0454b4..47c6f57 100644 --- a/drivers/home/driver.settings.compose.json +++ b/drivers/home/driver.settings.compose.json @@ -15,6 +15,15 @@ }, "value": false }, + { + "id": "showCurrent", + "type": "checkbox", + "label": { + "en": "Show current per phase", + "no": "Vis strøm per fase" + }, + "value": true + }, { "id": "firmware", "type": "label", diff --git a/drivers/pro/device.ts b/drivers/pro/device.ts index 904c410..c702e59 100644 --- a/drivers/pro/device.ts +++ b/drivers/pro/device.ts @@ -85,6 +85,15 @@ export class ProCharger extends Homey.Device { await this.removeCapability('measure_voltage.phase2'); await this.removeCapability('measure_voltage.phase3'); } + if (this.getSetting('showCurrent')){ + await this.addCapability('measure_current.phase1'); + await this.addCapability('measure_current.phase2'); + await this.addCapability('measure_current.phase3'); + }else{ + await this.removeCapability('measure_current.phase1'); + await this.removeCapability('measure_current.phase2'); + await this.removeCapability('measure_current.phase3'); + } } /** @@ -163,6 +172,18 @@ export class ProCharger extends Homey.Device { await this.removeCapability('measure_voltage.phase3'); } } + // Allow user to select if they want phase current as a capability or not. + if (changes.changedKeys.some((k) => k === 'showCurrent')) { + if (changes.newSettings.showCurrent) { + await this.addCapability('measure_current.phase1'); + await this.addCapability('measure_current.phase2'); + await this.addCapability('measure_current.phase3'); + } else { + await this.removeCapability('measure_current.phase1'); + await this.removeCapability('measure_current.phase2'); + await this.removeCapability('measure_current.phase3'); + } + } } /** diff --git a/drivers/pro/driver.settings.compose.json b/drivers/pro/driver.settings.compose.json index 59214a3..bc90b45 100644 --- a/drivers/pro/driver.settings.compose.json +++ b/drivers/pro/driver.settings.compose.json @@ -15,6 +15,15 @@ }, "value": false }, + { + "id": "showCurrent", + "type": "checkbox", + "label": { + "en": "Show current per phase", + "no": "Vis strøm per fase" + }, + "value": true + }, { "id": "firmware", "type": "label",