return UnDefType.UNDEF;
}
int count = 0;
- if (goeResponse.energy[4] > 0) { // current P1
+ if (goeResponse.energy.length >= 5 && goeResponse.energy[4] > 0) { // current P1
count++;
}
- if (goeResponse.energy[5] > 0) { // current P2
+ if (goeResponse.energy.length >= 6 && goeResponse.energy[5] > 0) { // current P2
count++;
}
- if (goeResponse.energy[6] > 0) { // current P3
+ if (goeResponse.energy.length >= 7 && goeResponse.energy[6] > 0) { // current P3
count++;
}
return new DecimalType(count);
if (goeResponse.sessionChargeConsumption == null) {
return UnDefType.UNDEF;
}
- return new QuantityType<>((Double) (goeResponse.sessionChargeConsumption / 360000d),
- Units.KILOWATT_HOUR);
+ return new QuantityType<>(goeResponse.sessionChargeConsumption / 360000d, Units.KILOWATT_HOUR);
case SESSION_CHARGE_CONSUMPTION_LIMIT:
if (goeResponse.sessionChargeConsumptionLimit == null) {
return UnDefType.UNDEF;
}
- return new QuantityType<>((Double) (goeResponse.sessionChargeConsumptionLimit / 10d),
- Units.KILOWATT_HOUR);
+ return new QuantityType<>(goeResponse.sessionChargeConsumptionLimit / 10d, Units.KILOWATT_HOUR);
case TOTAL_CONSUMPTION:
if (goeResponse.totalChargeConsumption == null) {
return UnDefType.UNDEF;
}
- return new QuantityType<>((Double) (goeResponse.totalChargeConsumption / 10d), Units.KILOWATT_HOUR);
+ return new QuantityType<>(goeResponse.totalChargeConsumption / 10d, Units.KILOWATT_HOUR);
case CURRENT_L1:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 5) {
return UnDefType.UNDEF;
}
// values come in as A*10, 41 means 4.1A
- return new QuantityType<>((Double) (goeResponse.energy[4] / 10d), Units.AMPERE);
+ return new QuantityType<>(goeResponse.energy[4] / 10d, Units.AMPERE);
case CURRENT_L2:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 6) {
return UnDefType.UNDEF;
}
- return new QuantityType<>((Double) (goeResponse.energy[5] / 10d), Units.AMPERE);
+ return new QuantityType<>(goeResponse.energy[5] / 10d, Units.AMPERE);
case CURRENT_L3:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 7) {
return UnDefType.UNDEF;
}
- return new QuantityType<>((Double) (goeResponse.energy[6] / 10d), Units.AMPERE);
+ return new QuantityType<>(goeResponse.energy[6] / 10d, Units.AMPERE);
case POWER_L1:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 8) {
return UnDefType.UNDEF;
}
// values come in as kW*10, 41 means 4.1kW
return new QuantityType<>(goeResponse.energy[7] * 100, Units.WATT);
case POWER_L2:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 9) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[8] * 100, Units.WATT);
case POWER_L3:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 10) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[9] * 100, Units.WATT);
case VOLTAGE_L1:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 1) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[0], Units.VOLT);
case VOLTAGE_L2:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 2) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[1], Units.VOLT);
case VOLTAGE_L3:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 3) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[2], Units.VOLT);
case POWER_ALL:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 12) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[11] * 10, Units.WATT);
allChannels.forEach(channel -> updateState(channel, UnDefType.UNDEF));
} else {
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
- allChannels.forEach(channel -> updateState(channel, getValue(channel, (GoEStatusResponseDTO) goeResponse)));
+ allChannels.forEach(channel -> updateState(channel, getValue(channel, goeResponse)));
}
}
}
case ALLOW_CHARGING:
return goeResponse.allowCharging == true ? OnOffType.ON : OnOffType.OFF;
case TEMPERATURE_TYPE2_PORT:
- if (goeResponse.temperatures == null) {
+ // It was reported that the temperature is invalid when only one value is returned
+ // That's why it is checked that at least 2 values are returned
+ if (goeResponse.temperatures == null || goeResponse.temperatures.length < 2) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.temperatures[0], SIUnits.CELSIUS);
case TEMPERATURE_CIRCUIT_BOARD:
- if (goeResponse.temperatures == null) {
+ if (goeResponse.temperatures == null || goeResponse.temperatures.length < 2) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.temperatures[1], SIUnits.CELSIUS);
if (goeResponse.totalChargeConsumption == null) {
return UnDefType.UNDEF;
}
- return new QuantityType<>((Double) (goeResponse.totalChargeConsumption / 1000d), Units.KILOWATT_HOUR);
+ return new QuantityType<>(goeResponse.totalChargeConsumption / 1000d, Units.KILOWATT_HOUR);
case VOLTAGE_L1:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 1) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[0], Units.VOLT);
case VOLTAGE_L2:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 2) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[1], Units.VOLT);
case VOLTAGE_L3:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 3) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[2], Units.VOLT);
case CURRENT_L1:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 5) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[4], Units.AMPERE);
case CURRENT_L2:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 6) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[5], Units.AMPERE);
case CURRENT_L3:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 7) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[6], Units.AMPERE);
case POWER_L1:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 8) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[7], Units.WATT);
case POWER_L2:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 9) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[8], Units.WATT);
case POWER_L3:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 10) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[9], Units.WATT);
case POWER_ALL:
- if (goeResponse.energy == null) {
+ if (goeResponse.energy == null || goeResponse.energy.length < 12) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[11], Units.WATT);
return gson.fromJson(response, GoEStatusResponseV2DTO.class);
}
+ @Override
protected void updateChannelsAndStatus(@Nullable GoEStatusResponseBaseDTO goeResponse, @Nullable String message) {
if (goeResponse == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, message);
allChannels.forEach(channel -> updateState(channel, UnDefType.UNDEF));
} else {
updateStatus(ThingStatus.ONLINE);
- allChannels
- .forEach(channel -> updateState(channel, getValue(channel, (GoEStatusResponseV2DTO) goeResponse)));
+ allChannels.forEach(channel -> updateState(channel, getValue(channel, goeResponse)));
}
}
}