mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[evcc] Fixes & Adjust to more breaking changes from evcc 0.111.x (#14381)
* [evcc] Adjust DTO for renamed activePhases * [evcc] Correct wrong units for capacities * [evcc] Fix wrong getter & Reformat Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
This commit is contained in:
parent
b384508fe4
commit
988fde1aba
@ -341,14 +341,17 @@ public class EvccHandler extends BaseThingHandler {
|
|||||||
if (batteryConfigured) {
|
if (batteryConfigured) {
|
||||||
float batteryCapacity = result.getBatteryCapacity();
|
float batteryCapacity = result.getBatteryCapacity();
|
||||||
channel = new ChannelUID(uid, "general", CHANNEL_BATTERY_CAPACITY);
|
channel = new ChannelUID(uid, "general", CHANNEL_BATTERY_CAPACITY);
|
||||||
updateState(channel, new QuantityType<>(batteryCapacity, Units.WATT_HOUR));
|
updateState(channel, new QuantityType<>(batteryCapacity, Units.KILOWATT_HOUR));
|
||||||
|
|
||||||
float batteryPower = result.getBatteryPower();
|
float batteryPower = result.getBatteryPower();
|
||||||
channel = new ChannelUID(uid, "general", CHANNEL_BATTERY_POWER);
|
channel = new ChannelUID(uid, "general", CHANNEL_BATTERY_POWER);
|
||||||
updateState(channel, new QuantityType<>(batteryPower, Units.WATT));
|
updateState(channel, new QuantityType<>(batteryPower, Units.WATT));
|
||||||
|
|
||||||
float batterySoC = result.getBatterySoC();
|
float batterySoC = result.getBatterySoC();
|
||||||
channel = new ChannelUID(uid, "general", CHANNEL_BATTERY_SOC);
|
channel = new ChannelUID(uid, "general", CHANNEL_BATTERY_SOC);
|
||||||
updateState(channel, new QuantityType<>(batterySoC, Units.PERCENT));
|
updateState(channel, new QuantityType<>(batterySoC, Units.PERCENT));
|
||||||
float batteryPrioritySoC = result.getBatterySoC();
|
|
||||||
|
float batteryPrioritySoC = result.getBatteryPrioritySoC();
|
||||||
channel = new ChannelUID(uid, "general", CHANNEL_BATTERY_PRIORITY_SOC);
|
channel = new ChannelUID(uid, "general", CHANNEL_BATTERY_PRIORITY_SOC);
|
||||||
updateState(channel, new QuantityType<>(batteryPrioritySoC, Units.PERCENT));
|
updateState(channel, new QuantityType<>(batteryPrioritySoC, Units.PERCENT));
|
||||||
}
|
}
|
||||||
@ -378,60 +381,79 @@ public class EvccHandler extends BaseThingHandler {
|
|||||||
final String loadpointName = "loadpoint" + loadpointId;
|
final String loadpointName = "loadpoint" + loadpointId;
|
||||||
ChannelUID channel;
|
ChannelUID channel;
|
||||||
Loadpoint loadpoint = result.getLoadpoints()[loadpointId];
|
Loadpoint loadpoint = result.getLoadpoints()[loadpointId];
|
||||||
|
|
||||||
int activePhases = loadpoint.getActivePhases();
|
int activePhases = loadpoint.getActivePhases();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_ACTIVE_PHASES);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_ACTIVE_PHASES);
|
||||||
updateState(channel, new DecimalType(activePhases));
|
updateState(channel, new DecimalType(activePhases));
|
||||||
|
|
||||||
float chargeCurrent = loadpoint.getChargeCurrent();
|
float chargeCurrent = loadpoint.getChargeCurrent();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CHARGE_CURRENT);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CHARGE_CURRENT);
|
||||||
updateState(channel, new QuantityType<>(chargeCurrent, Units.AMPERE));
|
updateState(channel, new QuantityType<>(chargeCurrent, Units.AMPERE));
|
||||||
|
|
||||||
long chargeDuration = loadpoint.getChargeDuration();
|
long chargeDuration = loadpoint.getChargeDuration();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CHARGE_DURATION);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CHARGE_DURATION);
|
||||||
updateState(channel, new QuantityType<>(chargeDuration, MetricPrefix.NANO(Units.SECOND)));
|
updateState(channel, new QuantityType<>(chargeDuration, MetricPrefix.NANO(Units.SECOND)));
|
||||||
|
|
||||||
float chargePower = loadpoint.getChargePower();
|
float chargePower = loadpoint.getChargePower();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CHARGE_POWER);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CHARGE_POWER);
|
||||||
updateState(channel, new QuantityType<>(chargePower, Units.WATT));
|
updateState(channel, new QuantityType<>(chargePower, Units.WATT));
|
||||||
|
|
||||||
long chargeRemainingDuration = loadpoint.getChargeRemainingDuration();
|
long chargeRemainingDuration = loadpoint.getChargeRemainingDuration();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CHARGE_REMAINING_DURATION);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CHARGE_REMAINING_DURATION);
|
||||||
updateState(channel, new QuantityType<>(chargeRemainingDuration, MetricPrefix.NANO(Units.SECOND)));
|
updateState(channel, new QuantityType<>(chargeRemainingDuration, MetricPrefix.NANO(Units.SECOND)));
|
||||||
|
|
||||||
float chargeRemainingEnergy = loadpoint.getChargeRemainingEnergy();
|
float chargeRemainingEnergy = loadpoint.getChargeRemainingEnergy();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CHARGE_REMAINING_ENERGY);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CHARGE_REMAINING_ENERGY);
|
||||||
updateState(channel, new QuantityType<>(chargeRemainingEnergy, Units.WATT_HOUR));
|
updateState(channel, new QuantityType<>(chargeRemainingEnergy, Units.WATT_HOUR));
|
||||||
|
|
||||||
float chargedEnergy = loadpoint.getChargedEnergy();
|
float chargedEnergy = loadpoint.getChargedEnergy();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CHARGED_ENERGY);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CHARGED_ENERGY);
|
||||||
updateState(channel, new QuantityType<>(chargedEnergy, Units.WATT_HOUR));
|
updateState(channel, new QuantityType<>(chargedEnergy, Units.WATT_HOUR));
|
||||||
|
|
||||||
boolean charging = loadpoint.getCharging();
|
boolean charging = loadpoint.getCharging();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CHARGING);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CHARGING);
|
||||||
updateState(channel, OnOffType.from(charging));
|
updateState(channel, OnOffType.from(charging));
|
||||||
|
|
||||||
boolean connected = loadpoint.getConnected();
|
boolean connected = loadpoint.getConnected();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CONNECTED);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CONNECTED);
|
||||||
updateState(channel, OnOffType.from(connected));
|
updateState(channel, OnOffType.from(connected));
|
||||||
|
|
||||||
long connectedDuration = loadpoint.getConnectedDuration();
|
long connectedDuration = loadpoint.getConnectedDuration();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CONNECTED_DURATION);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_CONNECTED_DURATION);
|
||||||
updateState(channel, new QuantityType<>(connectedDuration, MetricPrefix.NANO(Units.SECOND)));
|
updateState(channel, new QuantityType<>(connectedDuration, MetricPrefix.NANO(Units.SECOND)));
|
||||||
|
|
||||||
boolean enabled = loadpoint.getEnabled();
|
boolean enabled = loadpoint.getEnabled();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_ENABLED);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_ENABLED);
|
||||||
updateState(channel, OnOffType.from(enabled));
|
updateState(channel, OnOffType.from(enabled));
|
||||||
|
|
||||||
boolean hasVehicle = loadpoint.getHasVehicle();
|
boolean hasVehicle = loadpoint.getHasVehicle();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_HAS_VEHICLE);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_HAS_VEHICLE);
|
||||||
updateState(channel, OnOffType.from(hasVehicle));
|
updateState(channel, OnOffType.from(hasVehicle));
|
||||||
|
|
||||||
float maxCurrent = loadpoint.getMaxCurrent();
|
float maxCurrent = loadpoint.getMaxCurrent();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_MAX_CURRENT);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_MAX_CURRENT);
|
||||||
updateState(channel, new QuantityType<>(maxCurrent, Units.AMPERE));
|
updateState(channel, new QuantityType<>(maxCurrent, Units.AMPERE));
|
||||||
|
|
||||||
float minCurrent = loadpoint.getMinCurrent();
|
float minCurrent = loadpoint.getMinCurrent();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_MIN_CURRENT);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_MIN_CURRENT);
|
||||||
updateState(channel, new QuantityType<>(minCurrent, Units.AMPERE));
|
updateState(channel, new QuantityType<>(minCurrent, Units.AMPERE));
|
||||||
|
|
||||||
float minSoC = loadpoint.getMinSoC();
|
float minSoC = loadpoint.getMinSoC();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_MIN_SOC);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_MIN_SOC);
|
||||||
updateState(channel, new QuantityType<>(minSoC, Units.PERCENT));
|
updateState(channel, new QuantityType<>(minSoC, Units.PERCENT));
|
||||||
|
|
||||||
String mode = loadpoint.getMode();
|
String mode = loadpoint.getMode();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_MODE);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_MODE);
|
||||||
updateState(channel, new StringType(mode));
|
updateState(channel, new StringType(mode));
|
||||||
|
|
||||||
int phases = loadpoint.getPhases();
|
int phases = loadpoint.getPhases();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_PHASES);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_PHASES);
|
||||||
updateState(channel, new DecimalType(phases));
|
updateState(channel, new DecimalType(phases));
|
||||||
|
|
||||||
targetSoC = loadpoint.getTargetSoC();
|
targetSoC = loadpoint.getTargetSoC();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_TARGET_SOC);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_TARGET_SOC);
|
||||||
updateState(channel, new QuantityType<>(targetSoC, Units.PERCENT));
|
updateState(channel, new QuantityType<>(targetSoC, Units.PERCENT));
|
||||||
|
|
||||||
String targetTime = loadpoint.getTargetTime();
|
String targetTime = loadpoint.getTargetTime();
|
||||||
if (targetTime == null) {
|
if (targetTime == null) {
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_TARGET_TIME_ENABLED);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_TARGET_TIME_ENABLED);
|
||||||
@ -445,24 +467,31 @@ public class EvccHandler extends BaseThingHandler {
|
|||||||
updateState(channel, OnOffType.ON);
|
updateState(channel, OnOffType.ON);
|
||||||
targetTimeEnabled = true;
|
targetTimeEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String title = loadpoint.getTitle();
|
String title = loadpoint.getTitle();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_TITLE);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_TITLE);
|
||||||
updateState(channel, new StringType(title));
|
updateState(channel, new StringType(title));
|
||||||
|
|
||||||
float vehicleCapacity = loadpoint.getVehicleCapacity();
|
float vehicleCapacity = loadpoint.getVehicleCapacity();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_VEHICLE_CAPACITY);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_VEHICLE_CAPACITY);
|
||||||
updateState(channel, new QuantityType<>(vehicleCapacity, Units.WATT_HOUR));
|
updateState(channel, new QuantityType<>(vehicleCapacity, Units.KILOWATT_HOUR));
|
||||||
|
|
||||||
float vehicleOdometer = loadpoint.getVehicleOdometer();
|
float vehicleOdometer = loadpoint.getVehicleOdometer();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_VEHICLE_ODOMETER);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_VEHICLE_ODOMETER);
|
||||||
updateState(channel, new QuantityType<>(vehicleOdometer, MetricPrefix.KILO(SIUnits.METRE)));
|
updateState(channel, new QuantityType<>(vehicleOdometer, MetricPrefix.KILO(SIUnits.METRE)));
|
||||||
|
|
||||||
boolean vehiclePresent = loadpoint.getVehiclePresent();
|
boolean vehiclePresent = loadpoint.getVehiclePresent();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_VEHICLE_PRESENT);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_VEHICLE_PRESENT);
|
||||||
updateState(channel, OnOffType.from(vehiclePresent));
|
updateState(channel, OnOffType.from(vehiclePresent));
|
||||||
|
|
||||||
float vehicleRange = loadpoint.getVehicleRange();
|
float vehicleRange = loadpoint.getVehicleRange();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_VEHICLE_RANGE);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_VEHICLE_RANGE);
|
||||||
updateState(channel, new QuantityType<>(vehicleRange, MetricPrefix.KILO(SIUnits.METRE)));
|
updateState(channel, new QuantityType<>(vehicleRange, MetricPrefix.KILO(SIUnits.METRE)));
|
||||||
|
|
||||||
float vehicleSoC = loadpoint.getVehicleSoC();
|
float vehicleSoC = loadpoint.getVehicleSoC();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_VEHICLE_SOC);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_VEHICLE_SOC);
|
||||||
updateState(channel, new QuantityType<>(vehicleSoC, Units.PERCENT));
|
updateState(channel, new QuantityType<>(vehicleSoC, Units.PERCENT));
|
||||||
|
|
||||||
String vehicleTitle = loadpoint.getVehicleTitle();
|
String vehicleTitle = loadpoint.getVehicleTitle();
|
||||||
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_VEHICLE_TITLE);
|
channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_VEHICLE_TITLE);
|
||||||
updateState(channel, new StringType(vehicleTitle));
|
updateState(channel, new StringType(vehicleTitle));
|
||||||
|
@ -24,7 +24,7 @@ public class Loadpoint {
|
|||||||
// Data types from https://github.com/evcc-io/evcc/blob/master/api/api.go
|
// Data types from https://github.com/evcc-io/evcc/blob/master/api/api.go
|
||||||
// and from https://docs.evcc.io/docs/reference/configuration/messaging/#msg
|
// and from https://docs.evcc.io/docs/reference/configuration/messaging/#msg
|
||||||
|
|
||||||
@SerializedName("activePhases")
|
@SerializedName("phasesActive")
|
||||||
private int activePhases;
|
private int activePhases;
|
||||||
|
|
||||||
@SerializedName("chargeCurrent")
|
@SerializedName("chargeCurrent")
|
||||||
|
Loading…
Reference in New Issue
Block a user