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

[Keba] Removed check of firmware version #4987

Merged
merged 2 commits into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/binding/org.openhab.binding.keba/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ All devices support the following channels (non exhaustive):
| Channel Type ID | Item Type | Description | | |
|------------------|-----------|---------------------------------------------------------------------------------------------------|---|---|
| state | Number | This channel indicates the current operational state of the wallbox | | |
| maxpresetcurrent | Number | This channel supports adjusting the maximim current the charging station should deliver to the EV | | |
| maxpresetcurrent | Number | This channel supports adjusting the maximum current the charging station should deliver to the EV | | |
| power | Number | This channel indicates the active power delivered by the charging station | | |
| I1/2/3 | Number | This channel indicates the current for the given phase | | |
| U1/2/3 | Number | This channel indicates the voltage for the given phase | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,38 +100,4 @@ public static KebaSeries getSeries(char text) throws IllegalArgumentException {
throw new IllegalArgumentException("Not a valid series");
}
};

public enum KebaFirmware {
V201M21("2.01m21"),
V22A1("2.2a1"),
V23A2("2.3a2"),
V23A3("2.3a3"),
V25A3("2.5a3"),
V3042A1("3.04.2a1"),
V3062A5("3.06.2a5"),
V3071A1("3.07.1a1"),
V3084("3.08.4");

private final String id;

private KebaFirmware(final String id) {
this.id = id;
}

@Override
public String toString() {
return id;
}

public static KebaFirmware getFirmware(String text) throws IllegalArgumentException {
for (KebaFirmware c : KebaFirmware.values()) {
if (text.contains(c.id)) {
return c;
}
}

throw new IllegalArgumentException("Not a valid firmware");
}

};
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.eclipse.smarthome.core.types.Command;
import org.eclipse.smarthome.core.types.RefreshType;
import org.eclipse.smarthome.core.types.State;
import org.openhab.binding.keba.internal.KebaBindingConstants.KebaFirmware;
import org.openhab.binding.keba.internal.KebaBindingConstants.KebaSeries;
import org.openhab.binding.keba.internal.KebaBindingConstants.KebaType;
import org.slf4j.Logger;
Expand Down Expand Up @@ -83,10 +82,8 @@ public class KeContactHandler extends BaseThingHandler {
private int maxPresetCurrent = 0;
private int maxSystemCurrent = 63000;
private KebaType type;
private KebaFirmware firmware;
private KebaSeries series;

@SuppressWarnings("null")
public KeContactHandler(Thing thing) {
super(thing);
}
Expand All @@ -96,6 +93,13 @@ public void initialize() {
if (getConfig().get(IP_ADDRESS) != null && !getConfig().get(IP_ADDRESS).equals("")) {
transceiver.registerHandler(this);

cache = new ExpiringCacheMap<>(
Math.max((((BigDecimal) getConfig().get(POLLING_REFRESH_INTERVAL)).intValue()) - 5, 0) * 1000);

cache.put(CACHE_REPORT_1, () -> transceiver.send("report 1", getHandler()));
cache.put(CACHE_REPORT_2, () -> transceiver.send("report 2", getHandler()));
cache.put(CACHE_REPORT_3, () -> transceiver.send("report 3", getHandler()));

if (pollingJob == null || pollingJob.isCancelled()) {
try {
pollingJob = scheduler.scheduleWithFixedDelay(pollingRunnable, 0,
Expand All @@ -105,13 +109,6 @@ public void initialize() {
"An exception occurred while scheduling the polling job");
}
}

cache = new ExpiringCacheMap<>(
Math.max((((BigDecimal) getConfig().get(POLLING_REFRESH_INTERVAL)).intValue()) - 5, 0) * 1000);

cache.put(CACHE_REPORT_1, () -> transceiver.send("report 1", getHandler()));
cache.put(CACHE_REPORT_2, () -> transceiver.send("report 2", getHandler()));
cache.put(CACHE_REPORT_3, () -> transceiver.send("report 3", getHandler()));
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"IP address or port number not set");
Expand Down Expand Up @@ -174,12 +171,14 @@ protected Configuration getConfig() {
}
}
}
} catch (InterruptedException | NumberFormatException | IOException e) {
} catch (NumberFormatException | IOException e) {
logger.debug("An exception occurred while polling the KEBA KeContact '{}': {}", getThing().getUID(),
e.getMessage(), e);
Thread.currentThread().interrupt();
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"An exception occurred while while polling the charging station");
} catch (InterruptedException e) {
logger.debug("Polling job has been interrupted for handler of thing '{}'.", getThing().getUID());
}
};

Expand Down Expand Up @@ -220,7 +219,6 @@ protected void onData(ByteBuffer byteBuffer) {
Map<String, String> properties = editProperties();
properties.put(CHANNEL_FIRMWARE, entry.getValue().getAsString());
updateProperties(properties);
firmware = KebaFirmware.getFirmware(entry.getValue().getAsString());
break;
}
case "Plug": {
Expand Down Expand Up @@ -425,7 +423,8 @@ protected void onData(ByteBuffer byteBuffer) {
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
if ((command instanceof RefreshType)) {
scheduler.schedule(pollingRunnable, 0, TimeUnit.SECONDS);
// let's assume we do frequent enough polling and ignore the REFRESH request here
// in order to prevent too many channel state updates
} else {
switch (channelUID.getId()) {
case CHANNEL_MAX_PRESET_CURRENT: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void start() {
selector = Selector.open();

if (transceiverThread == null) {
transceiverThread = new Thread(transceiverRunnable, "ESH-Keba-Transceiver");
transceiverThread = new Thread(transceiverRunnable, "openHAB-Keba-Transceiver");
transceiverThread.start();
}

Expand Down Expand Up @@ -196,7 +196,7 @@ protected ByteBuffer send(String message, KeContactHandler handler) {
logger.trace("{} waiting on handerLock {}", Thread.currentThread().getName(),
handlerLock.toString());
}
handlerLock.wait();
handlerLock.wait(KeContactHandler.REPORT_INTERVAL);
}

return buffers.remove(handler);
Expand Down