Skip to content

Commit

Permalink
Implement Goodwe export limit control
Browse files Browse the repository at this point in the history
  • Loading branch information
longzheng committed Dec 13, 2024
1 parent 1b82a72 commit 23e274c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/coordinator/helpers/inverterController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type InverterConfiguration =
| { type: 'disconnect' }
| {
type: 'limit';
exportLimitWatts: number;
invertersCount: number;
targetSolarWatts: number;
targetSolarPowerRatio: number;
Expand Down Expand Up @@ -355,6 +356,7 @@ export class InverterController {

return {
type: 'limit',
exportLimitWatts: configuration.exportLimitWatts,
invertersCount: configuration.invertersCount,
targetSolarWatts: rampedTargetSolarWatts,
targetSolarPowerRatio: rampedTargetSolarPowerRatio,
Expand Down Expand Up @@ -458,6 +460,7 @@ export function calculateInverterConfiguration({

return {
type: 'limit',
exportLimitWatts,
invertersCount: maxInvertersCount,
targetSolarWatts,
targetSolarPowerRatio: roundToDecimals(targetSolarPowerRatio, 4),
Expand Down
26 changes: 22 additions & 4 deletions src/inverter/goodwe/et.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,30 @@ export class GoodweEtInverterDataPoller extends InverterDataPollerBase {
this.connection.onDestroy();
}

// eslint-disable-next-line @typescript-eslint/require-await
override async onControl(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_inverterConfiguration: InverterConfiguration,
inverterConfiguration: InverterConfiguration,
): Promise<void> {
throw new Error('Method not implemented.');
switch (inverterConfiguration.type) {
case 'disconnect':
throw new Error('Disconnect not supported');
case 'limit': {
const deviceParameters =
await this.connection.getDeviceParameters();

const exportLimitPercentageOfRatedPower = Math.min(
inverterConfiguration.exportLimitWatts /
deviceParameters.RatePower,
1,
);

await this.connection.setMeterControl({
FeedPowerEnable: true,
FeedPowerPara: Math.floor(
exportLimitPercentageOfRatedPower * 10000,
),
});
}
}
}
}

Expand Down

0 comments on commit 23e274c

Please sign in to comment.