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

[goecharger] Changed unit of SESSION_CHARGE_CONSUMPTION / Current_session_charged_energy #10903

Closed
wants to merge 12 commits into from
14 changes: 10 additions & 4 deletions bundles/org.openhab.binding.goecharger/README.md
Expand Up @@ -22,6 +22,7 @@ Currently available channels are
| Channel ID | Item Type | Description |
|--------------------------|--------------------------|---------------------------------------------------------------|
| maxCurrent | Number:ElectricCurrent | Maximum current allowed to use for charging |
| maxCurrTemp | Number:ElectricCurrent | Maximum current temporary (not written to EEPROM) |
| pwmSignal | String | Signal status for PWM signal |
| error | String | Error code of charger |
| voltageL1 | Number:ElectricPotential | Voltage on L1 |
Expand All @@ -33,16 +34,19 @@ Currently available channels are
| powerL1 | Number:Power | Power on L1 |
| powerL2 | Number:Power | Power on L2 |
| powerL3 | Number:Power | Power on L2 |
| powerAll | Number:Power | Power over all three phases |
| phases | Number | Amount of phases currently used for charging |
| sessionChargeEnergyLimit | Number:Energy | Wallbox stops charging after defined value, disable with 0 |
| sessionChargedEnergy | Number:Energy | Amount of energy that has been charged in this session |
| totalChargedEnergy | Number:Energy | Amount of energy that has been charged since installation |
| allowCharging | Switch | If `ON` charging is allowed |
| cableCurrent | Number:ElectricCurrent | Specifies the max current that can be charged with that cable |
| temperature | Number:Temperature | Temperature of the Go-eCharger |
| temptma1 | Number:Temperature | Temperature 1 of the Go-eCharger |
| temptma1 | Number:Temperature | Temperature 2 of the Go-eCharger |
| firmware | String | Firmware Version |
| accessConfiguration | String | Access configuration, for example OPEN, RFID ... |


## Full Example

demo.things
Expand All @@ -55,6 +59,7 @@ demo.items

```
Number:ElectricCurrent GoEChargerMaxCurrent "Maximum current" {channel="goecharger:goe:garage:maxCurrent"}
Number:ElectricCurrent GoEChargerMaxCurrTemp "Maximum current temporary" {channel="goecharger:goe:garage:maxCurrentTemp"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename a bit, this sounds like current temperature, for example MaxCurrentTemporary

String GoEChargerPwmSignal "Pwm signal status" {channel="goecharger:goe:garage:pwmSignal"}
String GoEChargerError "Error code" {channel="goecharger:goe:garage:error"}
Number:ElectricPotential GoEChargerVoltageL1 "Voltage l1" {channel="goecharger:goe:garage:voltageL1"}
Expand All @@ -66,17 +71,18 @@ Number:ElectricCurrent GoEChargerCurrentL3 "Current l3"
Number:Power GoEChargerPowerL1 "Power l1" {channel="goecharger:goe:garage:powerL1"}
Number:Power GoEChargerPowerL2 "Power l2" {channel="goecharger:goe:garage:powerL2"}
Number:Power GoEChargerPowerL3 "Power l3" {channel="goecharger:goe:garage:powerL3"}
Number:Power GoEChargerPowerAll "Power over all" {channel="goecharger:goe:garage:powerAll"}
Number GoEChargerPhases "Phases" {channel="goecharger:goe:garage:phases"}
Number:Energy GoEChargerSessionChargeEnergyLimit "Current session charge energy limit" {channel="goecharger:goe:garage:sessionChargeEnergyLimit"}
Number:Energy GoEChargerSessionChargedEnergy "Current session charged energy" {channel="goecharger:goe:garage:sessionChargedEnergy"}
Number:Energy GoEChargerTotalChargedEnergy "Total charged energy" {channel="goecharger:goe:garage:totalChargedEnergy"}
Switch GoEChargerAllowCharging "Allow charging" {channel="goecharger:goe:garage:allowCharging"}
Number:ElectricCurrent GoEChargerCableCurrent "Cable encoding" {channel="goecharger:goe:garage:cableCurrent"}
Number:Temperature GoEChargerTemperature "Temperature" {channel="goecharger:goe:garage:temperature"}
Number:Temperature GoEChargertemptma1 "Temperature_tma1" {channel="goecharger:goe:garage:temptma1"}
Number:Temperature GoEChargertemptma1 "Temperature_tma2" {channel="goecharger:goe:garage:temptma2"}
String GoEChargerFirmware "Firmware" {channel="goecharger:goe:garage:firmware"}
String GoEChargerAccessConfiguration "Access configuration" {channel="goecharger:goe:garage:accessConfiguration"}
```

## Setting charge current of Go-eCharger based on photovoltaik output

You can easily define rules to charge with PV power alone.
Expand All @@ -88,7 +94,7 @@ when
Item availablePVCurrent received update
then
logInfo("Amps available: ", receivedCommand.state)
MaxAmpere.sendCommand(receivedCommand.state)
MaxCurrTemp.sendCommand(receivedCommand.state)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename, sounds like current temperature

end
```
You can also define more advanced rules if you have multiple cars that charge with a different amount of phases.
Expand Down
Binary file not shown.
Expand Up @@ -31,6 +31,7 @@ public class GoEChargerBindingConstants {

// List of all Channel ids
public static final String MAX_CURRENT = "maxCurrent";
public static final String MAX_CURRENT_TEMPORARY = "maxCurrentTemporary";
public static final String ACCESS_CONFIGURATION = "accessConfiguration";
public static final String PWM_SIGNAL = "pwmSignal";
public static final String ERROR = "error";
Expand All @@ -43,15 +44,16 @@ public class GoEChargerBindingConstants {
public static final String POWER_L1 = "powerL1";
public static final String POWER_L2 = "powerL2";
public static final String POWER_L3 = "powerL3";
public static final String POWER_ALL = "powerAll";
public static final String ALLOW_CHARGING = "allowCharging";
public static final String CABLE_ENCODING = "cableCurrent";
public static final String PHASES = "phases";
public static final String TEMPERATURE = "temperature";
public static final String TEMP_TMA1 = "tempTma1";
public static final String TEMP_TMA2 = "tempTma2";
public static final String SESSION_CHARGE_CONSUMPTION = "sessionChargedEnergy";
public static final String SESSION_CHARGE_CONSUMPTION_LIMIT = "sessionChargeEnergyLimit";
public static final String TOTAL_CONSUMPTION = "totalChargedEnergy";
public static final String FIRMWARE = "firmware";

public static final String API_URL = "http://%IP%/status";
public static final String MQTT_URL = "http://%IP%/mqtt?payload=%KEY%=%VALUE%";
}
Expand Up @@ -33,6 +33,9 @@ public class GoEStatusResponseDTO {
@SerializedName("amp")
public Integer maxCurrent;

@SerializedName("amx")
public Integer maxCurrentTemporary;

@SerializedName("nrg")
public Integer[] energy;

Expand All @@ -48,8 +51,8 @@ public class GoEStatusResponseDTO {
@SerializedName("pha")
public Integer phases;

@SerializedName("tmp")
public Integer temperature;
@SerializedName("tma")
public Double[] tempTma;

@SerializedName("dws")
public Long sessionChargeConsumption;
Expand Down
Expand Up @@ -21,14 +21,17 @@
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.ERROR;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.FIRMWARE;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.MAX_CURRENT;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.MAX_CURRENT_TEMPORARY;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.PHASES;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.POWER_ALL;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.POWER_L1;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.POWER_L2;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.POWER_L3;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.PWM_SIGNAL;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.SESSION_CHARGE_CONSUMPTION;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.SESSION_CHARGE_CONSUMPTION_LIMIT;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.TEMPERATURE;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.TEMP_TMA1;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.TEMP_TMA2;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.TOTAL_CONSUMPTION;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.VOLTAGE_L1;
import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.VOLTAGE_L2;
Expand Down Expand Up @@ -108,6 +111,11 @@ private State getValue(String channelId, GoEStatusResponseDTO goeResponse) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.maxCurrent, Units.AMPERE);
case MAX_CURRENT_TEMPORARY:
if (goeResponse.maxCurrentTemporary == null) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.maxCurrentTemporary, Units.AMPERE);
case PWM_SIGNAL:
if (goeResponse.pwmSignal == null) {
return UnDefType.UNDEF;
Expand Down Expand Up @@ -198,11 +206,16 @@ private State getValue(String channelId, GoEStatusResponseDTO goeResponse) {
count++;
}
return new DecimalType(count);
case TEMPERATURE:
if (goeResponse.temperature == null) {
case TEMP_TMA1:
if ((goeResponse.tempTma == null) | (goeResponse.tempTma.length == 0)) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.temperature, SIUnits.CELSIUS);
return new QuantityType<>(goeResponse.tempTma[0], SIUnits.CELSIUS);
case TEMP_TMA2:
if ((goeResponse.tempTma == null) | (goeResponse.tempTma.length <= 1)) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.tempTma[1], SIUnits.CELSIUS);
case SESSION_CHARGE_CONSUMPTION:
if (goeResponse.sessionChargeConsumption == null) {
return UnDefType.UNDEF;
Expand Down Expand Up @@ -272,6 +285,11 @@ private State getValue(String channelId, GoEStatusResponseDTO goeResponse) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[9] * 100, Units.WATT);
case POWER_ALL:
if (goeResponse.energy == null) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[11] * 10, Units.WATT);
}
return UnDefType.UNDEF;
}
Expand All @@ -295,6 +313,14 @@ public void handleCommand(ChannelUID channelUID, Command command) {
value = String.valueOf(((QuantityType<ElectricCurrent>) command).toUnit(Units.AMPERE).intValue());
}
break;
case MAX_CURRENT_TEMPORARY:
key = "amx";
if (command instanceof DecimalType) {
value = String.valueOf(((DecimalType) command).intValue());
} else if (command instanceof QuantityType<?>) {
value = String.valueOf(((QuantityType<ElectricCurrent>) command).toUnit(Units.AMPERE).intValue());
}
break;
case SESSION_CHARGE_CONSUMPTION_LIMIT:
key = "dwo";
if (command instanceof DecimalType) {
Expand Down Expand Up @@ -344,9 +370,7 @@ public void initialize() {
config = getConfigAs(GoEChargerConfiguration.class);
allChannels = getThing().getChannels().stream().map(channel -> channel.getUID().getId())
.collect(Collectors.toList());

updateStatus(ThingStatus.UNKNOWN);

startAutomaticRefresh();
logger.debug("Finished initializing!");
}
Expand All @@ -357,13 +381,10 @@ private String getUrl(String type) {

private void sendData(String key, String value) {
String urlStr = getUrl(GoEChargerBindingConstants.MQTT_URL).replace("%KEY%", key).replace("%VALUE%", value);
logger.debug("POST URL = {}", urlStr);

try {
ContentResponse contentResponse = httpClient.newRequest(urlStr).method(HttpMethod.POST)
ContentResponse contentResponse = httpClient.newRequest(urlStr).method(HttpMethod.GET)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last time i used this i think only post worked, do new firmwares support get now? is this backwards compatible to old hardware?

.timeout(5, TimeUnit.SECONDS).send();
String response = contentResponse.getContentAsString();
logger.debug("POST Response: {}", response);
GoEStatusResponseDTO result = gson.fromJson(response, GoEStatusResponseDTO.class);
updateChannelsAndStatus(result, null);
} catch (InterruptedException | TimeoutException | ExecutionException | JsonSyntaxException e) {
Expand All @@ -384,8 +405,6 @@ private void sendData(String key, String value) {
private GoEStatusResponseDTO getGoEData()
throws InterruptedException, TimeoutException, ExecutionException, JsonSyntaxException {
String urlStr = getUrl(GoEChargerBindingConstants.API_URL);
logger.debug("GET URL = {}", urlStr);

ContentResponse contentResponse = httpClient.newRequest(urlStr).method(HttpMethod.GET)
.timeout(5, TimeUnit.SECONDS).send();

Expand Down
Expand Up @@ -10,6 +10,7 @@

<channels>
<channel id="maxCurrent" typeId="current"/>
<channel id="maxCurrentTemporary" typeId="amx"/>
<channel id="pwmSignal" typeId="pwm"/>
<channel id="error" typeId="err"/>
<channel id="voltageL1" typeId="vl1"/>
Expand All @@ -21,13 +22,15 @@
<channel id="powerL1" typeId="pl1"/>
<channel id="powerL2" typeId="pl2"/>
<channel id="powerL3" typeId="pl3"/>
<channel id="powerAll" typeId="pall"/>
<channel id="phases" typeId="pha"/>
<channel id="sessionChargeEnergyLimit" typeId="scl"/>
<channel id="sessionChargedEnergy" typeId="scs"/>
<channel id="totalChargedEnergy" typeId="eto"/>
<channel id="allowCharging" typeId="alw"/>
<channel id="cableCurrent" typeId="cbl"/>
<channel id="temperature" typeId="tmp"/>
<channel id="tempTma1" typeId="tma1"/>
<channel id="tempTma2" typeId="tma2"/>
<channel id="firmware" typeId="fmw"/>
<channel id="accessConfiguration" typeId="ast"/>
</channels>
Expand Down Expand Up @@ -65,6 +68,12 @@
<description>Maximum current per phase allowed to use for charging</description>
<state pattern="%d %unit%" readOnly="false"/>
</channel-type>
<channel-type id="amx">
<item-type>Number:ElectricCurrent</item-type>
<label>Maximum Current Temporary</label>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<label>Maximum Current Temporary</label>
<label>Maximum Temporary Current</label>

<description>Maximum current per phase not stored in EEPROM</description>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<description>Maximum current per phase not stored in EEPROM</description>
<description>Maximum current per phase. Not stored in EEPROM. Recommended to be used over "ama" when set often, for example during photovoltaic charging.</description>

<state pattern="%d %unit%" readOnly="false"/>
</channel-type>
<channel-type id="pwm">
<item-type>String</item-type>
<label>PWM signal status</label>
Expand Down Expand Up @@ -145,6 +154,12 @@
<description>Power on L3</description>
<state pattern="%.1f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="pall">
<item-type>Number:Power</item-type>
<label>Power All</label>
<description>Power on all phases</description>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<description>Power on all phases</description>
<description>Accumulated power on all phases</description>

<state pattern="%.1f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="pha">
<item-type>Number</item-type>
<label>Phases</label>
Expand Down Expand Up @@ -178,13 +193,19 @@
<channel-type id="cbl">
<item-type>Number:ElectricCurrent</item-type>
<label>Cable Encoding</label>
<description>Specifies the max amps that can be charged with that cable</description>
<description>Specifies the maximal current that can be charged with that cable</description>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="tma1">
<item-type>Number:Temperature</item-type>
<label>Temperature_tma1</label>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this name should be chosen in a human readable format

<description>Temperature (tma1) of the Go-eCharger</description>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="tmp">
<channel-type id="tma2">
<item-type>Number:Temperature</item-type>
<label>Temperature</label>
<description>Temperature of the Go-eCharger</description>
<label>Temperature_tma2</label>
<description>Temperature (tma2) of the Go-eCharger</description>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="fmw">
Expand Down