[goecharger] fix data type for energy (nrg) (#13052)
* [goecharger] fix data type for energy (nrg) * nrg need to be double for V2 * [goecharger] update example Signed-off-by: Reinhard Plaim <reinhardplaim@gmail.com>
This commit is contained in:
parent
57e31e2885
commit
9c768dc08f
|
@ -112,55 +112,66 @@ rule "Set charging limit for go-eCharger"
|
|||
when
|
||||
Time cron "*/10 * * ? * *" // Trigger every 10 seconds
|
||||
then
|
||||
var actualMaxChargingCurrentInt = (GoEChargerMaxCurrent.state as Number).intValue
|
||||
|
||||
if (GoEChargerExcessCharge.state == ON) {
|
||||
var totalPowerOutputInWatt = Total_power_fast.state as DecimalType * 1000
|
||||
if (totalPowerOutputInWatt > 0) {
|
||||
totalPowerOutputInWatt = 0
|
||||
var currentChargingPower = GoEChargerPowerAll.state as Number
|
||||
var totalPowerOutputInWatt = (Total_power_fast.state as DecimalType) * 1000
|
||||
var availableChargingPowerInWatt = 0
|
||||
|
||||
if (totalPowerOutputInWatt > 0 && currentChargingPower > 0) {
|
||||
// take care if already charging
|
||||
availableChargingPowerInWatt = currentChargingPower.intValue - totalPowerOutputInWatt.intValue
|
||||
} else {
|
||||
if (totalPowerOutputInWatt > 0) {
|
||||
totalPowerOutputInWatt = 0
|
||||
}
|
||||
availableChargingPowerInWatt = (totalPowerOutputInWatt.intValue * -1) + currentChargingPower.intValue
|
||||
}
|
||||
|
||||
totalPowerOutputInWatt = totalPowerOutputInWatt * -1
|
||||
|
||||
var maxAmp3Phases = (totalPowerOutputInWatt / 3) / 230
|
||||
var maxAmp3Phases = (availableChargingPowerInWatt / 3) / 230
|
||||
if (maxAmp3Phases > 16.0) {
|
||||
maxAmp3Phases = 16.0
|
||||
}
|
||||
var maxAmp1Phase = totalPowerOutputInWatt / 230;
|
||||
|
||||
if (maxAmp3Phases.intValue >= 6) {
|
||||
var maxAmp1Phase = availableChargingPowerInWatt / 230
|
||||
|
||||
if (maxAmp3Phases >= 6) {
|
||||
// set force state to neutral (Neutral=0, Off=1, On=2)
|
||||
if (GoEChargerForceState.state != 0) {
|
||||
GoEChargerForceState.sendCommand(0);
|
||||
GoEChargerForceState.sendCommand(0)
|
||||
}
|
||||
|
||||
// 3 phases
|
||||
if ((GoEChargerPhases.state as Number) != 3) {
|
||||
GoEChargerPhases.sendCommand(3);
|
||||
if (GoEChargerPhases.state != 3) {
|
||||
GoEChargerPhases.sendCommand(3)
|
||||
}
|
||||
|
||||
if ((GoEChargerMaxCurrent.state as Number).intValue != maxAmp3Phases.intValue) {
|
||||
if (actualMaxChargingCurrentInt != maxAmp3Phases.intValue) {
|
||||
GoEChargerMaxCurrent.sendCommand(maxAmp3Phases.intValue)
|
||||
// logInfo("eCharger", "Set charging limit 3 Phases: " + maxAmp3Phases.intValue + " A")
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
if (maxAmp1Phase.intValue >= 6 ) {
|
||||
// set force state to neutral (Neutral=0, Off=1, On=2)
|
||||
if (GoEChargerForceState.state != 0) {
|
||||
GoEChargerForceState.sendCommand(0);
|
||||
GoEChargerForceState.sendCommand(0)
|
||||
}
|
||||
|
||||
// switch to 1 phase -> check if this is useful
|
||||
if ((GoEChargerPhases.state as Number) != 1) {
|
||||
if (GoEChargerPhases.state != 1) {
|
||||
GoEChargerPhases.sendCommand(1)
|
||||
}
|
||||
|
||||
if ((GoEChargerMaxCurrent.state as Number).intValue != maxAmp1Phase.intValue) {
|
||||
if (actualMaxChargingCurrentInt != maxAmp1Phase.intValue) {
|
||||
GoEChargerMaxCurrent.sendCommand(maxAmp1Phase.intValue)
|
||||
// logInfo("eCharger", "Set charging limit 1 Phase: " + maxAmp1Phase.intValue + " A")
|
||||
}
|
||||
} else {
|
||||
// switch off
|
||||
if (GoEChargerForceState.state != 1) {
|
||||
GoEChargerForceState.sendCommand(1);
|
||||
GoEChargerMaxCurrent.sendCommand(6)
|
||||
GoEChargerForceState.sendCommand(1)
|
||||
// logInfo("eCharger", "Switch charging off")
|
||||
}
|
||||
}
|
||||
|
@ -168,14 +179,14 @@ then
|
|||
} else {
|
||||
// set force state to neutral (Neutral=0, Off=1, On=2)
|
||||
if (GoEChargerForceState.state != 0) {
|
||||
GoEChargerForceState.sendCommand(0);
|
||||
GoEChargerForceState.sendCommand(0)
|
||||
}
|
||||
|
||||
if ((GoEChargerPhases.state as Number) != 3) {
|
||||
GoEChargerPhases.sendCommand(3);
|
||||
if (GoEChargerPhases.state != 3) {
|
||||
GoEChargerPhases.sendCommand(3)
|
||||
}
|
||||
|
||||
if ((GoEChargerMaxCurrent.state as Number).intValue != 16) {
|
||||
if (actualMaxChargingCurrentInt != 16) {
|
||||
GoEChargerMaxCurrent.sendCommand(16)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,9 +27,6 @@ public class GoEStatusResponseBaseDTO {
|
|||
@SerializedName("amp")
|
||||
public Integer maxCurrent;
|
||||
|
||||
@SerializedName("nrg")
|
||||
public Integer[] energy;
|
||||
|
||||
@SerializedName("err")
|
||||
public Integer errorCode;
|
||||
|
||||
|
|
|
@ -45,4 +45,7 @@ public class GoEStatusResponseDTO extends GoEStatusResponseBaseDTO {
|
|||
|
||||
@SerializedName("amx")
|
||||
public Integer maxCurrentTemporary;
|
||||
|
||||
@SerializedName("nrg")
|
||||
public Integer[] energy;
|
||||
}
|
||||
|
|
|
@ -41,4 +41,7 @@ public class GoEStatusResponseV2DTO extends GoEStatusResponseBaseDTO {
|
|||
|
||||
@SerializedName("frc")
|
||||
public Integer forceState;
|
||||
|
||||
@SerializedName("nrg")
|
||||
public Double[] energy;
|
||||
}
|
||||
|
|
|
@ -87,21 +87,6 @@ public abstract class GoEChargerBaseHandler extends BaseThingHandler {
|
|||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new StringType(goeResponseBase.firmware);
|
||||
case VOLTAGE_L1:
|
||||
if (goeResponseBase.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>(goeResponseBase.energy[0], Units.VOLT);
|
||||
case VOLTAGE_L2:
|
||||
if (goeResponseBase.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>(goeResponseBase.energy[1], Units.VOLT);
|
||||
case VOLTAGE_L3:
|
||||
if (goeResponseBase.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>(goeResponseBase.energy[2], Units.VOLT);
|
||||
}
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
|
|
|
@ -218,11 +218,26 @@ public class GoEChargerHandler extends GoEChargerBaseHandler {
|
|||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>(goeResponse.energy[9] * 100, Units.WATT);
|
||||
case POWER_ALL:
|
||||
if (goeResponseBase.energy == null) {
|
||||
case VOLTAGE_L1:
|
||||
if (goeResponse.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>(goeResponseBase.energy[11] * 10, Units.WATT);
|
||||
return new QuantityType<>(goeResponse.energy[0], Units.VOLT);
|
||||
case VOLTAGE_L2:
|
||||
if (goeResponse.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>(goeResponse.energy[1], Units.VOLT);
|
||||
case VOLTAGE_L3:
|
||||
if (goeResponse.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>(goeResponse.energy[2], Units.VOLT);
|
||||
case POWER_ALL:
|
||||
if (goeResponse.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>(goeResponse.energy[11] * 10, Units.WATT);
|
||||
}
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
|
|
|
@ -152,53 +152,67 @@ public class GoEChargerV2Handler extends GoEChargerBaseHandler {
|
|||
if (goeResponse.sessionChargeConsumption == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>((Double) (goeResponse.sessionChargeConsumption / 1000d), Units.KILOWATT_HOUR);
|
||||
return new QuantityType<>(goeResponse.sessionChargeConsumption / 1000d, Units.KILOWATT_HOUR);
|
||||
case SESSION_CHARGE_CONSUMPTION_LIMIT:
|
||||
if (goeResponse.sessionChargeConsumptionLimit == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>((Double) (goeResponse.sessionChargeConsumptionLimit / 1000d),
|
||||
Units.KILOWATT_HOUR);
|
||||
return new QuantityType<>(goeResponse.sessionChargeConsumptionLimit / 1000d, Units.KILOWATT_HOUR);
|
||||
case TOTAL_CONSUMPTION:
|
||||
if (goeResponse.totalChargeConsumption == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>((Double) (goeResponse.totalChargeConsumption / 1000d), Units.KILOWATT_HOUR);
|
||||
case VOLTAGE_L1:
|
||||
if (goeResponse.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>(goeResponse.energy[0], Units.VOLT);
|
||||
case VOLTAGE_L2:
|
||||
if (goeResponse.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>(goeResponse.energy[1], Units.VOLT);
|
||||
case VOLTAGE_L3:
|
||||
if (goeResponse.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>(goeResponse.energy[2], Units.VOLT);
|
||||
case CURRENT_L1:
|
||||
if (goeResponse.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>((Double) (goeResponse.energy[4] / 1000d), Units.AMPERE);
|
||||
return new QuantityType<>(goeResponse.energy[4], Units.AMPERE);
|
||||
case CURRENT_L2:
|
||||
if (goeResponse.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>((Double) (goeResponse.energy[5] / 1000d), Units.AMPERE);
|
||||
return new QuantityType<>(goeResponse.energy[5], Units.AMPERE);
|
||||
case CURRENT_L3:
|
||||
if (goeResponse.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>((Double) (goeResponse.energy[6] / 1000d), Units.AMPERE);
|
||||
return new QuantityType<>(goeResponse.energy[6], Units.AMPERE);
|
||||
case POWER_L1:
|
||||
if (goeResponse.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>(goeResponse.energy[7] * 1000, Units.WATT);
|
||||
return new QuantityType<>(goeResponse.energy[7], Units.WATT);
|
||||
case POWER_L2:
|
||||
if (goeResponse.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>(goeResponse.energy[8] * 1000, Units.WATT);
|
||||
return new QuantityType<>(goeResponse.energy[8], Units.WATT);
|
||||
case POWER_L3:
|
||||
if (goeResponse.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>(goeResponse.energy[9] * 1000, Units.WATT);
|
||||
return new QuantityType<>(goeResponse.energy[9], Units.WATT);
|
||||
case POWER_ALL:
|
||||
if (goeResponse.energy == null) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
return new QuantityType<>(goeResponse.energy[11] * 1000, Units.WATT);
|
||||
return new QuantityType<>(goeResponse.energy[11], Units.WATT);
|
||||
case FORCE_STATE:
|
||||
if (goeResponse.forceState == null) {
|
||||
return UnDefType.UNDEF;
|
||||
|
|
Loading…
Reference in New Issue