Skip to content

Commit

Permalink
[enocean] Improve incoming message handling for Eltako rollershutters (
Browse files Browse the repository at this point in the history
…openhab#5703)

Fixes openhab#5702

Signed-off-by: Daniel Weber <uni@fruggy.de>
Signed-off-by: Maximilian Hess <mail@ne0h.de>
  • Loading branch information
fruggy83 authored and ne0h committed Sep 15, 2019
1 parent 1cba9af commit 99d4fd9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
public class EnOceanChannelRollershutterConfig {

public Integer shutTime;
public int shutTime;

public EnOceanChannelRollershutterConfig() {
shutTime = 255;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,24 @@ protected State convertToStateImpl(String channelId, String channelTypeId,
State currentState = getCurrentStateFunc.apply(channelId);

if (currentState != null) {
int direction = getDB_1() == MoveUp ? -1 : 1;
int duration = ((getDB_3Value() << 8) + getDB_2Value()) / 10; // => Time in DB3 and DB2 is given
// in ms

PercentType current = currentState.as(PercentType.class);
if (config != null && current != null) {
if (config != null) {
EnOceanChannelRollershutterConfig c = config.as(EnOceanChannelRollershutterConfig.class);
if (c.shutTime != -1 && c.shutTime != 0) {
return new PercentType(Math.min(100, (Math.max(0, current.intValue()
+ direction * ((duration * PercentType.HUNDRED.intValue()) / c.shutTime)))));
if (duration == c.shutTime) {
return getDB_1() == MoveUp ? PercentType.ZERO : PercentType.HUNDRED;
} else {
PercentType current = PercentType.ZERO;
if (currentState instanceof PercentType) {
current = currentState.as(PercentType.class);
}

int direction = getDB_1() == MoveUp ? -1 : 1;
if (c.shutTime != -1 && c.shutTime != 0) {
return new PercentType(Math.min(100, (Math.max(0, current.intValue()
+ direction * ((duration * PercentType.HUNDRED.intValue()) / c.shutTime)))));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void espPacketReceived(ESP3Packet packet) {

EEP eep = EEPFactory.buildEEP(receivingEEPType, (ERP1Message) packet);
logger.debug("ESP Packet payload {} for {} received", HexUtils.bytesToHex(packet.getPayload()),
config.enoceanId);
HexUtils.bytesToHex(msg.getSenderId()));

if (eep.isValid()) {
byte[] senderId = msg.getSenderId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<option value="A5_3F_7F_EltakoFSB">Eltako FSB14/61/71</option>
<option value="D2_05_00">D2-05-00 Rollershutter (like SIN-2-RS-01)</option>
<option value="A5_11_03">A5-11-03 Rollershutter status</option>
<option value="F6_00_00">PTM200 Rollershutter status</option>
</options>
<multipleLimit>4</multipleLimit>
<limitToOptions>true</limitToOptions>
Expand Down

0 comments on commit 99d4fd9

Please sign in to comment.