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

GoodWe battery remote control improvements. #1201

Merged
merged 26 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d3720f0
Added config input to enter the max battery charging/discharging power.
venu-sagar Aug 12, 2020
5a29113
allowed charge and discharge values are auto adjusted based on the so…
venu-sagar Aug 12, 2020
ad1e929
restructured the code.
venu-sagar Aug 12, 2020
c0871e0
Latest Changes charge/discharge
venu-sagar Sep 24, 2020
6ad88f8
changed power limits
venu-sagar Oct 7, 2020
399035f
Adjusting in the static battery limits.
venu-sagar Oct 19, 2020
b7eff23
Merge branch 'develop' into feature/GoodWeFix
venu-sagar Oct 19, 2020
92a5e99
merge problems rectified
venu-sagar Oct 19, 2020
b7e5081
corrected null pointer exception
venu-sagar Oct 20, 2020
e6ac2dc
Fix typo 'bateryPower'
sfeilmeier Oct 20, 2020
522721e
Drop unused channels
sfeilmeier Oct 20, 2020
62edc9b
Align comments with code
sfeilmeier Oct 20, 2020
4bfac2b
Drop unused channels (2nd try)
sfeilmeier Oct 20, 2020
3bcf7a7
Add JUnit tests according to definition of scenarios
sfeilmeier Oct 20, 2020
b29a809
rework on apply power funtion and converting it into a state machine
venu-sagar Oct 22, 2020
6d67c0d
Integrate BT + refactoring
sfeilmeier Oct 27, 2020
5b67b1f
ATTENTION: Renaming bundle to GoodWe instead of GoodWe.ET.
sfeilmeier Oct 27, 2020
dfac5e9
Cleanup code
sfeilmeier Oct 27, 2020
6b6110d
Rename java package; remove "et" from name
sfeilmeier Oct 28, 2020
e94815b
Merge branch 'develop' into feature/GoodWeFix
sfeilmeier Nov 1, 2020
19195fe
Reset to develop
sfeilmeier Nov 1, 2020
c45c9ed
Update ESS names
sfeilmeier Nov 1, 2020
69a5889
Merge branch 'develop' into feature/GoodWeFix
sfeilmeier Nov 10, 2020
807cac9
Fix Eclipse working set
sfeilmeier Nov 10, 2020
70bd217
Update readme
sfeilmeier Nov 10, 2020
c1a9385
Fix calculate Energy + improve modbus register priorities
sfeilmeier Nov 10, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
@AttributeDefinition(name = "Capacity", description = "Capacity of the battery in Wh")
int capacity() default 9_000;

@AttributeDefinition(name = "Maximum power", description = "Maximum charge/discharge power in [W]")
int maxBatteryPower() default 5_200;

@AttributeDefinition(name = "Modbus target filter", description = "This is auto-generated by 'Modbus-ID'.")
String Modbus_target() default "";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ protected ModbusProtocol defineModbusProtocol() {
m(EssChannelId.P_BATTERY1, new SignedWordElement(35183)), //
m(EssChannelId.BATTERY_MODE, new UnsignedWordElement(35184))), //

// new FC3ReadRegistersTask(37102, Priority.HIGH, //
// m(EssChannelId.BMS_ALLOWED_CHARGE, new UnsignedWordElement(37102)), //
// m(EssChannelId.BMS_ALLOWED_DISCHARGE, new SignedWordElement(37104))), //

new FC3ReadRegistersTask(35185, Priority.LOW, //
m(EssChannelId.WARNING_CODE, new UnsignedWordElement(35185)), //
m(EssChannelId.SAFETY_COUNTRY, new UnsignedWordElement(35186)), //
Expand Down Expand Up @@ -393,34 +397,26 @@ protected ModbusProtocol defineModbusProtocol() {
public void applyPower(int activePower, int reactivePower) throws OpenemsNamedException {
final PowerModeEms nextPowerMode;

System.out.println("Active power:" + activePower);

if (this.config.readOnlyMode()) {
// Read-Only-Mode: fall-back to internal self-consumption optimization
nextPowerMode = PowerModeEms.AUTO;
activePower = 0;
} else {
if (activePower <= 0) {
// ActivePower is negative or zero -> CHARGE
if (activePower < 0) {
// ActivePower is negative -> CHARGE
sfeilmeier marked this conversation as resolved.
Show resolved Hide resolved
System.out.println(" Setting Charging");
nextPowerMode = PowerModeEms.CHARGE_BAT;

} else {
// ActivePower is positive -> DISCHARGE

/*
* Check if PV is available. Discharge mode changes according to availability of
* PV
*
* TODO PV mode is not working, need an update from GoodWe for this.
*/
Integer productionPower = null;
for (AbstractGoodWeEtCharger charger : this.chargers) {
productionPower = TypeUtils.sum(productionPower, charger.getActualPower().get());
}
if (productionPower == null) {
// No PV-Power -> required to put on SELL_POWER
nextPowerMode = PowerModeEms.SELL_POWER;
// ActivePower is positive or zero -> DISCHARGE
System.out.println(" Setting Discharging");
Integer soc = this.getSoc().get();
sfeilmeier marked this conversation as resolved.
Show resolved Hide resolved
if (soc == 100 || activePower == 0) {
nextPowerMode = PowerModeEms.EXPORT_AC;
} else {
// PV-Power exists -> set DISCHARGE_BAT
nextPowerMode = PowerModeEms.DISCHARGE_BAT;
nextPowerMode = PowerModeEms.DISCHARGE_PV;
}
}
}
Expand Down Expand Up @@ -482,7 +478,9 @@ private void updatechannels() {
*/
final Channel<Integer> batteryPower = this.channel(EssChannelId.P_BATTERY1);
Integer activePower = batteryPower.getNextValue().get();
Integer productionPower = null;
for (AbstractGoodWeEtCharger charger : this.chargers) {
productionPower = TypeUtils.sum(productionPower, charger.getActualPower().get());
activePower = TypeUtils.sum(activePower, charger.getActualPowerChannel().getNextValue().get());
sfeilmeier marked this conversation as resolved.
Show resolved Hide resolved
}
this._setActivePower(activePower);
Expand All @@ -507,19 +505,49 @@ private void updatechannels() {
/*
* Update Allowed charge and Allowed discharge
*/

// System.out.println(
// "Allowed Charge power: " + allowedChargePower + " Allowed Discharge Power: " + allowedDischargePower);

Integer soc = this.getSoc().get();
Integer maxApparentPower = this.getMaxApparentPower().get();
Integer maxBatteryPower = this.config.maxBatteryPower();

if (soc == null || soc >= 99) {
this._setAllowedChargePower(0);
} else {
this._setAllowedChargePower(TypeUtils.multiply(maxApparentPower, -1));
Integer allowedCharge = null;
Integer allowedDischarge = null;

if (productionPower == null) {
productionPower = 0;
sfeilmeier marked this conversation as resolved.
Show resolved Hide resolved
}
if (soc == null || soc <= 0) {
this._setAllowedDischargePower(0);
} else {
this._setAllowedDischargePower(maxApparentPower);

if (soc == null) {

allowedCharge = 0;
allowedDischarge = 0;

} else if (soc == 100) {

allowedDischarge = maxBatteryPower + productionPower;
allowedCharge = 0;

} else if (soc > 0) {

allowedDischarge = maxBatteryPower + productionPower;
allowedCharge = maxBatteryPower;

} else if (soc == 0) {

allowedDischarge = productionPower;
allowedCharge = maxBatteryPower;

}

// to avoid charging when production is greater than maximum battery power.
if (allowedCharge < 0) {
sfeilmeier marked this conversation as resolved.
Show resolved Hide resolved
allowedCharge = 0;
}

this._setAllowedChargePower(TypeUtils.multiply(allowedCharge * -1));
this._setAllowedDischargePower(allowedDischarge);
sfeilmeier marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
Expand All @@ -541,6 +569,7 @@ public Constraint[] getStaticConstraints() throws OpenemsNamedException {
this.createPowerConstraint("Read-Only-Mode", Phase.ALL, Pwr.REACTIVE, Relationship.EQUALS, 0) //
};
}

return Power.NO_CONSTRAINTS;
}

Expand Down