Skip to content

Commit

Permalink
Merge branch 'issue71_SmokeDetector'
Browse files Browse the repository at this point in the history
  • Loading branch information
fruggy83 committed Dec 22, 2019
2 parents 80130e6 + 66f0da8 commit 1beb67e
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,25 @@ public class EnOceanBindingConstants {
public final static ThingTypeUID THING_TYPE_AUTOMATEDMETERSENSOR = new ThingTypeUID(BINDING_ID,
"automatedMeterSensor");
public final static ThingTypeUID THING_TYPE_THERMOSTAT = new ThingTypeUID(BINDING_ID, "thermostat");

public final static ThingTypeUID THING_TYPE_OCCUPANCYSENSOR = new ThingTypeUID(BINDING_ID, "occupancySensor");
public final static ThingTypeUID THING_TYPE_LIGHTTEMPERATUREOCCUPANCYSENSOR = new ThingTypeUID(BINDING_ID,
"lightTemperatureOccupancySensor");
public final static ThingTypeUID THING_TYPE_LIGHTSENSOR = new ThingTypeUID(BINDING_ID, "lightSensor");

public final static ThingTypeUID THING_TYPE_ENVIRONMENTALSENSOR = new ThingTypeUID(BINDING_ID,
"environmentalSensor");
public final static ThingTypeUID THING_TYPE_GENERICTHING = new ThingTypeUID(BINDING_ID, "genericThing");
public final static ThingTypeUID THING_TYPE_ROLLERSHUTTER = new ThingTypeUID(BINDING_ID, "rollershutter");
public final static ThingTypeUID THING_TYPE_MULTFUNCTIONSMOKEDETECTOR = new ThingTypeUID(BINDING_ID,
"multiFunctionSmokeDetector");

public static final Set<ThingTypeUID> SUPPORTED_DEVICE_THING_TYPES_UIDS = new HashSet<>(
Arrays.asList(THING_TYPE_PUSHBUTTON, THING_TYPE_ROCKERSWITCH, THING_TYPE_CLASSICDEVICE,
THING_TYPE_CENTRALCOMMAND, THING_TYPE_ROOMOPERATINGPANEL, THING_TYPE_MECHANICALHANDLE,
THING_TYPE_CONTACT, THING_TYPE_MEASUREMENTSWITCH, THING_TYPE_TEMPERATURESENSOR,
THING_TYPE_TEMPERATUREHUMIDITYSENSOR, THING_TYPE_GENERICTHING, THING_TYPE_ROLLERSHUTTER,
THING_TYPE_OCCUPANCYSENSOR, THING_TYPE_LIGHTTEMPERATUREOCCUPANCYSENSOR, THING_TYPE_LIGHTSENSOR,
THING_TYPE_AUTOMATEDMETERSENSOR, THING_TYPE_THERMOSTAT, THING_TYPE_ENVIRONMENTALSENSOR));
THING_TYPE_AUTOMATEDMETERSENSOR, THING_TYPE_THERMOSTAT, THING_TYPE_ENVIRONMENTALSENSOR,
THING_TYPE_MULTFUNCTIONSMOKEDETECTOR));

// List of all Channel Type Ids, these type ids are also used as channel ids during dynamic creation of channels
// this makes it a lot easier as we do not have to manage a type id and an id, drawback long channel names
Expand Down Expand Up @@ -111,6 +112,7 @@ public class EnOceanBindingConstants {
public final static String CHANNEL_RAINSTATUS = "rainStatus";
public final static String CHANNEL_COUNTER = "counter";
public final static String CHANNEL_CURRENTNUMBER = "currentNumber";
public final static String CHANNEL_SMOKDEDETECTION = "smokeDetection";

public final static String CHANNEL_PUSHBUTTON = "pushButton";
public final static String CHANNEL_DOUBLEPRESS = "doublePress";
Expand All @@ -136,6 +138,7 @@ public class EnOceanBindingConstants {
public final static String CHANNEL_BATTERY_VOLTAGE = "batteryVoltage";
public final static String CHANNEL_ENERGY_STORAGE = "energyStorage";
public final static String CHANNEL_BATTERY_LEVEL = "batteryLevel";
public final static String CHANNEL_BATTERYLOW = "batteryLow";

public final static String CHANNEL_AUTOOFF = "autoOFF";
public final static String CHANNEL_DELAYRADIOOFF = "delayRadioOFF";
Expand Down Expand Up @@ -214,6 +217,8 @@ public class EnOceanBindingConstants {
CoreItemFactory.NUMBER));
put(CHANNEL_CURRENTNUMBER, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_CURRENTNUMBER), CoreItemFactory.NUMBER));
put(CHANNEL_SMOKDEDETECTION, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_SMOKDEDETECTION), CoreItemFactory.SWITCH));
put(CHANNEL_SETPOINT, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_SETPOINT), CoreItemFactory.NUMBER));
put(CHANNEL_CONTACT, new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_CONTACT),
Expand All @@ -226,6 +231,8 @@ public class EnOceanBindingConstants {
new ChannelTypeUID(BINDING_ID, CHANNEL_ENERGY_STORAGE), CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + ElectricPotential.class.getSimpleName()));
put(CHANNEL_BATTERY_LEVEL, new EnOceanChannelDescription(DefaultSystemChannelTypeProvider.SYSTEM_CHANNEL_BATTERY_LEVEL.getUID(),
CoreItemFactory.NUMBER));
put(CHANNEL_BATTERYLOW, new EnOceanChannelDescription(DefaultSystemChannelTypeProvider.SYSTEM_CHANNEL_LOW_BATTERY.getUID(),
CoreItemFactory.SWITCH));
put(CHANNEL_TEACHINCMD, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_TEACHINCMD), CoreItemFactory.SWITCH));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
import org.openhab.binding.enocean.internal.eep.F6_01.F6_01_01;
import org.openhab.binding.enocean.internal.eep.F6_02.F6_02_01;
import org.openhab.binding.enocean.internal.eep.F6_02.F6_02_02;
import org.openhab.binding.enocean.internal.eep.F6_05.F6_05_02;
import org.openhab.binding.enocean.internal.eep.F6_10.F6_10_00;
import org.openhab.binding.enocean.internal.eep.F6_10.F6_10_00_EltakoFPE;
import org.openhab.binding.enocean.internal.eep.F6_10.F6_10_01;
Expand Down Expand Up @@ -200,6 +201,8 @@ public enum EEPType {
CHANNEL_CONTACT),
ContactAndSwitch03(RORG.RPS, 0x10, 0x00, false, "EltakoFPE", ELTAKOID, F6_10_00_EltakoFPE.class, THING_TYPE_CONTACT, CHANNEL_CONTACT),

SmokeDetection(RORG.RPS, 0x05, 0x02, false, F6_05_02.class, null, CHANNEL_SMOKDEDETECTION, CHANNEL_BATTERYLOW),

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),
Expand Down
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements
Arrays.asList(THING_TYPE_ROOMOPERATINGPANEL, THING_TYPE_MECHANICALHANDLE, THING_TYPE_CONTACT,
THING_TYPE_TEMPERATURESENSOR, THING_TYPE_TEMPERATUREHUMIDITYSENSOR, THING_TYPE_ROCKERSWITCH,
THING_TYPE_OCCUPANCYSENSOR, THING_TYPE_LIGHTTEMPERATUREOCCUPANCYSENSOR, THING_TYPE_LIGHTSENSOR,
THING_TYPE_PUSHBUTTON, THING_TYPE_AUTOMATEDMETERSENSOR, THING_TYPE_ENVIRONMENTALSENSOR));
THING_TYPE_PUSHBUTTON, THING_TYPE_AUTOMATEDMETERSENSOR, THING_TYPE_ENVIRONMENTALSENSOR,
THING_TYPE_MULTFUNCTIONSMOKEDETECTOR));

protected Hashtable<RORG, EEPType> receivingEEPTypes = null;

Expand Down
34 changes: 34 additions & 0 deletions src/main/resources/ESH-INF/thing/MultiFunctionSmokeDetector.xml
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>
8 changes: 8 additions & 0 deletions src/main/resources/ESH-INF/thing/channels.xml
Original file line number Diff line number Diff line change
Expand Up @@ -464,4 +464,12 @@
<category>thermostat</category>
</channel-type>

<channel-type id="smokeDetection">
<item-type>Switch</item-type>
<label>Smoke Detected</label>
<description>Smoke detection sensor state.</description>
<category>Switch</category>
<state readOnly="true" />
</channel-type>

</thing:thing-descriptions>

0 comments on commit 1beb67e

Please sign in to comment.