forked from J-N-K/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial D2_06_20 EEP Implementation.
Signed-off-by: Thomas Lauterbach <[email protected]>
- Loading branch information
Thomas Lauterbach
committed
Jul 6, 2021
1 parent
89f2da1
commit df6d002
Showing
7 changed files
with
192 additions
and
4 deletions.
There are no files selected for viewing
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
104 changes: 104 additions & 0 deletions
104
...inding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_06/D2_06_50.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,104 @@ | ||
/** | ||
* Copyright (c) 2010-2021 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.D2_06; | ||
|
||
import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*; | ||
|
||
import java.util.function.Function; | ||
|
||
import org.openhab.binding.enocean.internal.eep.Base._VLDMessage; | ||
import org.openhab.binding.enocean.internal.messages.ERP1Message; | ||
import org.openhab.core.config.core.Configuration; | ||
import org.openhab.core.library.types.DecimalType; | ||
import org.openhab.core.library.types.OnOffType; | ||
import org.openhab.core.library.types.StringType; | ||
import org.openhab.core.types.State; | ||
import org.openhab.core.types.UnDefType; | ||
|
||
/** | ||
* | ||
* @author Thomas Lauterbach - Initial contribution | ||
*/ | ||
public class D2_06_50 extends _VLDMessage { | ||
|
||
public D2_06_50() { | ||
super(); | ||
} | ||
|
||
public D2_06_50(ERP1Message packet) { | ||
super(packet); | ||
} | ||
|
||
protected State getWindowSashState() { | ||
int sashState = bytes[1] & 127; | ||
if (sashState == 0) { | ||
return UnDefType.UNDEF; | ||
} | ||
if (sashState < 4) { | ||
return new StringType("CLOSED"); | ||
} else if (sashState < 7) { | ||
return new StringType("OPEN"); | ||
} else if (sashState < 10) { | ||
return new StringType("TILTED"); | ||
} | ||
|
||
return UnDefType.UNDEF; | ||
} | ||
|
||
protected State getWindowHandleState() { | ||
int handleState = bytes[1] & 127; | ||
if (handleState == 1 || handleState == 4 || handleState == 7) { | ||
return new StringType("CLOSED"); | ||
} else if (handleState == 2 || handleState == 5 || handleState == 8) { | ||
return new StringType("OPEN"); | ||
} else if (handleState == 3 || handleState == 6 || handleState == 9) { | ||
return new StringType("TILTED"); | ||
} | ||
|
||
return UnDefType.UNDEF; | ||
} | ||
|
||
@Override | ||
protected String convertToEventImpl(String channelId, String channelTypeId, String lastEvent, | ||
Configuration config) { | ||
if (bytes[0] == 2) { | ||
switch (channelId) { | ||
case CHANNEL_WINDOWBREACHEVENT: | ||
if (bytes[1] == 1) { | ||
return "ALARM"; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public State convertToStateImpl(String channelId, String channelTypeId, Function<String, State> getCurrentStateFunc, | ||
Configuration config) { | ||
|
||
if (bytes[0] == 1) { | ||
switch (channelId) { | ||
case CHANNEL_WINDOWSASHSTATE: | ||
return getWindowSashState(); | ||
case CHANNEL_WINDOWHANDLESTATE: | ||
return getWindowHandleState(); | ||
case CHANNEL_BATTERY_LEVEL: | ||
return new DecimalType(bytes[6] & 127); | ||
case CHANNEL_BATTERYLOW: | ||
return getBit(bytes[6], 7) ? OnOffType.ON : OnOffType.OFF; | ||
} | ||
} | ||
|
||
return UnDefType.UNDEF; | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
...es/org.openhab.binding.enocean/src/main/resources/OH-INF/thing/WindowSashHandleSensor.xml
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,37 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<thing:thing-descriptions bindingId="enocean" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0" | ||
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> | ||
|
||
<!-- WindowSashHandleSensor --> | ||
<thing-type id="windowSashHandleSensor"> | ||
<supported-bridge-type-refs> | ||
<bridge-type-ref id="bridge"/> | ||
</supported-bridge-type-refs> | ||
|
||
<label>Window Sash and Handle Sensor</label> | ||
<description>Combined sensor for window/door sash state and handle state</description> | ||
|
||
<config-description> | ||
<parameter name="enoceanId" type="text" required="true"> | ||
<label>EnOceanId</label> | ||
<description>EnOceanId of device this thing belongs to</description> | ||
</parameter> | ||
<parameter name="receivingEEPId" type="text" required="true"> | ||
<label>EEP</label> | ||
<description>EEP which is used by handle</description> | ||
<options> | ||
<option value="D2_06_50">D2_06_50 (Siegenia Senso Secure)</option> | ||
</options> | ||
<limitToOptions>true</limitToOptions> | ||
</parameter> | ||
<parameter name="receivingSIGEEP" type="boolean"> | ||
<label>Receive Battery Status Signal Messages</label> | ||
<default>false</default> | ||
</parameter> | ||
</config-description> | ||
|
||
</thing-type> | ||
|
||
</thing:thing-descriptions> |
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