Skip to content

Commit 021a5b0

Browse files
authored
[Edge] Evcs.OpenWB: refactor to use MQTT (OpenEMS#3467)
* [Edge] Migrate OpenWB EVCS from HTTP to MQTT This update transitions the OpenWB EVCS integration from using HTTP API calls to MQTT for communication. The change involves modifying the configuration to use MQTT URI, username, and password instead of IP address and port. It also includes updates to the implementation to subscribe to MQTT topics for receiving data such as power, voltage, and state changes, and to publish commands. This migration improves the reliability and efficiency of the communication with OpenWB devices by leveraging the lightweight MQTT protocol, which is better suited for real-time data exchange in IoT applications. * Handle energyStartSession initialization during charging Initialize energyStartSession when charging has already been started.
1 parent 6e5ebd5 commit 021a5b0

7 files changed

Lines changed: 390 additions & 312 deletions

File tree

io.openems.edge.evcs.openwb/bnd.bnd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Bundle-Version: 1.0.0.${tstamp}
66
-buildpath: \
77
${buildpath},\
88
io.openems.common,\
9+
io.openems.edge.bridge.mqtt,\
910
io.openems.edge.common,\
1011
io.openems.edge.evcs.api,\
1112
io.openems.edge.meter.api,\

io.openems.edge.evcs.openwb/src/io/openems/edge/evcs/openwb/Config.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import org.osgi.service.metatype.annotations.AttributeDefinition;
44
import org.osgi.service.metatype.annotations.ObjectClassDefinition;
55

6+
import io.openems.edge.meter.api.PhaseRotation;
7+
68
@ObjectClassDefinition(//
79
name = "EVCS OpenWB", //
8-
description = "Implements the evcs component for OpenWB Series2 with internal chargepoints via HTTP API")
10+
description = "Implements the EVCS component for OpenWB Series2 with internal chargepoints via MQTT")
911
@interface Config {
1012

1113
@AttributeDefinition(name = "Component-ID", description = "Unique ID of this Component")
@@ -17,15 +19,15 @@
1719
@AttributeDefinition(name = "Is enabled?", description = "Is this Component enabled?")
1820
boolean enabled() default true;
1921

20-
@AttributeDefinition(name = "IP-Address", description = "The IP address of the charging station", required = true)
21-
String ip();
22-
23-
@AttributeDefinition(name = "Port", description = "Port of the charging station")
24-
int port() default 8443;
22+
@AttributeDefinition(name = "MQTT Bridge ID", description = "ID of the MQTT Bridge component (e.g., mqtt0)")
23+
String mqttBridgeId() default "mqtt0";
2524

26-
@AttributeDefinition(name = "Chargepoint", description = "Number of the internal chargepoint")
25+
@AttributeDefinition(name = "Chargepoint", description = "Number of the internal chargepoint (duo_num)")
2726
ChargePoint chargePoint() default ChargePoint.CP0;
2827

28+
@AttributeDefinition(name = "Phase rotation", description = "The way in which the phases are physically rotated.")
29+
PhaseRotation phaseRotation() default PhaseRotation.L1_L2_L3;
30+
2931
String webconsole_configurationFactory_nameHint() default "EVCS OpenWB [{id}]";
3032

31-
}
33+
}
Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,9 @@
11
package io.openems.edge.evcs.openwb;
22

3-
import io.openems.common.channel.Level;
4-
import io.openems.edge.common.channel.Doc;
3+
import io.openems.edge.bridge.mqtt.api.MqttComponent;
54
import io.openems.edge.common.component.OpenemsComponent;
65
import io.openems.edge.evcs.api.Evcs;
76

8-
public interface EvcsOpenWb extends Evcs, OpenemsComponent {
7+
public interface EvcsOpenWb extends Evcs, OpenemsComponent, MqttComponent {
98

10-
public enum ChannelId implements io.openems.edge.common.channel.ChannelId {
11-
/**
12-
* Slave Communication Failed Fault.
13-
*
14-
* <p>
15-
* Indicates a failure in communication with a slave device, which might affect
16-
* system operations.
17-
*
18-
* <ul>
19-
* <li>Interface: ShellyPlug
20-
* <li>Type: State
21-
* </ul>
22-
*/
23-
SLAVE_COMMUNICATION_FAILED(Doc.of(Level.FAULT)//
24-
.text("Communication with slave device failed."));
25-
26-
private final Doc doc;
27-
28-
private ChannelId(Doc doc) {
29-
this.doc = doc;
30-
}
31-
32-
@Override
33-
public Doc doc() {
34-
return this.doc;
35-
}
36-
}
379
}

0 commit comments

Comments
 (0)