-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for battery level SIG telegram.
- Loading branch information
Showing
12 changed files
with
130 additions
and
7 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/main/java/org/openhab/binding/enocean/internal/eep/Base/_SIGMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/org/openhab/binding/enocean/internal/eep/D0/D0_06.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters