diff --git a/drivers/go/device.ts b/drivers/go/device.ts index d085b65..c3c5c46 100644 --- a/drivers/go/device.ts +++ b/drivers/go/device.ts @@ -66,7 +66,18 @@ export class GoCharger extends Homey.Device { this.logToDebug(`Failed to poll charger info: ${e}`); }); } - } + + if (this.getSetting('showVoltage')){ + await this.addCapability('measure_voltage.phase1'); + await this.addCapability('measure_voltage.phase2'); + await this.addCapability('measure_voltage.phase3'); + }else{ + await this.removeCapability('measure_voltage.phase1'); + await this.removeCapability('measure_voltage.phase2'); + await this.removeCapability('measure_voltage.phase3'); + } + + } /** * Verify all expected capabilities and apply changes to capabilities. @@ -138,7 +149,7 @@ export class GoCharger extends Homey.Device { newSettings: { [key: string]: string }; changedKeys: string[]; }): Promise { - this.log('GoCharger settings where changed: ', JSON.stringify(changes)); + //this.log('GoCharger settings where changed: ', JSON.stringify(changes)); // Allow user to select if they want phase voltage as a capability or not. if (changes.changedKeys.some((k) => k === 'showVoltage')) { diff --git a/drivers/home/device.ts b/drivers/home/device.ts index 2db5194..5971926 100644 --- a/drivers/home/device.ts +++ b/drivers/home/device.ts @@ -66,6 +66,16 @@ export class HomeCharger extends Homey.Device { this.logToDebug(`Failed to poll charger info: ${e}`); }); } + + if (this.getSetting('showVoltage')){ + await this.addCapability('measure_voltage.phase1'); + await this.addCapability('measure_voltage.phase2'); + await this.addCapability('measure_voltage.phase3'); + }else{ + await this.removeCapability('measure_voltage.phase1'); + await this.removeCapability('measure_voltage.phase2'); + await this.removeCapability('measure_voltage.phase3'); + } } /** @@ -127,7 +137,7 @@ export class HomeCharger extends Homey.Device { newSettings: { [key: string]: string }; changedKeys: string[]; }): Promise { - this.log('HomeCharger settings where changed: ', JSON.stringify(changes)); + //this.log('HomeCharger settings where changed: ', JSON.stringify(changes)); // Allow user to select if they want phase voltage as a capability or not. if (changes.changedKeys.some((k) => k === 'showVoltage')) { diff --git a/drivers/pro/device.ts b/drivers/pro/device.ts index 5a81c03..f6d9632 100644 --- a/drivers/pro/device.ts +++ b/drivers/pro/device.ts @@ -66,6 +66,16 @@ export class ProCharger extends Homey.Device { this.logToDebug(`Failed to poll charger info: ${e}`); }); } + + if (this.getSetting('showVoltage')){ + await this.addCapability('measure_voltage.phase1'); + await this.addCapability('measure_voltage.phase2'); + await this.addCapability('measure_voltage.phase3'); + }else{ + await this.removeCapability('measure_voltage.phase1'); + await this.removeCapability('measure_voltage.phase2'); + await this.removeCapability('measure_voltage.phase3'); + } } /** @@ -129,7 +139,7 @@ export class ProCharger extends Homey.Device { newSettings: { [key: string]: string }; changedKeys: string[]; }): Promise { - this.log('ProCharger settings where changed: ', JSON.stringify(changes)); + //this.log('ProCharger settings where changed: ', JSON.stringify(changes)); // Allow user to select if they want phase voltage as a capability or not. if (changes.changedKeys.some((k) => k === 'showVoltage')) {