Skip to content

Commit

Permalink
[enocean] Added support for Heat Recovery Ventilation devices (#9465)
Browse files Browse the repository at this point in the history
 * code refactoring (JAVA11 improvements)

Fixes #9465

Signed-off-by: Daniel Weber <[email protected]>
  • Loading branch information
fruggy83 committed Jan 29, 2021
1 parent ff3a31e commit e2561d5
Show file tree
Hide file tree
Showing 6 changed files with 352 additions and 315 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -112,31 +112,31 @@ protected State convertToStateImpl(String channelId, String channelTypeId,
case CHANNEL_VENTILATIONOPERATIONMODE:
return new StringType(String.valueOf(bytes[0] & 0x0f));
case CHANNEL_FIREPLACESAFETYMODE:
return getBit(bytes[1], 3) ? OnOffType.ON : OnOffType.OFF;
return OnOffType.from(getBit(bytes[1], 3));
case CHANNEL_HEATEXCHANGERBYPASSSTATUS:
return getBit(bytes[1], 2) ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
case CHANNEL_SUPPLYAIRFLAPSTATUS:
return getBit(bytes[1], 1) ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
case CHANNEL_EXHAUSTAIRFLAPSTATUS:
return getBit(bytes[1], 0) ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
case CHANNEL_DEFROSTMODE:
return getBit(bytes[2], 7) ? OnOffType.ON : OnOffType.OFF;
return OnOffType.from(getBit(bytes[2], 7));
case CHANNEL_COOLINGPROTECTIONMODE:
return getBit(bytes[2], 6) ? OnOffType.ON : OnOffType.OFF;
return OnOffType.from(getBit(bytes[2], 6));
case CHANNEL_OUTDOORAIRHEATERSTATUS:
return getBit(bytes[2], 5) ? OnOffType.ON : OnOffType.OFF;
return OnOffType.from(getBit(bytes[2], 5));
case CHANNEL_SUPPLYAIRHEATERSTATUS:
return getBit(bytes[2], 4) ? OnOffType.ON : OnOffType.OFF;
return OnOffType.from(getBit(bytes[2], 4));
case CHANNEL_DRAINHEATERSTATUS:
return getBit(bytes[2], 3) ? OnOffType.ON : OnOffType.OFF;
return OnOffType.from(getBit(bytes[2], 3));
case CHANNEL_TIMEROPERATIONMODE:
return getBit(bytes[2], 2) ? OnOffType.ON : OnOffType.OFF;
return OnOffType.from(getBit(bytes[2], 2));
case CHANNEL_MAINTENANCESTATUS:
return getBit(bytes[2], 1) ? OnOffType.ON : OnOffType.OFF;
return OnOffType.from(getBit(bytes[2], 1));
case CHANNEL_WEEKLYTIMERPROGRAMSTATUS:
return getBit(bytes[2], 0) ? OnOffType.ON : OnOffType.OFF;
return OnOffType.from(getBit(bytes[2], 0));
case CHANNEL_ROOMTEMPERATURECONTROLSTATUS:
return getBit(bytes[3], 7) ? OnOffType.ON : OnOffType.OFF;
return OnOffType.from(getBit(bytes[3], 7));
case CHANNEL_AIRQUALITYVALUE1:
return new QuantityType<>((bytes[3] & 0x7f), Units.PERCENT);
case CHANNEL_AIRQUALITYVALUE2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@

import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -50,9 +48,9 @@
public class EnOceanBaseActuatorHandler extends EnOceanBaseSensorHandler {

// List of thing types which support sending of eep messages
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = new HashSet<>(
Arrays.asList(THING_TYPE_CENTRALCOMMAND, THING_TYPE_MEASUREMENTSWITCH, THING_TYPE_GENERICTHING,
THING_TYPE_ROLLERSHUTTER, THING_TYPE_THERMOSTAT, THING_TYPE_HEATRECOVERYVENTILATION));
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_CENTRALCOMMAND,
THING_TYPE_MEASUREMENTSWITCH, THING_TYPE_GENERICTHING, THING_TYPE_ROLLERSHUTTER, THING_TYPE_THERMOSTAT,
THING_TYPE_HEATRECOVERYVENTILATION);

protected byte[] senderId; // base id of bridge + senderIdOffset, used for sending msg
protected byte[] destinationId; // in case of broadcast FFFFFFFF otherwise the enocean id of the device
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@

import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Set;
import java.util.function.Predicate;
Expand Down Expand Up @@ -51,12 +49,11 @@
public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements PacketListener {

// List of all thing types which support receiving of eep messages
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = new HashSet<>(
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_MULTFUNCTIONSMOKEDETECTOR));
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(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_MULTFUNCTIONSMOKEDETECTOR);

protected final Hashtable<RORG, EEPType> receivingEEPTypes = new Hashtable<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.concurrent.ScheduledFuture;
Expand Down Expand Up @@ -70,7 +68,7 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T

private Logger logger = LoggerFactory.getLogger(EnOceanBridgeHandler.class);

public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = new HashSet<>(Arrays.asList(THING_TYPE_BRIDGE));
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_BRIDGE);

private EnOceanTransceiver transceiver; // holds connection to serial/tcp port and sends/receives messages
private ScheduledFuture<?> connectorTask; // is used for reconnection if something goes wrong
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -56,8 +54,7 @@
public class EnOceanClassicDeviceHandler extends EnOceanBaseActuatorHandler {

// List of thing types which support sending of eep messages
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = new HashSet<>(
Arrays.asList(THING_TYPE_CLASSICDEVICE));
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_CLASSICDEVICE);

private StringType lastTriggerEvent = StringType.valueOf(CommonTriggerEvents.DIR1_PRESSED);
ScheduledFuture<?> releaseFuture = null;
Expand Down

0 comments on commit e2561d5

Please sign in to comment.