Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new setting + migration script #41

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
21 changes: 21 additions & 0 deletions drivers/go/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

/**
Expand Down Expand Up @@ -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');
}
}
}

/**
Expand Down
9 changes: 9 additions & 0 deletions drivers/go/driver.settings.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 21 additions & 0 deletions drivers/home/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

/**
Expand Down Expand Up @@ -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');
}
}
}

/**
Expand Down
9 changes: 9 additions & 0 deletions drivers/home/driver.settings.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 21 additions & 0 deletions drivers/pro/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

/**
Expand Down Expand Up @@ -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');
}
}
}

/**
Expand Down
9 changes: 9 additions & 0 deletions drivers/pro/driver.settings.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading