Skip to content

Commit

Permalink
refs #81 * Updated A5-10 EEP family (corrected readings, added new ch…
Browse files Browse the repository at this point in the history
…annels)

 * Changed fanSpeedStage channel to type Number and added new options to it
 * Added dayNightModeState channel
  • Loading branch information
fruggy83 committed Jan 17, 2020
1 parent b757ed0 commit e294e0d
Show file tree
Hide file tree
Showing 24 changed files with 224 additions and 76 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ The channels of a thing are determined automatically based on the chosen EEP.
| occupancy | Switch | Occupancy button pressed (ON) or released (OFF) |
| motionDetection | Switch | On=Motion detected, Off=not |
| setPoint | Number | linear set point |
| fanSpeedStage | String | Fan speed: -1 (Auto), 0, 1, 2, 3 |
| fanSpeedStage | Number | Fan speed: -1 (Auto), 0, 1, 2, 3, 4, 5, 6 |
| dimmer | Dimmer | Dimmer value in percent |
| generalSwitch(/A/B) | Switch | Switch something (channel A/B) ON/OFF |
| rollershutter | Rollershutter | Shut time (shutTime) in seconds can be configured |
Expand All @@ -246,6 +246,7 @@ The channels of a thing are determined automatically based on the chosen EEP.
| batteryVoltage | Number:ElectricPotential | Battery voltage for things with battery |
| energyStorage | Number:ElectricPotential | Energy storage, don't know what this means... |
| batterLevel | Number | Battery level in percent |
| dayNightModeState | Number | 0 = Night mode on, 1 = day mode on |
| rssi | Number | Received Signal Strength Indication (dBm) of last received message |
| repeatCount | Number | Number of repeaters involved in the transmission of the telegram |
| lastReceived | DateTime | Date and time the last telegram was received |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public class EnOceanBindingConstants {
public final static String CHANNEL_CURRENTNUMBER = "currentNumber";
public final static String CHANNEL_SMOKDEDETECTION = "smokeDetection";
public final static String CHANNEL_PILOTWIREMODE = "pilotWireMode";
public final static String CHANNEL_DAYNIGHTMODESTATE = "dayNightModeState";

public final static String CHANNEL_PUSHBUTTON = "pushButton";
public final static String CHANNEL_DOUBLEPRESS = "doublePress";
Expand Down Expand Up @@ -195,7 +196,7 @@ public class EnOceanBindingConstants {
put(CHANNEL_HUMIDITY, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_HUMIDITY), CoreItemFactory.NUMBER));
put(CHANNEL_FANSPEEDSTAGE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_FANSPEEDSTAGE), CoreItemFactory.STRING));
new ChannelTypeUID(BINDING_ID, CHANNEL_FANSPEEDSTAGE), CoreItemFactory.NUMBER));
put(CHANNEL_OCCUPANCY, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_OCCUPANCY), CoreItemFactory.SWITCH));
put(CHANNEL_MOTIONDETECTION, new EnOceanChannelDescription(
Expand All @@ -222,6 +223,8 @@ public class EnOceanBindingConstants {
new ChannelTypeUID(BINDING_ID, CHANNEL_SMOKDEDETECTION), CoreItemFactory.SWITCH));
put(CHANNEL_PILOTWIREMODE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_PILOTWIREMODE), CoreItemFactory.NUMBER));
put(CHANNEL_DAYNIGHTMODESTATE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_DAYNIGHTMODESTATE), CoreItemFactory.NUMBER));
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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
import org.eclipse.smarthome.config.core.Configuration;
import org.eclipse.smarthome.core.library.types.DecimalType;
import org.eclipse.smarthome.core.library.types.OnOffType;
import org.eclipse.smarthome.core.library.types.OpenClosedType;
import org.eclipse.smarthome.core.library.types.QuantityType;
import org.eclipse.smarthome.core.library.types.StringType;
import org.eclipse.smarthome.core.library.unit.SIUnits;
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._4BSMessage;
Expand All @@ -37,32 +38,90 @@ public A5_10(ERP1Message packet) {
super(packet);
}

protected int getSetPointValue() {
// this is the default one
return getDB_2Value();
}

protected int getMaxUnscaledValue() {
return 255;
}

protected double getTempScalingFactor() {
return -6.375; // 255/40
}

protected State getTemperature() {
double temp = (getDB_1Value() - getMaxUnscaledValue()) / getTempScalingFactor();
return new QuantityType<>(temp, SIUnits.CELSIUS);
}

protected State getFanSpeedStage() {
if (getDB_3Value() > 209) {
return new DecimalType(-1);
} else if (getDB_3Value() > 189) {
return new DecimalType(0);
} else if (getDB_3Value() > 164) {
return new DecimalType(1);
} else if (getDB_3Value() > 144) {
return new DecimalType(2);
} else {
return new DecimalType(3);
}
}

protected int getIlluminationValue(){
return getDB_3Value();
}

protected State getIllumination() {
return new QuantityType<>(getIlluminationValue() * 4, SmartHomeUnits.LUX);
}

protected double getHumidityValue() {
return getDB_2Value();
}

protected State getSupplyVoltage() {
double voltage = ((double)getDB_3Value()) / 50.0;
return new QuantityType<>(voltage, SmartHomeUnits.VOLT);
}

@Override
protected State convertToStateImpl(String channelId, String channelTypeId, Function<String, State> getCurrentStateFunc, Configuration config) {

switch (channelId) {

case CHANNEL_BATTERY_VOLTAGE:
return getSupplyVoltage();

case CHANNEL_ILLUMINATION:
return getIllumination();

case CHANNEL_FANSPEEDSTAGE:
if (getDB_3Value() > 209) {
return new StringType("-1");
} else if (getDB_3Value() > 189) {
return new StringType("0");
} else if (getDB_3Value() > 164) {
return new StringType("1");
} else if (getDB_3Value() > 144) {
return new StringType("2");
} else {
return new StringType("3");
}
return getFanSpeedStage();

case CHANNEL_SETPOINT:
return new DecimalType(getDB_2Value());
return new DecimalType(getSetPointValue());

case CHANNEL_HUMIDITY:
return new DecimalType(getHumidityValue() / 2.5);

case CHANNEL_TEMPERATURE:
double temp = (getDB_1Value() - 255) / -6.375;
return new QuantityType<>(temp, SIUnits.CELSIUS);
return getTemperature();

case CHANNEL_BATTERYLOW:
return getBit(getDB_0(), 4) ? OnOffType.ON : OnOffType.OFF;

case CHANNEL_OCCUPANCY:
return getBit(getDB_0(), 0) ? OnOffType.OFF : OnOffType.ON;

case CHANNEL_DAYNIGHTMODESTATE:
return new DecimalType(getDB_0Value() & 0x01);

case CHANNEL_CONTACT:
return getBit(getDB_0(), 0) ? OpenClosedType.OPEN : OpenClosedType.CLOSED;

}

return UnDefType.UNDEF;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*/
package org.openhab.binding.enocean.internal.eep.A5_10;

import org.eclipse.smarthome.core.library.types.QuantityType;
import org.eclipse.smarthome.core.library.unit.SIUnits;
import org.eclipse.smarthome.core.types.State;
import org.openhab.binding.enocean.internal.messages.ERP1Message;

/**
Expand All @@ -20,7 +23,20 @@
*/
public class A5_10_10 extends A5_10 {

protected final double tempFactor = 40.0 / 250.0;

public A5_10_10(ERP1Message packet) {
super(packet);
}

@Override
protected int getSetPointValue() {
return getDB_3Value();
}

@Override
protected State getTemperature() {
double temp = (getDB_1Value()) * tempFactor;
return new QuantityType<>(temp, SIUnits.CELSIUS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_11 extends A5_10 {
public class A5_10_11 extends A5_10_10 {

public A5_10_11(ERP1Message packet) {
super(packet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_12 extends A5_10 {
public class A5_10_12 extends A5_10_10 {

public A5_10_12(ERP1Message packet) {
super(packet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_13 extends A5_10 {
public class A5_10_13 extends A5_10_10 {

public A5_10_13(ERP1Message packet) {
super(packet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_14 extends A5_10 {
public class A5_10_14 extends A5_10_10 {

public A5_10_14(ERP1Message packet) {
super(packet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*/
package org.openhab.binding.enocean.internal.eep.A5_10;

import org.eclipse.smarthome.core.library.types.QuantityType;
import org.eclipse.smarthome.core.library.unit.SIUnits;
import org.eclipse.smarthome.core.types.State;
import org.openhab.binding.enocean.internal.messages.ERP1Message;

/**
Expand All @@ -23,4 +26,16 @@ public class A5_10_15 extends A5_10 {
public A5_10_15(ERP1Message packet) {
super(packet);
}

@Override
protected int getSetPointValue() {
return getDB_2Value() >>> 2;
}

@Override
protected State getTemperature() {
int value = ((getDB_2Value() & 0b11) << 8) + getDB_1Value();
double temp = 41.2 - (value * (41.2 + 10.0) / 1023.0);
return new QuantityType<>(temp, SIUnits.CELSIUS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_16 extends A5_10 {
public class A5_10_16 extends A5_10_15 {

public A5_10_16(ERP1Message packet) {
super(packet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_17 extends A5_10 {
public class A5_10_17 extends A5_10_15 {

public A5_10_17(ERP1Message packet) {
super(packet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package org.openhab.binding.enocean.internal.eep.A5_10;

import org.eclipse.smarthome.core.library.types.DecimalType;
import org.eclipse.smarthome.core.types.State;
import org.openhab.binding.enocean.internal.messages.ERP1Message;

/**
Expand All @@ -23,4 +25,19 @@ public class A5_10_18 extends A5_10 {
public A5_10_18(ERP1Message packet) {
super(packet);
}

@Override
protected int getMaxUnscaledValue() {
return 250;
}

@Override
protected double getTempScalingFactor() {
return -6.25; // 250/40
}

@Override
protected State getFanSpeedStage(){
return new DecimalType((getDB_0Value() >>> 4) -1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_19 extends A5_10 {
public class A5_10_19 extends A5_10_18 {

public A5_10_19(ERP1Message packet) {
super(packet);
}

@Override
protected double getHumidityValue() {
return getDB_3Value();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_1A extends A5_10 {
public class A5_10_1A extends A5_10_18 {

public A5_10_1A(ERP1Message packet) {
super(packet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_1B extends A5_10 {
public class A5_10_1B extends A5_10_18 {

public A5_10_1B(ERP1Message packet) {
super(packet);
}

@Override
protected int getIlluminationValue() {
return getDB_2Value();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_1C extends A5_10 {
public class A5_10_1C extends A5_10_18 {

public A5_10_1C(ERP1Message packet) {
super(packet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_1D extends A5_10 {
public class A5_10_1D extends A5_10_18 {

public A5_10_1D(ERP1Message packet) {
super(packet);
}

@Override
protected double getHumidityValue() {
return getDB_3Value();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_1E extends A5_10 {
public class A5_10_1E extends A5_10_1B {

public A5_10_1E(ERP1Message packet) {
super(packet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_20 extends A5_10 {
public class A5_10_20 extends A5_10_10 {

public A5_10_20(ERP1Message packet) {
super(packet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_21 extends A5_10 {
public class A5_10_21 extends A5_10_10 {

public A5_10_21(ERP1Message packet) {
super(packet);
Expand Down
Loading

0 comments on commit e294e0d

Please sign in to comment.