Skip to content

Commit

Permalink
Added support for battery level SIG telegram.
Browse files Browse the repository at this point in the history
  • Loading branch information
fruggy83 committed Oct 3, 2019
1 parent e98215c commit dbccf3d
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright (c) 2010-2019 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.enocean.internal.eep.Base;

import org.openhab.binding.enocean.internal.eep.EEP;
import org.openhab.binding.enocean.internal.messages.ERP1Message;

/**
*
* @author Daniel Weber - Initial contribution
*/
public abstract class _SIGMessage extends EEP {

public static final byte MID_ENERGY_STATUS = 0x06;

public _SIGMessage() {
super();
}

public _SIGMessage(ERP1Message packet) {
super(packet);
}

@Override
protected int getDataLength() {
if (packet != null) {
return packet.getPayload().length - SenderIdLength - RORGLength - StatusLength;
} else {
return bytes.length;
}
}

@Override
protected boolean validateData(byte[] bytes) {
return true;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Copyright (c) 2010-2019 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.enocean.internal.eep.D0;

import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;

import java.util.function.Function;

import org.eclipse.smarthome.config.core.Configuration;
import org.eclipse.smarthome.core.library.types.QuantityType;
import org.eclipse.smarthome.core.library.unit.SmartHomeUnits;
import org.eclipse.smarthome.core.types.State;
import org.eclipse.smarthome.core.types.UnDefType;
import org.openhab.binding.enocean.internal.eep.Base._SIGMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;

/**
*
* @author Daniel Weber - Initial contribution
*/
public class D0_06 extends _SIGMessage {

public D0_06() {
super();
}

public D0_06(ERP1Message packet) {
super(packet);
}

@Override
public State convertToStateImpl(String channelId, String channelTypeId, Function<String, State> getCurrentStateFunc, Configuration config) {
if (CHANNEL_BATTERY_LEVEL.equals(channelId)) {
return new QuantityType<>(bytes[1] & 0xFF, SmartHomeUnits.PERCENT);
}

return UnDefType.UNDEF;
}

@Override
protected boolean validateData(byte[] bytes) {
return bytes[0] == MID_ENERGY_STATUS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public static EEP buildEEPFromTeachInERP1(ERP1Message msg) {
case Unknown:
case VLD:
case MSC:
case SIG:
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
import org.openhab.binding.enocean.internal.eep.Base.PTM200Message;
import org.openhab.binding.enocean.internal.eep.Base.UTEResponse;
import org.openhab.binding.enocean.internal.eep.Base._4BSTeachInVariation3Response;
import org.openhab.binding.enocean.internal.eep.D0.D0_06;
import org.openhab.binding.enocean.internal.eep.D2_01.D2_01_00;
import org.openhab.binding.enocean.internal.eep.D2_01.D2_01_01;
import org.openhab.binding.enocean.internal.eep.D2_01.D2_01_02;
Expand Down Expand Up @@ -201,6 +202,7 @@ public enum EEPType {

BatteryStatus(RORG._4BS, 0x14, 0x01, false, "ELTAKO", ELTAKOID, A5_14_01_ELTAKO.class, THING_TYPE_CONTACT,
CHANNEL_BATTERY_VOLTAGE, CHANNEL_ENERGY_STORAGE),
SigBatteryStatus(RORG.SIG, 0x06, 0x00, false, D0_06.class, null, CHANNEL_BATTERY_LEVEL),

TemperatureSensor_A5_02_01(RORG._4BS, 0x02, 0x01, false, A5_02_01.class, THING_TYPE_TEMPERATURESENSOR,
CHANNEL_TEMPERATURE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public enum RORG {
VLD((byte) 0xD2, -1),
// ADT(0xA6, -1),
UTE((byte) 0xD4, -1),
MSC((byte) 0xD1, -1);
MSC((byte) 0xD1, -1),
SIG((byte) 0xD0, -1);

private byte value;
private int dataLength;
Expand Down Expand Up @@ -109,6 +110,10 @@ public ERP1Message(int dataLength, int optionalDataLength, byte[] payload) {
senderId = Arrays.copyOfRange(payload, dataLength - 5, dataLength - 1);
}
break;
case SIG:
teachIn = false;
senderId = Arrays.copyOfRange(payload, dataLength - 5, dataLength - 1);
break;
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/ESH-INF/thing/Contact.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<option value="A5_14_01">A5-14-01 Single input contact, supply voltage monitor</option>
<option value="A5_14_01_ELTAKO">Eltako battery status</option>
<option value="F6_10_00_EltakoFPE">F6-10-00 Eltako FPE-X</option>
<option value="D0_06_00">D0-06 signal message for battery status</option>
</options>
<default>D5_00_01</default>
<multipleLimit>2</multipleLimit>
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/ESH-INF/thing/LightSensor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
<description>EnOceanId of device this thing belongs to</description>
<required>true</required>
</parameter>
<parameter name="receivingEEPId" type="text">
<parameter name="receivingEEPId" type="text" multiple="true">
<label>EEP</label>
<description>EEP which is used by sensor</description>
<options>
<option value="A5_06_01">A5-06-01</option>
<option value="A5_06_01_ELTAKO">A5-06-01 ELTAKO</option>
<option value="D0_06_00">D0-06 signal message for battery status</option>
</options>
<multipleLimit>2</multipleLimit>
<limitToOptions>true</limitToOptions>
<required>true</required>
</parameter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
<description>EnOceanId of device this thing belongs to</description>
<required>true</required>
</parameter>
<parameter name="receivingEEPId" type="text">
<parameter name="receivingEEPId" type="text" multiple="true">
<label>EEP</label>
<description>EEP which is used by sensor</description>
<options>
<option value="A5_08_01">A5-08-01 temperature range [0;51], lux range [0;510]</option>
<option value="A5_08_02">A5-08-02 temperature range [0;51], lux range [0;1020]</option>
<option value="A5_08_03">A5-08-03 temperature range [-30;50], lux range [0;1530]</option>
<option value="A5_08_01_FXBH">Eltako FxBH lux range [0;2048]</option>
<option value="D0_06_00">D0-06 signal message for battery status</option>
</options>
<multipleLimit>2</multipleLimit>
<limitToOptions>true</limitToOptions>
<required>true</required>
</parameter>
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/ESH-INF/thing/MechanicalHandle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@
<description>EnOceanId of device this thing belongs to</description>
<required>true</required>
</parameter>
<parameter name="receivingEEPId" type="text">
<parameter name="receivingEEPId" type="text" multiple="true">
<label>EEP</label>
<description>EEP which is used by handle</description>
<options>
<option value="F6_10_00">F6-10-00</option>
<option value="F6_10_01">F6-10-01</option>
<option value="A5_14_09">A5-14-09</option>
<option value="A5_14_0A">A5-14-0A</option>
<option value="D0_06_00">D0-06 signal message for battery status</option>
</options>
<multipleLimit>2</multipleLimit>
<limitToOptions>true</limitToOptions>
<required>true</required>
</parameter>
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/ESH-INF/thing/OccupancySensor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@
<description>EnOceanId of device this thing belongs to</description>
<required>true</required>
</parameter>
<parameter name="receivingEEPId" type="text">
<parameter name="receivingEEPId" type="text" multiple="true">
<label>EEP</label>
<description>EEP which is used by sensor</description>
<options>
<option value="A5_07_01">A5-07-01 battery voltage (optional)</option>
<option value="A5_07_02">A5-07-02 battery voltage</option>
<option value="A5_07_03">A5-07-03 battery voltage, lux range [0;1000]</option>
<option value="D0_06_00">D0-06 signal message for battery status</option>
</options>
<multipleLimit>2</multipleLimit>
<limitToOptions>true</limitToOptions>
<required>true</required>
</parameter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
<description>EnOceanId of device this thing belongs to</description>
<required>true</required>
</parameter>
<parameter name="receivingEEPId" type="text">
<parameter name="receivingEEPId" type="text" multiple="true">
<label>EEP</label>
<description>EEP which is used by sensor</description>
<options>
<option value="A5_04_01">A5-04-01 temperature sensor range [0;40]</option>
<option value="A5_04_02">A5-04-02 temperature sensor range [-20;60]</option>
<option value="A5_04_02_ELTAKO">A5-04-02 temperature sensor range [-20;60] with battery indicator</option>
<option value="A5_04_03">A5-04-03 temperature sensor range (10 bit) [-20;60]</option>
<option value="D0_06_00">D0-06 signal message for battery status</option>
</options>
<multipleLimit>2</multipleLimit>
<limitToOptions>true</limitToOptions>
<required>true</required>
</parameter>
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/ESH-INF/thing/TemperatureSensor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<description>EnOceanId of device this thing belongs to</description>
<required>true</required>
</parameter>
<parameter name="receivingEEPId" type="text">
<parameter name="receivingEEPId" type="text" multiple="true">
<label>EEP</label>
<description>EEP which is used by panel</description>
<options>
Expand Down Expand Up @@ -47,7 +47,9 @@
<option value="A5_02_1B">A5-02-1B temperature sensor range [50;130]</option>
<option value="A5_02_20">A5-02-20 temperature sensor range [-10;41.2]</option>
<option value="A5_02_30">A5-02-30 temperature sensor range [-40;62.3]</option>
<option value="D0_06_00">D0-06 signal message for battery status</option>
</options>
<multipleLimit>2</multipleLimit>
<limitToOptions>true</limitToOptions>
<required>true</required>
</parameter>
Expand Down

0 comments on commit dbccf3d

Please sign in to comment.