Skip to content

Commit 9d45d08

Browse files
sfeilmeierDerMuaaaDerMuaaa
committed
[Edge] Clever-PV / EnerixControl: code cleanup and refactorings
- Breaking changes - RENAME EssDcDischargePower (also its now the actual value and not "powerStorageState") Co-authored-by: DerMuaaa <102706922+Andreas [email protected]> Co-authored-by: Andreas Mur <[email protected]> Reviewed-by: Michael Grill <[email protected]>
1 parent 90fc5fa commit 9d45d08

File tree

15 files changed

+596
-385
lines changed

15 files changed

+596
-385
lines changed

io.openems.common.bridge.http/src/io/openems/common/bridge/http/NetworkEndpointFetcher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public HttpResponse<String> fetchEndpoint(final BridgeHttp.Endpoint endpoint, De
6262
throw new HttpError.ResponseError(status, body);
6363
}
6464
if (mode.equals(DebugMode.DETAILED)) {
65-
this.log.debug("Fetched Endpoint for request: " + endpoint.url() + "\n" //
66-
+ "method: " + endpoint.method().name() + "\n" //
65+
this.log.info("Fetched Endpoint for request: " + "\n" //
66+
+ "endpoint: " + endpoint + "\n" //
6767
+ "result: " + body //
6868
);
6969
}

io.openems.edge.controller.cleverpv/bnd.bnd

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ Bundle-Version: 1.0.0.${tstamp}
55

66
-buildpath: \
77
${buildpath},\
8-
Java-WebSocket,\
9-
com.squareup.okhttp3,\
108
io.openems.common,\
119
io.openems.common.bridge.http,\
1210
io.openems.edge.common,\
1311
io.openems.edge.controller.api,\
14-
io.openems.edge.controller.api.common,\
1512
io.openems.edge.controller.ess.timeofusetariff,\
1613
io.openems.edge.energy.api,\
1714
io.openems.edge.ess.api,\

io.openems.edge.controller.cleverpv/src/io/openems/edge/controller/cleverpv/Config.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.openems.edge.controller.cleverpv;
22

3+
import io.openems.common.types.DebugMode;
34
import org.osgi.service.metatype.annotations.AttributeDefinition;
45
import org.osgi.service.metatype.annotations.AttributeType;
56
import org.osgi.service.metatype.annotations.ObjectClassDefinition;
@@ -21,14 +22,14 @@
2122
@AttributeDefinition(name = "URL", description = "Full API URL. See https://www.clever-pv.com/anleitungen/push-api", type = AttributeType.PASSWORD)
2223
String url();
2324

24-
@AttributeDefinition(name = "Log-Verbosity", description = "The log verbosity.")
25-
LogVerbosity logVerbosity() default LogVerbosity.NONE;
26-
27-
@AttributeDefinition(name = "Read only", description = "Defines that this controller is read only.", required = true)
25+
@AttributeDefinition(name = "Read only", description = "Defines that this controller is read only. This permanently disables remote control via Clever-PV.", required = true)
2826
boolean readOnly() default true;
2927

30-
@AttributeDefinition(name = "Mode", description = "Set the type of mode.")
31-
Mode mode() default Mode.OFF;
28+
@AttributeDefinition(name = "Control Mode", description = "Set the type of control mode.")
29+
ControlMode controlMode() default ControlMode.OFF;
30+
31+
@AttributeDefinition(name = "Debug Mode", description = "Activates the debug mode")
32+
DebugMode debugMode() default DebugMode.OFF;
3233

3334
String webconsole_configurationFactory_nameHint() default "Controller Clever-PV [{id}]";
3435
}
Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,6 @@
11
package io.openems.edge.controller.cleverpv;
22

3-
import io.openems.common.types.OptionsEnum;
4-
5-
public enum ControlMode implements OptionsEnum {
6-
7-
/**
8-
* Unknown state.
9-
*/
10-
UNDEFINED(-1, "Undefined"),
11-
12-
OFF(0, "Off"),
13-
14-
NO_DISCHARGE(1, "No discharge");
15-
16-
private final int value;
17-
private final String name;
18-
19-
ControlMode(int value, String name) {
20-
this.value = value;
21-
this.name = name;
22-
}
23-
24-
@Override
25-
public int getValue() {
26-
return this.value;
27-
}
28-
29-
@Override
30-
public OptionsEnum getUndefined() {
31-
return ControlMode.UNDEFINED;
32-
}
33-
34-
@Override
35-
public String getName() {
36-
return this.name;
37-
}
3+
// User settings in UI
4+
public enum ControlMode {
5+
OFF, REMOTE_CONTROL
386
}

io.openems.edge.controller.cleverpv/src/io/openems/edge/controller/cleverpv/ControllerCleverPv.java

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,32 @@
77
import io.openems.common.channel.AccessMode;
88
import io.openems.common.channel.Level;
99
import io.openems.common.channel.PersistencePriority;
10-
import io.openems.edge.common.channel.Channel;
1110
import io.openems.edge.common.channel.Doc;
12-
import io.openems.edge.common.channel.value.Value;
1311
import io.openems.edge.common.component.OpenemsComponent;
1412
import io.openems.edge.controller.api.Controller;
1513

1614
public interface ControllerCleverPv extends Controller, OpenemsComponent {
1715

18-
enum ChannelId implements io.openems.edge.common.channel.ChannelId {
19-
UNABLE_TO_SEND(Doc.of(Level.WARNING)
20-
.translationKey(ControllerCleverPv.class, "unableToSend")),
16+
public enum ChannelId implements io.openems.edge.common.channel.ChannelId {
17+
UNABLE_TO_SEND(Doc.of(Level.WARNING) //
18+
.translationKey(ControllerCleverPv.class, "unableToSend")), //
2119

22-
CONTROL_MODE(Doc.of(ControlMode.values()) //
23-
.persistencePriority(PersistencePriority.HIGH) //
20+
REMOTE_CONTROL_MODE(Doc.of(RemoteControlMode.values())//
21+
.persistencePriority(PersistencePriority.HIGH)//
2422
.accessMode(AccessMode.READ_ONLY)),
2523

2624
CUMULATED_NO_DISCHARGE_TIME(Doc.of(LONG)//
27-
.unit(CUMULATED_SECONDS) //
25+
.unit(CUMULATED_SECONDS)//
2826
.persistencePriority(HIGH)), //
2927

3028
CUMULATED_INACTIVE_TIME(Doc.of(LONG)//
31-
.unit(CUMULATED_SECONDS) //
32-
.persistencePriority(HIGH)), //
33-
34-
CUMULATED_FORCE_CHARGE_TIME(Doc.of(LONG)//
35-
.unit(CUMULATED_SECONDS) //
29+
.unit(CUMULATED_SECONDS)//
3630
.persistencePriority(HIGH)), //
3731
;
3832

3933
private final Doc doc;
4034

41-
ChannelId(Doc doc) {
35+
private ChannelId(Doc doc) {
4236
this.doc = doc;
4337
}
4438

@@ -47,32 +41,4 @@ public Doc doc() {
4741
return this.doc;
4842
}
4943
}
50-
51-
/**
52-
* Gets the Channel for {@link ChannelId#CONTROL_MODE}.
53-
*
54-
* @return the Channel
55-
*/
56-
default Channel<ControlMode> getControlModeChannel() {
57-
return this.channel(ChannelId.CONTROL_MODE);
58-
}
59-
60-
/**
61-
* Gets the current mode of override. See {@link ChannelId#CONTROL_MODE}.
62-
*
63-
* @return the Channel {@link Value}
64-
*/
65-
default ControlMode getControlMode() {
66-
return this.getControlModeChannel().value().asEnum();
67-
}
68-
69-
/**
70-
* Gets the current mode of control override. See
71-
* {@link ChannelId#CONTROL_MODE}.
72-
*
73-
* @param controlMode the current control mode
74-
*/
75-
default void setControlMode(ControlMode controlMode) {
76-
this.getControlModeChannel().setNextValue(controlMode);
77-
}
7844
}

0 commit comments

Comments
 (0)