diff --git a/src/main/java/org/openhab/binding/enocean/internal/eep/Base/_SIGMessage.java b/src/main/java/org/openhab/binding/enocean/internal/eep/Base/_SIGMessage.java new file mode 100644 index 0000000..f27d4eb --- /dev/null +++ b/src/main/java/org/openhab/binding/enocean/internal/eep/Base/_SIGMessage.java @@ -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; + } + +} diff --git a/src/main/java/org/openhab/binding/enocean/internal/eep/D0/D0_06.java b/src/main/java/org/openhab/binding/enocean/internal/eep/D0/D0_06.java new file mode 100644 index 0000000..ea28603 --- /dev/null +++ b/src/main/java/org/openhab/binding/enocean/internal/eep/D0/D0_06.java @@ -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 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; + } +} \ No newline at end of file diff --git a/src/main/java/org/openhab/binding/enocean/internal/eep/EEPFactory.java b/src/main/java/org/openhab/binding/enocean/internal/eep/EEPFactory.java index 1b23d49..2e61bcb 100644 --- a/src/main/java/org/openhab/binding/enocean/internal/eep/EEPFactory.java +++ b/src/main/java/org/openhab/binding/enocean/internal/eep/EEPFactory.java @@ -175,6 +175,7 @@ public static EEP buildEEPFromTeachInERP1(ERP1Message msg) { case Unknown: case VLD: case MSC: + case SIG: return null; } diff --git a/src/main/java/org/openhab/binding/enocean/internal/eep/EEPType.java b/src/main/java/org/openhab/binding/enocean/internal/eep/EEPType.java index b158a44..31e879d 100644 --- a/src/main/java/org/openhab/binding/enocean/internal/eep/EEPType.java +++ b/src/main/java/org/openhab/binding/enocean/internal/eep/EEPType.java @@ -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; @@ -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), diff --git a/src/main/java/org/openhab/binding/enocean/internal/messages/ERP1Message.java b/src/main/java/org/openhab/binding/enocean/internal/messages/ERP1Message.java index afe4ac7..cb83693 100644 --- a/src/main/java/org/openhab/binding/enocean/internal/messages/ERP1Message.java +++ b/src/main/java/org/openhab/binding/enocean/internal/messages/ERP1Message.java @@ -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; @@ -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; } diff --git a/src/main/resources/ESH-INF/thing/Contact.xml b/src/main/resources/ESH-INF/thing/Contact.xml index ad27deb..35f76d3 100644 --- a/src/main/resources/ESH-INF/thing/Contact.xml +++ b/src/main/resources/ESH-INF/thing/Contact.xml @@ -26,6 +26,7 @@ + D5_00_01 2 diff --git a/src/main/resources/ESH-INF/thing/LightSensor.xml b/src/main/resources/ESH-INF/thing/LightSensor.xml index ffe6c26..66e5435 100644 --- a/src/main/resources/ESH-INF/thing/LightSensor.xml +++ b/src/main/resources/ESH-INF/thing/LightSensor.xml @@ -18,13 +18,15 @@ EnOceanId of device this thing belongs to true - + EEP which is used by sensor + + 2 true true diff --git a/src/main/resources/ESH-INF/thing/LightTemperatureOccupancySensor.xml b/src/main/resources/ESH-INF/thing/LightTemperatureOccupancySensor.xml index d8b7513..312191c 100644 --- a/src/main/resources/ESH-INF/thing/LightTemperatureOccupancySensor.xml +++ b/src/main/resources/ESH-INF/thing/LightTemperatureOccupancySensor.xml @@ -18,7 +18,7 @@ EnOceanId of device this thing belongs to true - + EEP which is used by sensor @@ -26,7 +26,9 @@ + + 2 true true diff --git a/src/main/resources/ESH-INF/thing/MechanicalHandle.xml b/src/main/resources/ESH-INF/thing/MechanicalHandle.xml index 1a7a676..9720391 100644 --- a/src/main/resources/ESH-INF/thing/MechanicalHandle.xml +++ b/src/main/resources/ESH-INF/thing/MechanicalHandle.xml @@ -19,7 +19,7 @@ EnOceanId of device this thing belongs to true - + EEP which is used by handle @@ -27,7 +27,9 @@ + + 2 true true diff --git a/src/main/resources/ESH-INF/thing/OccupancySensor.xml b/src/main/resources/ESH-INF/thing/OccupancySensor.xml index b209823..8b10407 100644 --- a/src/main/resources/ESH-INF/thing/OccupancySensor.xml +++ b/src/main/resources/ESH-INF/thing/OccupancySensor.xml @@ -18,14 +18,16 @@ EnOceanId of device this thing belongs to true - + EEP which is used by sensor + + 2 true true diff --git a/src/main/resources/ESH-INF/thing/TemperatureHumiditySensor.xml b/src/main/resources/ESH-INF/thing/TemperatureHumiditySensor.xml index fe27114..8c658d1 100644 --- a/src/main/resources/ESH-INF/thing/TemperatureHumiditySensor.xml +++ b/src/main/resources/ESH-INF/thing/TemperatureHumiditySensor.xml @@ -18,7 +18,7 @@ EnOceanId of device this thing belongs to true - + EEP which is used by sensor @@ -26,7 +26,9 @@ + + 2 true true diff --git a/src/main/resources/ESH-INF/thing/TemperatureSensor.xml b/src/main/resources/ESH-INF/thing/TemperatureSensor.xml index b6165db..be7fe87 100644 --- a/src/main/resources/ESH-INF/thing/TemperatureSensor.xml +++ b/src/main/resources/ESH-INF/thing/TemperatureSensor.xml @@ -18,7 +18,7 @@ EnOceanId of device this thing belongs to true - + EEP which is used by panel @@ -47,7 +47,9 @@ + + 2 true true