-
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.
Merge branch 'issue71_SmokeDetector'
- Loading branch information
Showing
6 changed files
with
122 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
65 changes: 65 additions & 0 deletions
65
src/main/java/org/openhab/binding/enocean/internal/eep/F6_05/F6_05_02.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,65 @@ | ||
/** | ||
* Copyright (c) 2010-2019 Contributors to the openHAB project | ||
*5 * 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.F6_05; | ||
|
||
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.OnOffType; | ||
import org.eclipse.smarthome.core.types.State; | ||
import org.eclipse.smarthome.core.types.UnDefType; | ||
import org.openhab.binding.enocean.internal.eep.Base._RPSMessage; | ||
import org.openhab.binding.enocean.internal.messages.ERP1Message; | ||
|
||
/** | ||
* | ||
* @author Daniel Weber - Initial contribution | ||
*/ | ||
public class F6_05_02 extends _RPSMessage { | ||
|
||
protected static final byte ALARM_OFF = 0x00; | ||
protected static final byte ALARM_ON = 0x10; | ||
protected static final byte ENERGY_LOW = 0x30; | ||
|
||
public F6_05_02() { | ||
super(); | ||
} | ||
|
||
public F6_05_02(ERP1Message packet) { | ||
super(packet); | ||
} | ||
|
||
@Override | ||
protected State convertToStateImpl(String channelId, String channelTypeId, | ||
Function<String, State> getCurrentStateFunc, Configuration config) { | ||
if (!isValid()) { | ||
return UnDefType.UNDEF; | ||
} | ||
|
||
switch (channelId){ | ||
case CHANNEL_SMOKDEDETECTION: | ||
return bytes[0] == ALARM_OFF ? OnOffType.OFF | ||
: (bytes[0] == ALARM_ON ? OnOffType.ON : UnDefType.UNDEF); | ||
case CHANNEL_BATTERYLOW: | ||
return bytes[0] == ENERGY_LOW ? OnOffType.ON : UnDefType.UNDEF; | ||
} | ||
|
||
return UnDefType.UNDEF; | ||
} | ||
|
||
@Override | ||
protected boolean validateData(byte[] bytes) { | ||
return super.validateData(bytes) && (bytes[0] == ALARM_OFF || bytes[0] == ALARM_ON || bytes[0] == ENERGY_LOW); | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
src/main/resources/ESH-INF/thing/MultiFunctionSmokeDetector.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,34 @@ | ||
<?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"> | ||
|
||
<thing-type id="multiFunctionSmokeDetector"> | ||
<supported-bridge-type-refs> | ||
<bridge-type-ref id="bridge" /> | ||
</supported-bridge-type-refs> | ||
|
||
<label>Multi Function Smoke Detector</label> | ||
<description>Multi Function Sensor like a Smoke Detector (EEP: F6-05, D2-14)</description> | ||
|
||
<config-description> | ||
<parameter name="enoceanId" type="text"> | ||
<label>EnOceanId</label> | ||
<description>EnOceanId of device this thing belongs to</description> | ||
<required>true</required> | ||
</parameter> | ||
<parameter name="receivingEEPId" type="text"> | ||
<label>EEP</label> | ||
<description>EEP which is used by sensor</description> | ||
<options> | ||
<option value="F6_05_02">F6-05-02 smoke detector</option> | ||
</options> | ||
<limitToOptions>true</limitToOptions> | ||
<required>true</required> | ||
</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