diff --git a/bundles/org.openhab.binding.rfxcom/README.md b/bundles/org.openhab.binding.rfxcom/README.md
index 2931b23fb059..172b6c20fca4 100644
--- a/bundles/org.openhab.binding.rfxcom/README.md
+++ b/bundles/org.openhab.binding.rfxcom/README.md
@@ -136,10 +136,15 @@ Bridge rfxcom:tcpbridge:sunflower [ host="sunflower", port=10001 ] {
## Thing Configuration
-Configuration parameters are listed alongside each thing type. Most devices only require a deviceId and
-a subType, but some things require additional configuration. The deviceId is used both when receiving and
-transmitting messages, the subType is mainly used when sending messages, but it can vary between device
-types.
+Available configuration parameters are:
+
+| Applies to | Parameter Label | Parameter ID | Description | Required | Default |
+|------------|-----------------|--------------|----------------------------------------------------------------------|----------|---------|
+| All things | Device ID | deviceId | (Unique) id of the device, for example "100001.1", "B.8" or "286169" | true | |
+| All things | Sub type | subType | Sub type, note that every thing-type has its own sub types | true | |
+| Lighting4 | Pulse | pulse | Pulse length used by the device, only used when sending | false | 350 |
+| Lighting4 | On command ID | onCommandId | Id of the command which should be send to turn the device ON | false | 1 |
+| Lighting4 | Off command ID | offCommandId | Id of the command which should be send to turn the device OFF | false | 4 |
## Channels
@@ -685,27 +690,7 @@ A Lighting2 device
### lighting4 - RFXCOM Lighting4 Actuator
-A Lighting4 device. The specification for the PT2262 protocol includes 3 bytes for data. By
-convention, the first 20 bits of this is used for deviceId, and the last 4 bits is used for
-command, which gives us a total of 16 commands per device.
-
-Depending on your device, you may have only one command, one pair of commands (on/off), or
-any other multiple, for example, a set of 4 sockets with an on/off pair for each and an
-additional pair for "all".
-
-Different device manufactures using this protocol will use different schemes for their
-commands, so to configure a thing using the lighting4 protocol, you must specify at least
-one commandId in the thing configuration. If a device has multiple sets of commands, you
-can configure multiple things with the same device id, but different commandIds.
-
-Some devices will expect a specific pulse length. If required, that can also be specified
-as a thing configuration parameter.
-
-Previously, openHAB would attempt to guess at the meaning of a commandId if it was not
-specified in the thing configuration based on devices seen in the wild. Due to the varying
-nature of devices, this behaviour is deprecated and will be removed in a future openHAB
-version. Until then, commands 1, 3, 5-13 and 15 are considered ON and 0, 2, 4 and 14 are
-considered OFF when the `onCommandId` or `offCommandId` for a device is not specified.
+A Lighting4 device
#### Channels
@@ -724,46 +709,64 @@ considered OFF when the `onCommandId` or `offCommandId` for a device is not spec
* subType - Sub Type
* Specifies device sub type.
- * PT2262 - PT2262
+ * PT2262 - PT2262
* pulse - Pulse length
* Pulse length of the device
* onCommandId - On command
- * Specifies command that represents ON for this device.
+ * Specifies command to be send when ON must be transmitted
+
+ * 0 - OFF (value 0)
+ * 1 - ON (value 1)
+ * 2 - OFF (value 2)
+ * 3 - ON (value 3)
+ * 4 - OFF (value 4)
+ * 5 - ON (value 5)
+ * 6 - value 6
+ * 7 - ON (value 7)
+ * 8 - value 8
+ * 9 - ON (value 9)
+ * 10 - ON (value 10)
+ * 11 - ON (value 11)
+ * 12 - ON (value 12)
+ * 13 - value 13
+ * 14 - OFF (value 14)
+ * 15 - value 15
* offCommandId - Off command
- * Specifies command that represents OFF for this device.
-
-* openCommandId - Open command
- * Specifies command that represents OPEN for this device.
-
-* closedCommandId - Closed command
- * Specifies command that represents CLOSED for this device.
-
-#### Discovering commandId values
+ * Specifies command to be send when OFF must be transmitted
+
+ * 0 - OFF (value 0)
+ * 1 - ON (value 1)
+ * 2 - OFF (value 2)
+ * 3 - ON (value 3)
+ * 4 - OFF (value 4)
+ * 5 - ON (value 5)
+ * 6 - value 6
+ * 7 - ON (value 7)
+ * 8 - value 8
+ * 9 - ON (value 9)
+ * 10 - ON (value 10)
+ * 11 - ON (value 11)
+ * 12 - ON (value 12)
+ * 13 - value 13
+ * 14 - OFF (value 14)
+ * 15 - value 15
-There are a number of ways to detect the commandId values for your device.
+#### Examples
-- You can turn on DEBUG messages for the rfxcom binding by adding the line
- ``
- to your `log4j2.xml`. You will then be able to see the commandId in the log
- file when you trigger the device.
-
-- You can link a Number Item to the commandId channel. The item will be updated with the
- detected commandId when you trigger the device.
-
-- You can use RFXmngr to look at the data from the device. Use the last letter/number
- of the hexadecimal "Code", and convert it from hexadecimal to decimal.
+The support for lighting 4 in RFXCOM is less complete because a lot of different devices use the same chips and can not easily be distinguished.
-#### Examples
+So some extra configuration can be used for fine tuning the behavior of your Lighting4 devices.
+When configuring, three extra fields are available, being the the pulse length, and a separate command id for both on and off.
+If your item is auto-discovered normally the on or off command should be recognized properly.
-For a USB attached RFXCOM on Windows the configuration could look like this (note the `pulse` is optional):
+For a USB attached RFXCOM on Windows the configuration could look like this (note that the `onCommandId`, `offCommandId` and `pulse` are all optional):
```
Bridge rfxcom:bridge:238adf67 [ serialPort="COM4" ] {
- Thing lighting4 17745a [deviceId="17745", subType="PT2262", onCommandId=7, offCommandId=4]
- Thing lighting4 17745b [deviceId="17745", subType="PT2262", onCommandId=10, offCommandId=2]
+ Thing lighting4 17745 [deviceId="17745", subType="PT2262", onCommandId=7, offCommandId=4, pulse=800]
Thing lighting4 motion [deviceId="286169", subType="PT2262", onCommandId=9, pulse=392]
}
```
@@ -771,31 +774,30 @@ Bridge rfxcom:bridge:238adf67 [ serialPort="COM4" ] {
Your items file could look like this:
```
-Number SocketCommandId {channel="rfxcom:lighting4:238adf67:17745a:commandId"}
-Switch SocketA {channel="rfxcom:lighting4:238adf67:17745a:command"}
-Switch SocketB {channel="rfxcom:lighting4:238adf67:17745b:command"}
+Switch Switch {channel="rfxcom:lighting4:238adf67:17745:command"}
+Number SwitchCommandId "Command ID [%d]" {channel="rfxcom:lighting4:238adf67:17745:commandId"}
```
-#### Known commandIds
-
-These are some commandIds from the field that may match your devices.
-
-| Brand | What | Action | Command ID | Source |
-|-------|---------------|-------------|------------|--------|
-| Kerui | Motion Sensor | Motion | 10 | [#3103](https://github.com/openhab/openhab-addons/issues/3103) |
-| Kerui | Door Contact | door open | 14 | [#3103](https://github.com/openhab/openhab-addons/issues/3103) |
-| Kerui | Door Contact | door closed | 7 | [#3103](https://github.com/openhab/openhab-addons/issues/3103) |
-| Kerui | Door Contact | tamper | 11 | [#3103](https://github.com/openhab/openhab-addons/issues/3103) |
-| Energenie | 4 Socket Power Bar | Socket 1 on | 15 | [Community](https://community.openhab.org/t/rfxcom-looking-to-improve-lighting4-call-for-users/123674) |
-| Energenie | 4 Socket Power Bar | Socket 1 off | 14 | [Community](https://community.openhab.org/t/rfxcom-looking-to-improve-lighting4-call-for-users/123674) |
-| Energenie | 4 Socket Power Bar | Socket 2 on | 7 | [Community](https://community.openhab.org/t/rfxcom-looking-to-improve-lighting4-call-for-users/123674) |
-| Energenie | 4 Socket Power Bar | Socket 2 off | 6 | [Community](https://community.openhab.org/t/rfxcom-looking-to-improve-lighting4-call-for-users/123674) |
-| Energenie | 4 Socket Power Bar | Socket 3 on | 11 | [Community](https://community.openhab.org/t/rfxcom-looking-to-improve-lighting4-call-for-users/123674) |
-| Energenie | 4 Socket Power Bar | Socket 3 off | 10 | [Community](https://community.openhab.org/t/rfxcom-looking-to-improve-lighting4-call-for-users/123674) |
-| Energenie | 4 Socket Power Bar | Socket 4 on | 3 | [Community](https://community.openhab.org/t/rfxcom-looking-to-improve-lighting4-call-for-users/123674) |
-| Energenie | 4 Socket Power Bar | Socket 4 off | 2 | [Community](https://community.openhab.org/t/rfxcom-looking-to-improve-lighting4-call-for-users/123674) |
-| Energenie | 4 Socket Power Bar | All on | 13 | [Community](https://community.openhab.org/t/rfxcom-looking-to-improve-lighting4-call-for-users/123674) |
-| Energenie | 4 Socket Power Bar | All off | 12 | [Community](https://community.openhab.org/t/rfxcom-looking-to-improve-lighting4-call-for-users/123674) |
+And if you want random actions on your relay you could for example do like this:
+
+```
+rule "Set random relay variations"
+ when
+ System started or
+ Time cron "/20 * * * * ?"
+ then
+ SwitchCommandId.sendCommand((Math::random * 15.9).intValue)
+end
+```
+
+#### Devices:
+
+| Brand | What | Action | Command ID | Supported | Source |
+|-------|---------------|-------------|------------|-----------|--------|
+| Kerui | Motion Sensor | Motion | 10 | as ON | [#3103](https://github.com/openhab/openhab-addons/issues/3103) |
+| Kerui | Door Contact | door open | 14 | as OFF | [#3103](https://github.com/openhab/openhab-addons/issues/3103) |
+| Kerui | Door Contact | door closed | 7 | as ON | [#3103](https://github.com/openhab/openhab-addons/issues/3103) |
+| Kerui | Door Contact | tamper | 7 | as ON | [#3103](https://github.com/openhab/openhab-addons/issues/3103) |
### lighting5 - RFXCOM Lighting5 Actuator
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/config/RFXComLighting4DeviceConfiguration.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/config/RFXComLighting4DeviceConfiguration.java
index c4d54e591781..f1244edaf05f 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/config/RFXComLighting4DeviceConfiguration.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/config/RFXComLighting4DeviceConfiguration.java
@@ -21,11 +21,7 @@ public class RFXComLighting4DeviceConfiguration extends RFXComGenericDeviceConfi
public static final String PULSE_LABEL = "pulse";
public static final String ON_COMMAND_ID_LABEL = "onCommandId";
public static final String OFF_COMMAND_ID_LABEL = "offCommandId";
- public static final String OPEN_COMMAND_ID_LABEL = "openCommandId";
- public static final String CLOSED_COMMAND_ID_LABEL = "closedCommandId";
public Integer pulse;
public Integer onCommandId;
public Integer offCommandId;
- public Integer openCommandId;
- public Integer closedCommandId;
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/handler/RFXComBridgeHandler.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/handler/RFXComBridgeHandler.java
index 8880881862e4..092ebf436476 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/handler/RFXComBridgeHandler.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/handler/RFXComBridgeHandler.java
@@ -102,10 +102,8 @@ public synchronized void send() throws IOException {
RFXComBaseMessage msg = queue.peek();
try {
+ logger.debug("Transmitting message '{}'", msg);
byte[] data = msg.decodeMessage();
- if (logger.isDebugEnabled()) {
- logger.debug("Transmitting bytes '{}' for message '{}'", HexUtils.bytesToHex(data), msg);
- }
connector.sendMessage(data);
break;
} catch (RFXComException rfxe) {
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/handler/RFXComHandler.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/handler/RFXComHandler.java
index 04a247e86b6a..992015902859 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/handler/RFXComHandler.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/handler/RFXComHandler.java
@@ -95,7 +95,10 @@ public void handleCommand(ChannelUID channelUID, Command command) {
PacketType packetType = RFXComMessageFactoryImpl
.convertPacketType(getThing().getThingTypeUID().getId().toUpperCase());
- RFXComMessage msg = messageFactory.createMessage(packetType, config, channelUID, command);
+ RFXComMessage msg = messageFactory.createMessage(packetType);
+
+ msg.setConfig(config);
+ msg.convertFromState(channelUID.getId(), command);
bridgeHandler.sendMessage(msg);
} catch (RFXComMessageNotImplementedException e) {
@@ -177,9 +180,9 @@ public void onDeviceMessageReceived(ThingUID bridge, RFXComDeviceMessage message
try {
if (config.matchesMessage(message)) {
String receivedId = PACKET_TYPE_THING_TYPE_UID_MAP.get(message.getPacketType()).getId();
+ logger.debug("Received message from bridge: {} message: {}", bridge, message);
+
if (receivedId.equals(getThing().getThingTypeUID().getId())) {
- logger.debug("Message from bridge [{}] matches thing [{}] message: {}", bridge,
- getThing().getUID().toString(), message);
updateStatus(ThingStatus.ONLINE);
for (Channel channel : getThing().getChannels()) {
@@ -191,21 +194,19 @@ public void onDeviceMessageReceived(ThingUID bridge, RFXComDeviceMessage message
case CHANNEL_COMMAND:
case CHANNEL_CHIME_SOUND:
case CHANNEL_MOOD:
- postNullableCommand(uid, message.convertToCommand(channelId, config, this));
+ postNullableCommand(uid, message.convertToCommand(channelId, this));
break;
case CHANNEL_LOW_BATTERY:
updateNullableState(uid,
- isLowBattery(message.convertToState(CHANNEL_BATTERY_LEVEL, config, this)));
+ isLowBattery(message.convertToState(CHANNEL_BATTERY_LEVEL, this)));
break;
default:
- updateNullableState(uid, message.convertToState(channelId, config, this));
+ updateNullableState(uid, message.convertToState(channelId, this));
break;
}
- } catch (RFXComInvalidStateException e) {
- logger.trace("{} not configured for {}", channelId, message);
- } catch (RFXComUnsupportedChannelException e) {
+ } catch (RFXComException e) {
logger.trace("{} does not handle {}", channelId, message);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBBQTemperatureMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBBQTemperatureMessage.java
index f4c27532f92c..99d00360cec9 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBBQTemperatureMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBBQTemperatureMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -126,14 +124,13 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
if (CHANNEL_FOOD_TEMPERATURE.equals(channelId)) {
return new DecimalType(foodTemperature);
} else if (CHANNEL_BBQ_TEMPERATURE.equals(channelId)) {
return new DecimalType(bbqTemperature);
} else {
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBatteryDeviceMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBatteryDeviceMessage.java
index f6f1e5cba157..92eec8e1ba49 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBatteryDeviceMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBatteryDeviceMessage.java
@@ -14,8 +14,6 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.CHANNEL_BATTERY_LEVEL;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
import org.openhab.core.library.types.DecimalType;
@@ -38,14 +36,13 @@ abstract class RFXComBatteryDeviceMessage extends RFXComDeviceMessageImpl
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_BATTERY_LEVEL:
return convertBatteryLevelToSystemWideLevel(batteryLevel);
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBlinds1Message.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBlinds1Message.java
index ed1648568c00..11aa77bdbb32 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBlinds1Message.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBlinds1Message.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -176,12 +174,11 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
if (CHANNEL_COMMAND.equals(channelId)) {
return (command == Commands.CLOSE ? OpenClosedType.CLOSED : OpenClosedType.OPEN);
} else {
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComChimeMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComChimeMessage.java
index 9d56a328a156..7640e56c1573 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComChimeMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComChimeMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.CHANNEL_CHIME_SOUND;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -135,12 +133,11 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
if (CHANNEL_CHIME_SOUND.equals(channelId)) {
return new DecimalType(chimeSound);
} else {
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurrentEnergyMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurrentEnergyMessage.java
index e1535d48a744..44b123636633 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurrentEnergyMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurrentEnergyMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -138,8 +136,7 @@ public byte[] decodeMessage() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_CHANNEL1_AMPS:
return new DecimalType(channel1Amps);
@@ -154,7 +151,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
return new DecimalType(totalUsage);
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurrentMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurrentMessage.java
index e4821229278e..a4184fd3a7ad 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurrentMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurrentMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -127,8 +125,7 @@ public byte[] decodeMessage() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_CHANNEL1_AMPS:
return new DecimalType(channel1Amps);
@@ -140,7 +137,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
return new DecimalType(channel3Amps);
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurtain1Message.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurtain1Message.java
index 4f09b3211380..f5cf61194a56 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurtain1Message.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurtain1Message.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -133,12 +131,11 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
if (channelId.equals(CHANNEL_COMMAND)) {
return (command == Commands.CLOSE ? OpenClosedType.CLOSED : OpenClosedType.OPEN);
} else {
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComDateTimeMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComDateTimeMessage.java
index 7d63b83a9c36..0d77d92685e3 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComDateTimeMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComDateTimeMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.CHANNEL_DATE_TIME;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -124,12 +122,11 @@ public byte[] decodeMessage() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
if (channelId.equals(CHANNEL_DATE_TIME)) {
return new DateTimeType(dateTime);
} else {
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComDeviceMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComDeviceMessage.java
index 3737f8026cbb..2628834589c9 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComDeviceMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComDeviceMessage.java
@@ -14,7 +14,6 @@
import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -32,27 +31,21 @@ public interface RFXComDeviceMessage extends RFXComMessage {
* Procedure for converting RFXCOM value to openHAB command.
*
* @param channelId id of the channel
- * @param config Configuration of the thing being handled
* @param deviceState
* @return openHAB command.
* @throws RFXComUnsupportedChannelException if the channel is not supported
- * @throws RFXComInvalidStateException if the channel is supported, but the device is not configured for the value
*/
- Command convertToCommand(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException;
+ Command convertToCommand(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException;
/**
* Procedure for converting RFXCOM value to openHAB state.
*
* @param channelId id of the channel
- * @param config configuration of the thing being handled
* @param deviceState
* @return openHAB state.
* @throws RFXComUnsupportedChannelException if the channel is not supported
- * @throws RFXComInvalidStateException if the channel is supported, but the device is not configured for the value
*/
- State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException;
+ State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException;
/**
* Procedure to get device id.
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComDeviceMessageImpl.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComDeviceMessageImpl.java
index 6eadde867d12..ed4de3e361b4 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComDeviceMessageImpl.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComDeviceMessageImpl.java
@@ -17,7 +17,6 @@
import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.config.RFXComGenericDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
@@ -49,14 +48,13 @@ public void setConfig(RFXComDeviceConfiguration config) throws RFXComException {
}
@Override
- public Command convertToCommand(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
- return (Command) convertToState(channelId, config, deviceState);
+ public Command convertToCommand(String channelId, DeviceState deviceState)
+ throws RFXComUnsupportedChannelException {
+ return (Command) convertToState(channelId, deviceState);
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_SIGNAL_LEVEL:
return convertSignalLevelToSystemWideLevel(signalLevel);
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComEnergyMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComEnergyMessage.java
index c679e018122b..be24d3c4c828 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComEnergyMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComEnergyMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -147,8 +145,7 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_INSTANT_POWER:
return new DecimalType(instantPower);
@@ -163,7 +160,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
return new DecimalType(totalAmpHour);
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanMessage.java
index 5931d37aaf2c..feecca897992 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanMessage.java
@@ -21,9 +21,7 @@
import java.util.List;
import org.eclipse.jdt.annotation.Nullable;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -265,8 +263,7 @@ public SubType convertSubType(String subType) throws RFXComUnsupportedValueExcep
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_FAN_LIGHT:
return handleLightChannel();
@@ -281,7 +278,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
return handleCommandStringChannel();
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComHomeConfortMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComHomeConfortMessage.java
index a20b19d639e4..a5e289f1468e 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComHomeConfortMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComHomeConfortMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.CHANNEL_COMMAND;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -127,12 +125,11 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
if (channelId.equals(CHANNEL_COMMAND)) {
return (command == Commands.OFF || command == Commands.GROUP_OFF ? OnOffType.OFF : OnOffType.ON);
} else {
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComHumidityMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComHumidityMessage.java
index ba5fa8e544cc..be7435fafd80 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComHumidityMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComHumidityMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -131,8 +129,7 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_HUMIDITY:
return new DecimalType(humidity);
@@ -141,7 +138,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
return new StringType(humidityStatus.toString());
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComInterfaceMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComInterfaceMessage.java
index 1f83bd69b767..d225a8a595ec 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComInterfaceMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComInterfaceMessage.java
@@ -271,7 +271,7 @@ private void encodeResponseMessage(byte[] data) throws RFXComException {
transceiverType = TransceiverType._UNKNOWN;
logger.warn(
"The transceiver type reported ({}) isn't known to the RFXCom binding. Please raise an issue at https://github.com/openhab/openhab-addons/ to have it included.",
- Byte.toUnsignedInt(data[5]));
+ data[5]);
}
hardwareVersion1 = data[11];
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting1Message.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting1Message.java
index 2a42d9e81945..bdd6fa6f5071 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting1Message.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting1Message.java
@@ -14,9 +14,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -128,11 +126,11 @@ public void encodeMessage(byte[] data) throws RFXComException {
// the message unless the last X ON they saw was for them. So we
// redirect an incoming broadcast DIM/BRIGHT to the correct item
// based on the last X we saw or sent.
- unitCode = lastUnit[houseCode - 'A'];
+ unitCode = lastUnit[(int) houseCode - (int) 'A'];
} else {
unitCode = data[5];
if (command == Commands.ON) {
- lastUnit[houseCode - 'A'] = unitCode;
+ lastUnit[(int) houseCode - (int) 'A'] = unitCode;
}
}
@@ -164,8 +162,8 @@ public String getDeviceId() {
}
@Override
- public Command convertToCommand(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public Command convertToCommand(String channelId, DeviceState deviceState)
+ throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_COMMAND:
switch (command) {
@@ -192,13 +190,11 @@ public Command convertToCommand(String channelId, RFXComDeviceConfiguration conf
}
default:
- return super.convertToCommand(channelId, config, deviceState);
+ return super.convertToCommand(channelId, deviceState);
}
}
- @Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_COMMAND:
switch (command) {
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting2Message.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting2Message.java
index fb584c5c3640..2c84bcbf71b6 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting2Message.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting2Message.java
@@ -20,9 +20,7 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -175,8 +173,7 @@ public static PercentType getPercentTypeFromDimLevel(int value) {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_DIMMING_LEVEL:
return RFXComLighting2Message.getPercentTypeFromDimLevel(dimmingLevel);
@@ -214,7 +211,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
}
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting4Message.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting4Message.java
index 2a74d0e5a4ae..20321f691754 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting4Message.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting4Message.java
@@ -13,17 +13,12 @@
package org.openhab.binding.rfxcom.internal.messages;
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
-import static org.openhab.binding.rfxcom.internal.config.RFXComLighting4DeviceConfiguration.PULSE_LABEL;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
+import static org.openhab.binding.rfxcom.internal.config.RFXComLighting4DeviceConfiguration.*;
+import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.config.RFXComLighting4DeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -33,6 +28,8 @@
import org.openhab.core.library.types.OpenClosedType;
import org.openhab.core.types.State;
import org.openhab.core.types.Type;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* RFXCOM data class for lighting4 message.
@@ -60,10 +57,14 @@
* @author Alessandro Ballini (ITA) - Initial contribution
* @author Pauli Anttila - Migrated to OH2
* @author Martin van Wingerden - Extended support for more complex PT2262 devices
- * @author James Hewitt - Use the thing config to identify what incoming commandIds map to
- * @author James Hewitt - Deprecate using previously discovered commandIds because they are unreliable
*/
public class RFXComLighting4Message extends RFXComDeviceMessageImpl {
+ // this logger is used from a static context, so is static as well
+ private static final Logger LOGGER = LoggerFactory.getLogger(RFXComLighting4Message.class);
+
+ private static final byte DEFAULT_OFF_COMMAND_ID = Commands.OFF_4.toByte();
+ private static final byte DEFAULT_ON_COMMAND_ID = Commands.ON_1.toByte();
+
public enum SubType implements ByteEnumWrapper {
PT2262(0);
@@ -79,21 +80,62 @@ public byte toByte() {
}
}
- // These are historical behaviour, are deprecated, and will be removed in a future openHAB release.
- @Deprecated
- private static final byte DEFAULT_OFF_COMMAND_ID = 4;
- @Deprecated
- private static final byte DEFAULT_ON_COMMAND_ID = 1;
- @Deprecated
- private Set ON_COMMAND_IDS = Stream.of(1, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15)
- .collect(Collectors.toCollection(HashSet::new));
+ public enum Commands implements ByteEnumWrapper {
+ OFF_0(0, false),
+ ON_1(1, true),
+ OFF_2(2, false),
+ ON_3(3, true),
+ OFF_4(4, false),
+ ON_5(5, true),
+ ON_6(6, true),
+ ON_7(7, true),
+ ON_8(8, true),
+ ON_9(9, true),
+ ON_10(10, true),
+ ON_11(11, true),
+ ON_12(12, true),
+ OFF_14(14, false),
+ ON_15(15, true),
+ UNKNOWN(-1, false);
+
+ private final int command;
+ private final boolean on;
+
+ Commands(int command, boolean on) {
+ this.command = command;
+ this.on = on;
+ }
+
+ @Override
+ public byte toByte() {
+ return (byte) command;
+ }
+
+ public boolean isOn() {
+ return on;
+ }
+
+ public static Commands fromByte(int input) {
+ for (Commands c : Commands.values()) {
+ if (c.command == input) {
+ return c;
+ }
+ }
+ LOGGER.info(
+ "A not completely supported command with value {} was received, we can send it but please report "
+ + "it as an issue including what the command means, this helps to extend the binding with better support.",
+ input);
+ return UNKNOWN;
+ }
+ }
private SubType subType;
private int sensorId;
private int pulse;
+ private Commands command;
private int commandId;
-
- private RFXComLighting4DeviceConfiguration config;
+ private int offCommandId;
+ private int onCommandId;
public RFXComLighting4Message() {
super(PacketType.LIGHTING4);
@@ -110,7 +152,7 @@ public String toString() {
str += super.toString();
str += ", Sub type = " + subType;
str += ", Device Id = " + getDeviceId();
- str += ", Command Id = " + commandId;
+ str += ", Command = " + command + "(" + commandId + ")";
str += ", Pulse = " + pulse;
return str;
@@ -120,10 +162,13 @@ public String toString() {
public void encodeMessage(byte[] data) throws RFXComException {
super.encodeMessage(data);
- subType = ByteEnumUtil.fromByte(SubType.class, super.subType);
+ subType = fromByte(SubType.class, super.subType);
sensorId = (data[4] & 0xFF) << 12 | (data[5] & 0xFF) << 4 | (data[6] & 0xF0) >> 4;
commandId = (data[6] & 0x0F);
+ command = Commands.fromByte(commandId);
+ onCommandId = command.isOn() ? commandId : DEFAULT_ON_COMMAND_ID;
+ offCommandId = command.isOn() ? DEFAULT_OFF_COMMAND_ID : commandId;
pulse = (data[7] & 0xFF) << 8 | (data[8] & 0xFF);
@@ -160,45 +205,20 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration configuration, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
- RFXComLighting4DeviceConfiguration config = (RFXComLighting4DeviceConfiguration) configuration;
-
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_COMMAND:
case CHANNEL_MOTION:
- if (config.onCommandId != null && commandId == config.onCommandId) {
- return OnOffType.ON;
- }
- if (config.offCommandId != null && commandId == config.offCommandId) {
- return OnOffType.OFF;
- }
- // Deprecated if statement - to be removed in a future release
- if (config.onCommandId == null && config.offCommandId == null) {
- return ON_COMMAND_IDS.contains(commandId) ? OnOffType.ON : OnOffType.OFF;
- }
- throw new RFXComInvalidStateException(channelId, Integer.toString(commandId),
- "Device not configured for received commandId");
+ return command.isOn() ? OnOffType.ON : OnOffType.OFF;
case CHANNEL_CONTACT:
- if (config.openCommandId != null && commandId == config.openCommandId) {
- return OpenClosedType.OPEN;
- }
- if (config.closedCommandId != null && commandId == config.closedCommandId) {
- return OpenClosedType.CLOSED;
- }
- // Deprecated if statement - to be removed in a future release
- if (config.onCommandId == null && config.offCommandId == null) {
- return ON_COMMAND_IDS.contains(commandId) ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
- }
- throw new RFXComInvalidStateException(channelId, Integer.toString(commandId),
- "Device not configured for received commandId");
+ return command.isOn() ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
case CHANNEL_COMMAND_ID:
return new DecimalType(commandId);
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
@@ -213,70 +233,30 @@ public void setDeviceId(String deviceId) {
}
@Override
- public void convertFromState(String channelId, Type type)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public void convertFromState(String channelId, Type type) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_COMMAND:
if (type instanceof OnOffType) {
- if (type == OnOffType.ON) {
- if (config.onCommandId != null) {
- commandId = config.onCommandId;
- } else {
- // Deprecated - to throw RFXComInvalidStateException in a future release, see contact
- // channel
- commandId = DEFAULT_ON_COMMAND_ID;
- }
- }
- if (type == OnOffType.OFF) {
- if (config.offCommandId != null) {
- commandId = config.offCommandId;
- } else {
- // Deprecated - to throw RFXComInvalidStateException in a future release, see contact
- // channel
- commandId = DEFAULT_OFF_COMMAND_ID;
- }
- }
- } else {
- throw new RFXComInvalidStateException(channelId, type.toString(),
- "Channel only supports OnOffType");
- }
- break;
+ command = Commands.fromByte(type == OnOffType.ON ? onCommandId : offCommandId);
+ commandId = command.toByte();
- case CHANNEL_CONTACT:
- if (type instanceof OpenClosedType) {
- if (type == OpenClosedType.OPEN) {
- if (config.openCommandId != null) {
- commandId = config.openCommandId;
- } else {
- throw new RFXComInvalidStateException(channelId, type.toString(),
- "openCommandId not configured for this device");
- }
- }
- if (type == OpenClosedType.CLOSED) {
- if (config.closedCommandId != null) {
- commandId = config.closedCommandId;
- } else {
- throw new RFXComInvalidStateException(channelId, type.toString(),
- "closedCommandId not configured for this device");
- }
- }
} else {
- throw new RFXComInvalidStateException(channelId, type.toString(),
- "Channel only supports OpenClosedType");
+ throw new RFXComUnsupportedChannelException("Channel " + channelId + " does not accept " + type);
}
break;
case CHANNEL_COMMAND_ID:
if (type instanceof DecimalType) {
- commandId = (byte) ((DecimalType) type).intValue();
+ commandId = ((DecimalType) type).toBigDecimal().byteValue();
+ command = Commands.fromByte(commandId);
+
} else {
- throw new RFXComInvalidStateException(channelId, type.toString(),
- "Channel only supports DecimalType");
+ throw new RFXComUnsupportedChannelException("Channel " + channelId + " does not accept " + type);
}
break;
default:
- throw new RFXComUnsupportedChannelException("Channel " + channelId + " is not supported by Lighting4");
+ throw new RFXComUnsupportedChannelException("Channel " + channelId + " is not relevant here");
}
}
@@ -289,12 +269,23 @@ public SubType convertSubType(String subType) throws RFXComUnsupportedValueExcep
public void addDevicePropertiesTo(DiscoveryResultBuilder discoveryResultBuilder) throws RFXComException {
super.addDevicePropertiesTo(discoveryResultBuilder);
discoveryResultBuilder.withProperty(PULSE_LABEL, pulse);
+ discoveryResultBuilder.withProperty(ON_COMMAND_ID_LABEL, onCommandId);
+ discoveryResultBuilder.withProperty(OFF_COMMAND_ID_LABEL, offCommandId);
}
@Override
public void setConfig(RFXComDeviceConfiguration config) throws RFXComException {
- super.setConfig(config);
- this.config = (RFXComLighting4DeviceConfiguration) config;
- this.pulse = this.config.pulse != null ? this.config.pulse : 350;
+ RFXComLighting4DeviceConfiguration lighting4Config = (RFXComLighting4DeviceConfiguration) config;
+ super.setConfig(lighting4Config);
+ this.pulse = lighting4Config.pulse != null ? lighting4Config.pulse : 350;
+ this.onCommandId = valueOrDefault(lighting4Config.onCommandId, DEFAULT_ON_COMMAND_ID);
+ this.offCommandId = valueOrDefault(lighting4Config.offCommandId, DEFAULT_OFF_COMMAND_ID);
+ }
+
+ private int valueOrDefault(Integer commandId, byte defaultValue) {
+ if (commandId != null) {
+ return commandId;
+ }
+ return defaultValue;
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting5Message.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting5Message.java
index 9cf4e845a998..3602810be1ac 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting5Message.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting5Message.java
@@ -21,9 +21,7 @@
import java.util.Arrays;
import java.util.List;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -236,8 +234,7 @@ public static PercentType getPercentTypeFromDimLevel(int value) {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_MOOD:
switch (command) {
@@ -295,7 +292,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
}
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting6Message.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting6Message.java
index f468367a2f66..ae3508802364 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting6Message.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting6Message.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -136,8 +134,7 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_COMMAND:
switch (command) {
@@ -168,7 +165,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
}
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComMessageFactory.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComMessageFactory.java
index c320e2102283..d555a32f58d3 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComMessageFactory.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComMessageFactory.java
@@ -12,11 +12,8 @@
*/
package org.openhab.binding.rfxcom.internal.messages;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
-import org.openhab.core.thing.ChannelUID;
-import org.openhab.core.types.Command;
/**
* Factory to create RFXCom messages from either bytes delivered by the RFXCom device
@@ -24,11 +21,9 @@
*
* @author Pauli Anttila - Initial contribution
* @author James Hewitt-Thomas - Convert to interface to allow dependency injection
- * @author James Hewitt-Thomas - Switch to making messages for a specific command
*/
public interface RFXComMessageFactory {
- public RFXComMessage createMessage(PacketType packetType, RFXComDeviceConfiguration config, ChannelUID channelUID,
- Command command) throws RFXComException;
+ public RFXComMessage createMessage(PacketType packetType) throws RFXComException;
public RFXComMessage createMessage(byte[] packet) throws RFXComException;
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComMessageFactoryImpl.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComMessageFactoryImpl.java
index b45922dabbba..6098d437c563 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComMessageFactoryImpl.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComMessageFactoryImpl.java
@@ -18,12 +18,9 @@
import java.util.HashMap;
import java.util.Map;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
-import org.openhab.core.thing.ChannelUID;
-import org.openhab.core.types.Command;
/**
* Factory to create RFXCom messages from either bytes delivered by the RFXCom device
@@ -101,17 +98,13 @@ public enum RFXComMessageFactoryImpl implements RFXComMessageFactory {
* Create message for transmission from the packet type associated with the thing.
*/
@Override
- public RFXComMessage createMessage(PacketType packetType, RFXComDeviceConfiguration config, ChannelUID channelUID,
- Command command) throws RFXComException {
+ public RFXComMessage createMessage(PacketType packetType) throws RFXComException {
try {
Class extends RFXComMessage> cl = MESSAGE_CLASSES.get(packetType);
if (cl == null) {
throw new RFXComMessageNotImplementedException("Message " + packetType + " not implemented");
}
- RFXComMessage msg = cl.getDeclaredConstructor().newInstance();
- msg.setConfig(config);
- msg.convertFromState(channelUID.getId(), command);
- return msg;
+ return cl.getDeclaredConstructor().newInstance();
} catch (ReflectiveOperationException e) {
throw new RFXComException(e);
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXSensorMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXSensorMessage.java
index 539f92498f5f..e5af3962a5eb 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXSensorMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXSensorMessage.java
@@ -18,9 +18,7 @@
import java.math.BigDecimal;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -203,8 +201,7 @@ public void setSubType(SubType subType) {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_TEMPERATURE:
return subType == SubType.TEMPERATURE ? getTemperature() : null;
@@ -222,7 +219,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
return subType == SubType.A_D ? handlePressure(deviceState) : null;
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRainMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRainMessage.java
index 58303e741bf0..293f2bc8c936 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRainMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRainMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -137,8 +135,7 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_RAIN_RATE:
return new DecimalType(rainRate);
@@ -147,7 +144,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
return new DecimalType(rainTotal);
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRawMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRawMessage.java
index bf28863ba939..1aa27620be3b 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRawMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRawMessage.java
@@ -142,8 +142,7 @@ public void setConfig(RFXComDeviceConfiguration config) throws RFXComException {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_RAW_MESSAGE:
return new StringType(HexUtils.bytesToHex(rawMessage));
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRfyMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRfyMessage.java
index b185389e698b..d5cf2e19a971 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRfyMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRfyMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -136,14 +134,13 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_COMMAND:
return (command == Commands.DOWN ? OpenClosedType.CLOSED : OpenClosedType.OPEN);
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComSecurity1Message.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComSecurity1Message.java
index 7385770bef21..3e13fd8e2228 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComSecurity1Message.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComSecurity1Message.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -235,8 +233,7 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_MOTION:
switch (status) {
@@ -266,7 +263,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
return new StringType(status.toString());
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComSecurity2Message.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComSecurity2Message.java
index 7f7931e6ff88..3dbb357d62f9 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComSecurity2Message.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComSecurity2Message.java
@@ -17,9 +17,7 @@
import java.util.Arrays;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -117,8 +115,7 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_CONTACT:
return ((buttonStatus & BUTTON_0_BIT) == 0) ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
@@ -133,7 +130,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
return ((buttonStatus & BUTTON_3_BIT) == 0) ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureHumidityBarometricMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureHumidityBarometricMessage.java
index 9c04bf120dd3..349c5cc3fb83 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureHumidityBarometricMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureHumidityBarometricMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -180,8 +178,7 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_TEMPERATURE:
return new DecimalType(temperature);
@@ -199,7 +196,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
return new StringType(forecastStatus.toString());
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureHumidityMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureHumidityMessage.java
index 17f850f8355b..ff3f21dd1b80 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureHumidityMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureHumidityMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -160,8 +158,7 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_TEMPERATURE:
return new DecimalType(temperature);
@@ -173,7 +170,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
return new StringType(humidityStatus.toString());
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureMessage.java
index eb6c113f1553..f57298e3fe11 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.CHANNEL_TEMPERATURE;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -128,14 +126,13 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_TEMPERATURE:
return new DecimalType(temperature);
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureRainMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureRainMessage.java
index b67d25a20bbd..d591a9f05df3 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureRainMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureRainMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -122,8 +120,7 @@ public byte[] decodeMessage() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_TEMPERATURE:
return new DecimalType(temperature);
@@ -132,7 +129,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
return new DecimalType(rainTotal);
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat1Message.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat1Message.java
index c5577e79cf04..eda9c10395a0 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat1Message.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat1Message.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -157,8 +155,7 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_TEMPERATURE:
return new DecimalType(temperature);
@@ -177,7 +174,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
}
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat3Message.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat3Message.java
index 024d8fbbe61b..24e628bb654f 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat3Message.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat3Message.java
@@ -19,9 +19,7 @@
import java.util.Arrays;
import java.util.List;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -154,8 +152,7 @@ public byte[] decodeMessage() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_COMMAND:
switch (command) {
@@ -205,7 +202,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
return command == null ? UnDefType.UNDEF : StringType.valueOf(command.toString());
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComUVMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComUVMessage.java
index f861bd0048da..f64656ee3b38 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComUVMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComUVMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -127,8 +125,7 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_UV:
return new DecimalType(uv);
@@ -137,7 +134,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
return (subType == SubType.UV3 ? new DecimalType(temperature) : UnDefType.UNDEF);
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComUndecodedRFMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComUndecodedRFMessage.java
index 387791ddd41d..456510707913 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComUndecodedRFMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComUndecodedRFMessage.java
@@ -17,7 +17,6 @@
import java.util.Arrays;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageTooLongException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
@@ -141,8 +140,7 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_RAW_MESSAGE:
return new StringType(HexUtils.bytesToHex(rawMessage));
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComWindMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComWindMessage.java
index 75d70974b77b..a0c577ea82a7 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComWindMessage.java
+++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComWindMessage.java
@@ -15,9 +15,7 @@
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
import org.openhab.binding.rfxcom.internal.handler.DeviceState;
@@ -170,8 +168,7 @@ public String getDeviceId() {
}
@Override
- public State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
- throws RFXComUnsupportedChannelException, RFXComInvalidStateException {
+ public State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_WIND_DIRECTION:
return new DecimalType(windDirection);
@@ -189,7 +186,7 @@ public State convertToState(String channelId, RFXComDeviceConfiguration config,
return new DecimalType(chillTemperature);
default:
- return super.convertToState(channelId, config, deviceState);
+ return super.convertToState(channelId, deviceState);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/main/resources/OH-INF/thing/lighting4.xml b/bundles/org.openhab.binding.rfxcom/src/main/resources/OH-INF/thing/lighting4.xml
index 771e7f8fdbed..8bc6d8e8fc6b 100644
--- a/bundles/org.openhab.binding.rfxcom/src/main/resources/OH-INF/thing/lighting4.xml
+++ b/bundles/org.openhab.binding.rfxcom/src/main/resources/OH-INF/thing/lighting4.xml
@@ -38,31 +38,51 @@
Pulse length of the device
350
-
+
- Specifies command that represents ON for this device. If not
- specified, will treat 1, 3, 5-13 and 15 as
- ON commands for receiving message, and will send 1 as an ON
- command. This behaviour is deprecated. In a future
- version, if this is not specified, the on command will
- not be available.
+ Specifies command to be send when ON must be transmitted
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
-
+
- Specifies command that represents OFF for this device. For historical reasons, if not
- specified, will
- treat 0, 2, 4 and 14 as OFF commands for receiving message, and will send 4 as an OFF
- command. This behaviour is
- deprecated. In a future version, if this is not specified, the off command will
- not be available.
-
-
-
- Specifies command that represents OPEN for this device.
-
-
-
- Specifies command that represents CLOSED for this device.
+ Specifies command to be send when OFF must be transmitted
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/RFXComTestHelper.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/RFXComTestHelper.java
deleted file mode 100644
index 9aac7d55db0b..000000000000
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/RFXComTestHelper.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * 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.rfxcom.internal;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.messages.MockDeviceState;
-import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
-import org.openhab.binding.rfxcom.internal.messages.RFXComDeviceMessage;
-import org.openhab.binding.rfxcom.internal.messages.RFXComMessage;
-import org.openhab.core.library.types.DecimalType;
-import org.openhab.core.thing.ChannelUID;
-import org.openhab.core.thing.ThingTypeUID;
-import org.openhab.core.thing.ThingUID;
-
-/**
- * Helper class for testing the RFXCom-binding
- *
- * @author Martin van Wingerden - Initial contribution
- */
-@NonNullByDefault
-public class RFXComTestHelper {
- static final public ThingUID bridgeUID = new ThingUID("rfxcom", "tcpbridge", "rfxtrx0");
- static final public ThingUID thingUID = new ThingUID("rfxcom", bridgeUID, "mocked");
- static final public ThingTypeUID thingTypeUID = new ThingTypeUID("rfxcom", "raw");
-
- static final public ChannelUID commandChannelUID = new ChannelUID(thingUID, RFXComBindingConstants.CHANNEL_COMMAND);
-
- static public void basicBoundaryCheck(PacketType packetType, RFXComMessage message) throws RFXComException {
- // This is a place where its easy to make mistakes in coding, and can result in errors, normally
- // array bounds errors
- byte[] binaryMessage = message.decodeMessage();
- assertEquals(binaryMessage[0], binaryMessage.length - 1, "Wrong packet length");
- assertEquals(packetType.toByte(), binaryMessage[1], "Wrong packet type");
- }
-
- static public int getActualIntValue(RFXComDeviceMessage msg, RFXComDeviceConfiguration config, String channelId)
- throws RFXComException {
- return ((DecimalType) msg.convertToState(channelId, config, new MockDeviceState())).intValue();
- }
-}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/handler/RFXComHandlerTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/handler/RFXComHandlerTest.java
index 52dff9c37037..238f1a33fe6e 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/handler/RFXComHandlerTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/handler/RFXComHandlerTest.java
@@ -15,7 +15,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
-import static org.openhab.binding.rfxcom.internal.RFXComTestHelper.*;
import java.util.Map;
@@ -42,6 +41,8 @@
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.thing.ThingStatusInfo;
+import org.openhab.core.thing.ThingTypeUID;
+import org.openhab.core.thing.ThingUID;
import org.openhab.core.thing.binding.ThingHandlerCallback;
import org.openhab.core.types.Command;
@@ -53,6 +54,10 @@
@ExtendWith(MockitoExtension.class)
public class RFXComHandlerTest {
+ static ThingUID bridgeUID = new ThingUID("rfxcom", "tcpbridge", "rfxtrx0");
+ static ThingUID thingUID = new ThingUID("rfxcom", bridgeUID, "mocked");
+ static ThingTypeUID thingTypeUID = new ThingTypeUID("rfxcom", "raw");
+
@Mock
Bridge bridge;
@@ -109,10 +114,10 @@ private void verifyStatusUpdated(ThingStatus status, ThingStatusDetail thingStat
private RFXComGenericDeviceConfiguration sendMessageToGetConfig(String channel, Command command)
throws RFXComException {
+ when(messageFactory.createMessage(any(PacketType.class))).thenReturn(message);
ChannelUID cuid = new ChannelUID(thing.getUID(), channel);
handler.handleCommand(cuid, command);
- verify(messageFactory).createMessage(any(PacketType.class), deviceConfigurationCaptor.capture(), eq(cuid),
- eq(command));
+ verify(message).setConfig(deviceConfigurationCaptor.capture());
return deviceConfigurationCaptor.getValue();
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComBarometricMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComBarometricMessageTest.java
index 72c2de476266..4c07f477cef8 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComBarometricMessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComBarometricMessageTest.java
@@ -29,6 +29,6 @@ public class RFXComBarometricMessageTest {
@Test
public void checkNotImplemented() {
assertThrows(RFXComMessageNotImplementedException.class,
- () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.BAROMETRIC, null, null, null));
+ () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.BAROMETRIC));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComCamera1MessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComCamera1MessageTest.java
index 64c06af80bc6..97f8b23241b5 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComCamera1MessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComCamera1MessageTest.java
@@ -29,6 +29,6 @@ public class RFXComCamera1MessageTest {
@Test
public void checkNotImplemented() {
assertThrows(RFXComMessageNotImplementedException.class,
- () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.CAMERA1, null, null, null));
+ () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.CAMERA1));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurtain1MessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurtain1MessageTest.java
index 383d05a26883..83ef0d5542b4 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurtain1MessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurtain1MessageTest.java
@@ -12,17 +12,11 @@
*/
package org.openhab.binding.rfxcom.internal.messages;
-import static org.openhab.binding.rfxcom.internal.RFXComTestHelper.thingUID;
import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.CURTAIN1;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.jupiter.api.Test;
-import org.openhab.binding.rfxcom.internal.RFXComBindingConstants;
-import org.openhab.binding.rfxcom.internal.RFXComTestHelper;
-import org.openhab.binding.rfxcom.internal.config.RFXComGenericDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.core.library.types.OpenClosedType;
-import org.openhab.core.thing.ChannelUID;
/**
* Test for RFXCom-binding
@@ -31,23 +25,18 @@
*/
@NonNullByDefault
public class RFXComCurtain1MessageTest {
- private static ChannelUID shutterChannelUID = new ChannelUID(thingUID, RFXComBindingConstants.CHANNEL_SHUTTER);
- private static RFXComGenericDeviceConfiguration config = new RFXComGenericDeviceConfiguration();
-
- static {
- config.deviceId = "1.2";
- config.subType = RFXComCurtain1Message.SubType.HARRISON.toString();
- }
-
@Test
public void checkForSupportTest() throws RFXComException {
- RFXComMessageFactoryImpl.INSTANCE.createMessage(CURTAIN1, config, shutterChannelUID, OpenClosedType.OPEN);
+ RFXComMessageFactoryImpl.INSTANCE.createMessage(CURTAIN1);
}
@Test
public void basicBoundaryCheck() throws RFXComException {
RFXComCurtain1Message message = (RFXComCurtain1Message) RFXComMessageFactoryImpl.INSTANCE
- .createMessage(CURTAIN1, config, shutterChannelUID, OpenClosedType.OPEN);
+ .createMessage(CURTAIN1);
+
+ message.subType = RFXComCurtain1Message.SubType.HARRISON;
+ message.command = RFXComCurtain1Message.Commands.OPEN;
RFXComTestHelper.basicBoundaryCheck(CURTAIN1, message);
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComDateTimeMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComDateTimeMessageTest.java
index cf5affcdb770..151458ec2dad 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComDateTimeMessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComDateTimeMessageTest.java
@@ -17,8 +17,6 @@
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.jupiter.api.Test;
-import org.openhab.binding.rfxcom.internal.RFXComTestHelper;
-import org.openhab.binding.rfxcom.internal.config.RFXComGenericDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.util.HexUtils;
@@ -32,10 +30,6 @@
public class RFXComDateTimeMessageTest {
@Test
public void testSomeMessages() throws RFXComException {
- RFXComGenericDeviceConfiguration config = new RFXComGenericDeviceConfiguration();
- config.deviceId = "47360";
- config.subType = RFXComDateTimeMessage.SubType.RTGR328N.toString();
-
String hexMessage = "0D580117B90003041D030D150A69";
byte[] message = HexUtils.hexToBytes(hexMessage);
RFXComDateTimeMessage msg = (RFXComDateTimeMessage) RFXComMessageFactoryImpl.INSTANCE.createMessage(message);
@@ -43,10 +37,10 @@ public void testSomeMessages() throws RFXComException {
assertEquals(23, (short) (msg.seqNbr & 0xFF), "Seq Number");
assertEquals("47360", msg.getDeviceId(), "Sensor Id");
assertEquals("2003-04-29T13:21:10", msg.dateTime, "Date time");
- assertEquals(2, RFXComTestHelper.getActualIntValue(msg, config, CHANNEL_SIGNAL_LEVEL), "Signal Level");
+ assertEquals(2, RFXComTestHelper.getActualIntValue(msg, CHANNEL_SIGNAL_LEVEL), "Signal Level");
assertEquals(DateTimeType.valueOf("2003-04-29T13:21:10"),
- msg.convertToState(CHANNEL_DATE_TIME, config, new MockDeviceState()), "Converted value");
+ msg.convertToState(CHANNEL_DATE_TIME, new MockDeviceState()), "Converted value");
byte[] decoded = msg.decodeMessage();
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComEdisioTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComEdisioTest.java
index 736eed1bbf21..b8463c3d78af 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComEdisioTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComEdisioTest.java
@@ -29,6 +29,6 @@ public class RFXComEdisioTest {
@Test
public void checkNotImplemented() {
assertThrows(RFXComMessageNotImplementedException.class,
- () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(EDISIO, null, null, null));
+ () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(EDISIO));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFS20MessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFS20MessageTest.java
index 1add4b37f3ca..e8ea4d13eddd 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFS20MessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFS20MessageTest.java
@@ -30,6 +30,6 @@ public class RFXComFS20MessageTest {
@Test
public void checkNotImplemented() {
assertThrows(RFXComMessageNotImplementedException.class,
- () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.FS20, null, null, null));
+ () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.FS20));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanMessageTest.java
index 0eb7c6b2dc71..c475507e8afe 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanMessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanMessageTest.java
@@ -14,20 +14,15 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
-import static org.openhab.binding.rfxcom.internal.RFXComTestHelper.thingUID;
import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.FAN;
import static org.openhab.binding.rfxcom.internal.messages.RFXComFanMessage.SubType.CASAFAN;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.junit.jupiter.api.Test;
-import org.openhab.binding.rfxcom.internal.RFXComBindingConstants;
-import org.openhab.binding.rfxcom.internal.RFXComTestHelper;
-import org.openhab.binding.rfxcom.internal.config.RFXComGenericDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.StringType;
-import org.openhab.core.thing.ChannelUID;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
import org.openhab.core.util.HexUtils;
@@ -39,26 +34,19 @@
*/
@NonNullByDefault
public class RFXComFanMessageTest {
- private static RFXComGenericDeviceConfiguration config = new RFXComGenericDeviceConfiguration();
- private static ChannelUID fanSpeedChannelUID = new ChannelUID(thingUID, RFXComBindingConstants.CHANNEL_FAN_SPEED);
- private static StringType fanSpeedOff = StringType.valueOf("OFF");
-
- static {
- config.deviceId = "5428224";
- config.subType = RFXComFanMessage.SubType.CASAFAN.toString();
- }
-
private static final MockDeviceState DEVICE_STATE = new MockDeviceState();
@Test
public void checkForSupportTest() throws RFXComException {
- RFXComMessageFactoryImpl.INSTANCE.createMessage(FAN, config, fanSpeedChannelUID, fanSpeedOff);
+ RFXComMessageFactoryImpl.INSTANCE.createMessage(FAN);
}
@Test
public void basicBoundaryCheck() throws RFXComException {
- RFXComFanMessage message = (RFXComFanMessage) RFXComMessageFactoryImpl.INSTANCE.createMessage(FAN, config,
- fanSpeedChannelUID, fanSpeedOff);
+ RFXComFanMessage message = (RFXComFanMessage) RFXComMessageFactoryImpl.INSTANCE.createMessage(FAN);
+
+ message.setSubType(RFXComFanMessage.SubType.CASAFAN);
+ message.convertFromState(CHANNEL_FAN_SPEED, StringType.valueOf("OFF"));
RFXComTestHelper.basicBoundaryCheck(FAN, message);
}
@@ -72,9 +60,9 @@ private void testMessage(String hexMsg, int seqNbr, String deviceId, int signalL
assertEquals(deviceId, msg.getDeviceId(), "Sensor Id");
assertEquals(signalLevel, msg.signalLevel, "Signal Level");
- assertEquals(expectedCommand, msg.convertToState(CHANNEL_COMMAND, config, DEVICE_STATE));
- assertEquals(expectedLightCommand, msg.convertToState(CHANNEL_FAN_LIGHT, config, DEVICE_STATE));
- assertEquals(expectedFanSpeed, msg.convertToState(CHANNEL_FAN_SPEED, config, DEVICE_STATE));
+ assertEquals(expectedCommand, msg.convertToState(CHANNEL_COMMAND, DEVICE_STATE));
+ assertEquals(expectedLightCommand, msg.convertToState(CHANNEL_FAN_LIGHT, DEVICE_STATE));
+ assertEquals(expectedFanSpeed, msg.convertToState(CHANNEL_FAN_SPEED, DEVICE_STATE));
assertEquals(packetType, msg.getPacketType());
@@ -151,10 +139,10 @@ static void testCommand(RFXComFanMessage.SubType subType, String channel, State
private static void assertValues(RFXComFanMessage msg, @Nullable OnOffType expectedCommand,
State expectedLightCommand, @Nullable State expectedFanSpeed, RFXComBaseMessage.PacketType packetType,
State expectedCommandString) throws RFXComException {
- assertEquals(expectedCommand, msg.convertToState(CHANNEL_COMMAND, config, DEVICE_STATE));
- assertEquals(expectedLightCommand, msg.convertToState(CHANNEL_FAN_LIGHT, config, DEVICE_STATE));
- assertEquals(expectedFanSpeed, msg.convertToState(CHANNEL_FAN_SPEED, config, DEVICE_STATE));
- assertEquals(expectedCommandString, msg.convertToState(CHANNEL_COMMAND_STRING, config, DEVICE_STATE));
+ assertEquals(expectedCommand, msg.convertToState(CHANNEL_COMMAND, DEVICE_STATE));
+ assertEquals(expectedLightCommand, msg.convertToState(CHANNEL_FAN_LIGHT, DEVICE_STATE));
+ assertEquals(expectedFanSpeed, msg.convertToState(CHANNEL_FAN_SPEED, DEVICE_STATE));
+ assertEquals(expectedCommandString, msg.convertToState(CHANNEL_COMMAND_STRING, DEVICE_STATE));
assertEquals(packetType, msg.getPacketType());
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComGasMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComGasMessageTest.java
index d58e4c5d63b4..b82f3df9cf89 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComGasMessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComGasMessageTest.java
@@ -30,6 +30,6 @@ public class RFXComGasMessageTest {
@Test
public void checkNotImplemented() {
assertThrows(RFXComMessageNotImplementedException.class,
- () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.GAS, null, null, null));
+ () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.GAS));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComHomeConfortMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComHomeConfortTest.java
similarity index 63%
rename from bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComHomeConfortMessageTest.java
rename to bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComHomeConfortTest.java
index 549459e1eab9..28de642f3538 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComHomeConfortMessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComHomeConfortTest.java
@@ -13,16 +13,13 @@
package org.openhab.binding.rfxcom.internal.messages;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.openhab.binding.rfxcom.internal.RFXComTestHelper.commandChannelUID;
import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.HOME_CONFORT;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.jupiter.api.Test;
-import org.openhab.binding.rfxcom.internal.config.RFXComGenericDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
+import org.openhab.binding.rfxcom.internal.messages.RFXComHomeConfortMessage.Commands;
import org.openhab.binding.rfxcom.internal.messages.RFXComHomeConfortMessage.SubType;
-import org.openhab.core.library.types.OnOffType;
-import org.openhab.core.types.Command;
import org.openhab.core.util.HexUtils;
/**
@@ -32,21 +29,19 @@
* @author Mike Jagdis - added message handling and real test
*/
@NonNullByDefault
-public class RFXComHomeConfortMessageTest {
- private void testMessage(SubType subType, Command command, String deviceId, String data) throws RFXComException {
- RFXComGenericDeviceConfiguration config = new RFXComGenericDeviceConfiguration();
-
- config.deviceId = deviceId;
- config.subType = subType.toString();
-
+public class RFXComHomeConfortTest {
+ private void testMessage(SubType subType, Commands command, String deviceId, String data) throws RFXComException {
RFXComHomeConfortMessage message = (RFXComHomeConfortMessage) RFXComMessageFactoryImpl.INSTANCE
- .createMessage(HOME_CONFORT, config, commandChannelUID, command);
+ .createMessage(HOME_CONFORT);
+ message.setSubType(subType);
+ message.command = command;
+ message.setDeviceId(deviceId);
assertArrayEquals(HexUtils.hexToBytes(data), message.decodeMessage());
}
@Test
public void testMessage1() throws RFXComException {
- testMessage(SubType.TEL_010, OnOffType.ON, "1118739.A.4", "0C1B0000111213410401000000");
+ testMessage(SubType.TEL_010, Commands.GROUP_ON, "1118739.A.4", "0C1B0000111213410403000000");
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComIOLinesMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComIOLinesMessageTest.java
index 5ebe0b9e78bb..044008fd42d2 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComIOLinesMessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComIOLinesMessageTest.java
@@ -30,6 +30,6 @@ public class RFXComIOLinesMessageTest {
@Test
public void checkNotImplemented() {
assertThrows(RFXComMessageNotImplementedException.class,
- () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.IO_LINES, null, null, null));
+ () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.IO_LINES));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting1MessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting1MessageTest.java
index 787cbbbac507..54af0ef7dcc2 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting1MessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting1MessageTest.java
@@ -17,7 +17,6 @@
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.jupiter.api.Test;
-import org.openhab.binding.rfxcom.internal.config.RFXComGenericDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.binding.rfxcom.internal.messages.RFXComLighting1Message.Commands;
@@ -34,12 +33,6 @@
@NonNullByDefault
public class RFXComLighting1MessageTest {
private final MockDeviceState deviceState = new MockDeviceState();
- private static final RFXComGenericDeviceConfiguration config = new RFXComGenericDeviceConfiguration();
-
- static {
- config.deviceId = "A.1";
- config.subType = RFXComLighting1Message.SubType.ARC.toString();
- }
private void testMessage(String hexMsg, RFXComLighting1Message.SubType subType, int seqNbr, String deviceId,
byte signalLevel, Commands command, String commandString) throws RFXComException {
@@ -50,11 +43,7 @@ private void testMessage(String hexMsg, RFXComLighting1Message.SubType subType,
assertEquals(deviceId, msg.getDeviceId(), "Sensor Id");
assertEquals(signalLevel, msg.signalLevel, "Signal Level");
assertEquals(command, msg.command, "Command");
-
- RFXComGenericDeviceConfiguration config = new RFXComGenericDeviceConfiguration();
- config.deviceId = deviceId;
- config.subType = subType.toString();
- assertEquals(commandString, msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState).toString(),
+ assertEquals(commandString, msg.convertToState(CHANNEL_COMMAND_STRING, deviceState).toString(),
"Command String");
byte[] decoded = msg.decodeMessage();
@@ -83,9 +72,9 @@ public void testCommandStringOff() throws RFXComUnsupportedChannelException {
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("OFF"));
- assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(OpenClosedType.CLOSED, msg.convertToState(CHANNEL_CONTACT, config, deviceState));
- assertEquals(StringType.valueOf("OFF"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(OpenClosedType.CLOSED, msg.convertToState(CHANNEL_CONTACT, deviceState));
+ assertEquals(StringType.valueOf("OFF"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
}
@Test
@@ -94,9 +83,9 @@ public void testCommandStringChime() throws RFXComUnsupportedChannelException {
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("chime"));
- assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(OpenClosedType.OPEN, msg.convertToState(CHANNEL_CONTACT, config, deviceState));
- assertEquals(StringType.valueOf("CHIME"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(OpenClosedType.OPEN, msg.convertToState(CHANNEL_CONTACT, deviceState));
+ assertEquals(StringType.valueOf("CHIME"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
}
@Test
@@ -105,9 +94,9 @@ public void testCommandStringBright() throws RFXComUnsupportedChannelException {
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("bright"));
- assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(OpenClosedType.OPEN, msg.convertToState(CHANNEL_CONTACT, config, deviceState));
- assertEquals(StringType.valueOf("BRIGHT"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(OpenClosedType.OPEN, msg.convertToState(CHANNEL_CONTACT, deviceState));
+ assertEquals(StringType.valueOf("BRIGHT"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
}
@Test
@@ -116,8 +105,8 @@ public void testCommandStringDim() throws RFXComUnsupportedChannelException {
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("dim"));
- assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(OpenClosedType.CLOSED, msg.convertToState(CHANNEL_CONTACT, config, deviceState));
- assertEquals(StringType.valueOf("DIM"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(OpenClosedType.CLOSED, msg.convertToState(CHANNEL_CONTACT, deviceState));
+ assertEquals(StringType.valueOf("DIM"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting3MessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting3MessageTest.java
index fe671050827b..655698e16399 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting3MessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting3MessageTest.java
@@ -31,6 +31,6 @@ public class RFXComLighting3MessageTest {
public void checkNotImplemented() {
// TODO Note that this message is supported in the 1.9 binding
assertThrows(RFXComMessageNotImplementedException.class,
- () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.LIGHTING3, null, null, null));
+ () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.LIGHTING3));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting4MessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting4MessageTest.java
index d4f01a4d832c..aaea645133fa 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting4MessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting4MessageTest.java
@@ -12,31 +12,21 @@
*/
package org.openhab.binding.rfxcom.internal.messages;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
-import static org.openhab.binding.rfxcom.internal.RFXComTestHelper.*;
import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.LIGHTING4;
+import static org.openhab.binding.rfxcom.internal.messages.RFXComLighting4Message.Commands.*;
import static org.openhab.binding.rfxcom.internal.messages.RFXComLighting4Message.SubType.PT2262;
import java.util.Arrays;
import java.util.List;
-import java.util.Map;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.junit.jupiter.api.Test;
-import org.openhab.binding.rfxcom.internal.RFXComTestHelper;
-import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.config.RFXComLighting4DeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
-import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
-import org.openhab.core.config.discovery.DiscoveryResultBuilder;
import org.openhab.core.library.types.OnOffType;
-import org.openhab.core.library.types.OpenClosedType;
-import org.openhab.core.thing.ChannelUID;
-import org.openhab.core.thing.ThingUID;
-import org.openhab.core.types.Command;
import org.openhab.core.util.HexUtils;
/**
@@ -46,33 +36,17 @@
*/
@NonNullByDefault
public class RFXComLighting4MessageTest {
- static public final ChannelUID contactChannelUID = new ChannelUID(thingUID, CHANNEL_CONTACT);
-
- static public void checkDiscoveryResult(RFXComDeviceMessage msg, String deviceId,
- @Nullable Integer pulse, String subType) throws RFXComException {
- String thingUID = "homeduino:rfxcom:fssfsd:thing";
- DiscoveryResultBuilder builder = DiscoveryResultBuilder.create(new ThingUID(thingUID));
-
- // check whether the pulse is stored
- msg.addDevicePropertiesTo(builder);
-
- Map properties = builder.build().getProperties();
- assertEquals(deviceId, properties.get("deviceId"), "Device Id");
- assertEquals(subType, properties.get("subType"), "Sub type");
- if (pulse != null) {
- assertEquals(pulse, properties.get("pulse"), "Pulse");
- }
- }
-
@Test
public void basicBoundaryCheck() throws RFXComException {
+ RFXComLighting4Message message = (RFXComLighting4Message) RFXComMessageFactoryImpl.INSTANCE
+ .createMessage(LIGHTING4);
+
RFXComLighting4DeviceConfiguration config = new RFXComLighting4DeviceConfiguration();
config.deviceId = "90000";
config.subType = "PT2262";
config.pulse = 300;
-
- RFXComLighting4Message message = (RFXComLighting4Message) RFXComMessageFactoryImpl.INSTANCE
- .createMessage(LIGHTING4, config, commandChannelUID, OnOffType.ON);
+ message.setConfig(config);
+ message.convertFromState(CHANNEL_COMMAND, OnOffType.ON);
byte[] binaryMessage = message.decodeMessage();
RFXComLighting4Message msg = (RFXComLighting4Message) RFXComMessageFactoryImpl.INSTANCE
@@ -81,59 +55,56 @@ public void basicBoundaryCheck() throws RFXComException {
assertEquals("90000", msg.getDeviceId(), "Sensor Id");
}
- private void testMessageWithoutCommandIds(String hexMsg, RFXComLighting4Message.SubType subType, String deviceId,
- @Nullable Integer pulse, int commandByte, @Nullable Integer seqNbr, int signalLevel, Command command)
- throws RFXComException {
- // These tests rely on the deprecated behaviour of a "known" set of ON/OFF values and will
- // be removed in a later release to be replaced with test that check we throw an exception
- // if the config isn't specified (see the open/closed tests).
- RFXComLighting4DeviceConfiguration config = new RFXComLighting4DeviceConfiguration();
- config.deviceId = deviceId;
- config.subType = subType.toString();
+ private void testMessage(String hexMsg, RFXComLighting4Message.SubType subType, String deviceId,
+ @Nullable Integer pulse, RFXComLighting4Message.Commands command, @Nullable Integer seqNbr, int signalLevel,
+ int offCommand, int onCommand) throws RFXComException {
+ testMessage(hexMsg, subType, deviceId, pulse, command.toByte(), seqNbr, signalLevel, offCommand, onCommand);
+ }
+ private void testMessage(String hexMsg, RFXComLighting4Message.SubType subType, String deviceId,
+ @Nullable Integer pulse, byte commandByte, @Nullable Integer seqNbr, int signalLevel, int offCommand,
+ int onCommand) throws RFXComException {
RFXComLighting4Message msg = (RFXComLighting4Message) RFXComMessageFactoryImpl.INSTANCE
.createMessage(HexUtils.hexToBytes(hexMsg));
assertEquals(deviceId, msg.getDeviceId(), "Sensor Id");
- assertEquals(commandByte, RFXComTestHelper.getActualIntValue(msg, config, CHANNEL_COMMAND_ID), "Command");
+ assertEquals(commandByte, RFXComTestHelper.getActualIntValue(msg, CHANNEL_COMMAND_ID), "Command");
if (seqNbr != null) {
assertEquals(seqNbr.shortValue(), (short) (msg.seqNbr & 0xFF), "Seq Number");
}
- assertEquals(signalLevel, RFXComTestHelper.getActualIntValue(msg, config, CHANNEL_SIGNAL_LEVEL),
- "Signal Level");
- assertEquals(command, msg.convertToCommand(CHANNEL_COMMAND, config, null));
+ assertEquals(signalLevel, RFXComTestHelper.getActualIntValue(msg, CHANNEL_SIGNAL_LEVEL), "Signal Level");
byte[] decoded = msg.decodeMessage();
assertEquals(hexMsg, HexUtils.bytesToHex(decoded), "Message converted back");
- checkDiscoveryResult(msg, deviceId, pulse, subType.toString());
+ RFXComTestHelper.checkDiscoveryResult(msg, deviceId, pulse, subType.toString(), offCommand, onCommand);
}
@Test
public void testSomeMessages() throws RFXComException {
- testMessageWithoutCommandIds("091300E1D8AD59018F70", PT2262, "887509", 399, 9, 225, 2, OnOffType.ON);
- testMessageWithoutCommandIds("0913005FA9A9C901A170", PT2262, "694940", 417, 9, 95, 2, OnOffType.ON);
- testMessageWithoutCommandIds("091300021D155C01E960", PT2262, "119125", 489, 12, 2, 2, OnOffType.ON);
- testMessageWithoutCommandIds("091300D345DD99018C50", PT2262, "286169", 396, 9, 211, 2, OnOffType.ON);
- testMessageWithoutCommandIds("09130035D149A2017750", PT2262, "857242", 375, 2, 53, 2, OnOffType.OFF);
- testMessageWithoutCommandIds("0913000B4E462A012280", PT2262, "320610", 290, 10, 11, 3, OnOffType.ON);
- testMessageWithoutCommandIds("09130009232D2E013970", PT2262, "144082", 313, 14, 9, 2, OnOffType.OFF);
- testMessageWithoutCommandIds("091300CA0F8D2801AA70", PT2262, "63698", 426, 8, 202, 2, OnOffType.ON);
+ testMessage("091300E1D8AD59018F70", PT2262, "887509", 399, ON_9, 225, 2, 4, 9);
+ testMessage("0913005FA9A9C901A170", PT2262, "694940", 417, ON_9, 95, 2, 4, 9);
+ testMessage("091300021D155C01E960", PT2262, "119125", 489, ON_12, 2, 2, 4, 12);
+ testMessage("091300D345DD99018C50", PT2262, "286169", 396, ON_9, 211, 2, 4, 9);
+ testMessage("09130035D149A2017750", PT2262, "857242", 375, OFF_2, 53, 2, 2, 1);
+ testMessage("0913000B4E462A012280", PT2262, "320610", 290, ON_10, 11, 3, 4, 10);
+ testMessage("09130009232D2E013970", PT2262, "144082", 313, OFF_14, 9, 2, 14, 1);
+ testMessage("091300CA0F8D2801AA70", PT2262, "63698", 426, ON_8, 202, 2, 4, 8);
}
@Test
public void testSomeAlarmRemote() throws RFXComException {
- testMessageWithoutCommandIds("0913004A0D8998016E60", PT2262, "55449", 366, 8, 74, 2, OnOffType.ON);
+ testMessage("0913004A0D8998016E60", PT2262, "55449", 366, ON_8, 74, 2, 4, 8);
}
@Test
public void testCheapPirSensor() throws RFXComException {
- testMessageWithoutCommandIds("091300EF505FC6019670", PT2262, "329212", 406, 6, 239, 2, OnOffType.ON);
+ testMessage("091300EF505FC6019670", PT2262, "329212", 406, ON_6, 239, 2, 4, 6);
}
@Test
public void testSomeConradMessages() throws RFXComException {
- testMessageWithoutCommandIds("0913003554545401A150", PT2262, "345413", 417, 4, 53, 2, OnOffType.OFF);
+ testMessage("0913003554545401A150", PT2262, "345413", 417, OFF_4, 53, 2, 4, 1);
}
@Test
@@ -142,7 +113,7 @@ public void testPhenixMessages() throws RFXComException {
"0913004C044551013780", "0913004E044551013780");
for (String message : onMessages) {
- testMessageWithoutCommandIds(message, PT2262, "17493", null, 1, null, 3, OnOffType.ON);
+ testMessage(message, PT2262, "17493", null, ON_1, null, 3, 4, 1);
}
List offMessages = Arrays.asList("09130051044554013980", "09130053044554013680", "09130055044554013680",
@@ -150,149 +121,7 @@ public void testPhenixMessages() throws RFXComException {
"09130060044554013980", "09130062044554013680", "09130064044554013280");
for (String message : offMessages) {
- testMessageWithoutCommandIds(message, PT2262, "17493", null, 4, null, 3, OnOffType.OFF);
- }
- }
-
- private void testRxWithConfig(String hexMsg, RFXComDeviceConfiguration config,
- RFXComLighting4Message.SubType subType, String deviceId, @Nullable Integer pulse, int commandByte,
- @Nullable Integer seqNbr, int signalLevel, ChannelUID channelUID, Command command) throws RFXComException {
- RFXComLighting4Message msg = (RFXComLighting4Message) RFXComMessageFactoryImpl.INSTANCE
- .createMessage(HexUtils.hexToBytes(hexMsg));
- assertEquals(deviceId, msg.getDeviceId(), "Sensor Id");
- assertEquals(commandByte, RFXComTestHelper.getActualIntValue(msg, config, CHANNEL_COMMAND_ID), "Command");
- if (seqNbr != null) {
- assertEquals(seqNbr.shortValue(), (short) (msg.seqNbr & 0xFF), "Seq Number");
+ testMessage(message, PT2262, "17493", null, OFF_4, null, 3, 4, 1);
}
- assertEquals(signalLevel, RFXComTestHelper.getActualIntValue(msg, config, CHANNEL_SIGNAL_LEVEL),
- "Signal Level");
- assertEquals(command, msg.convertToCommand(channelUID.getId(), config, null));
-
- byte[] decoded = msg.decodeMessage();
-
- assertEquals(hexMsg, HexUtils.bytesToHex(decoded), "Message converted back");
-
- checkDiscoveryResult(msg, deviceId, pulse, subType.toString());
- }
-
- @Test
- public void testRxWithFullConfig() throws RFXComException {
- RFXComLighting4DeviceConfiguration config = new RFXComLighting4DeviceConfiguration();
- config.deviceId = "12345";
- config.subType = PT2262.toString();
- config.onCommandId = 0xA;
- config.offCommandId = 0xB;
- config.openCommandId = 0xC;
- config.closedCommandId = 0xD;
-
- testRxWithConfig("0913003503039A01A150", config, PT2262, "12345", 417, 0xA, 53, 2, commandChannelUID,
- OnOffType.ON);
- testRxWithConfig("0913003503039B01A150", config, PT2262, "12345", 417, 0xB, 53, 2, commandChannelUID,
- OnOffType.OFF);
- testRxWithConfig("0913003503039C01A150", config, PT2262, "12345", 417, 0xC, 53, 2, contactChannelUID,
- OpenClosedType.OPEN);
- testRxWithConfig("0913003503039D01A150", config, PT2262, "12345", 417, 0xD, 53, 2, contactChannelUID,
- OpenClosedType.CLOSED);
- }
-
- @Test
- public void testRxWithPartialConfig() throws RFXComException {
- RFXComLighting4DeviceConfiguration config = new RFXComLighting4DeviceConfiguration();
- config.deviceId = "12345";
- config.subType = PT2262.toString();
- config.onCommandId = 0xA;
- config.openCommandId = 0xC;
-
- testRxWithConfig("0913003503039A01A150", config, PT2262, "12345", 417, 0xA, 53, 2, commandChannelUID,
- OnOffType.ON);
- assertThrows(RFXComInvalidStateException.class, () -> testRxWithConfig("0913003503039B01A150", config, PT2262,
- "12345", 417, 0xB, 53, 2, commandChannelUID, OnOffType.OFF));
- testRxWithConfig("0913003503039C01A150", config, PT2262, "12345", 417, 0xC, 53, 2, contactChannelUID,
- OpenClosedType.OPEN);
- assertThrows(RFXComInvalidStateException.class, () -> testRxWithConfig("0913003503039D01A150", config, PT2262,
- "12345", 417, 0xD, 53, 2, contactChannelUID, OpenClosedType.CLOSED));
- }
-
- @Test
- public void testRxWithNoConfig() throws RFXComException {
- RFXComLighting4DeviceConfiguration config = new RFXComLighting4DeviceConfiguration();
- config.deviceId = "12345";
- config.subType = PT2262.toString();
-
- // These will fall back on deprecated behaviour, but should all be assertThrows in the future.
- testRxWithConfig("0913003503039A01A150", config, PT2262, "12345", 417, 0xA, 53, 2, commandChannelUID,
- OnOffType.ON);
- testRxWithConfig("0913003503039B01A150", config, PT2262, "12345", 417, 0xB, 53, 2, commandChannelUID,
- OnOffType.ON);
- testRxWithConfig("0913003503039C01A150", config, PT2262, "12345", 417, 0xC, 53, 2, contactChannelUID,
- OpenClosedType.OPEN);
- testRxWithConfig("0913003503039D01A150", config, PT2262, "12345", 417, 0xD, 53, 2, contactChannelUID,
- OpenClosedType.OPEN);
- }
-
- private void testTxWithConfig(RFXComDeviceConfiguration config, ChannelUID channelUID, Command command,
- RFXComLighting4Message.SubType subType, String deviceId, @Nullable Integer pulse, int commandByte,
- String hexMsg) throws RFXComException {
- RFXComLighting4Message msg = (RFXComLighting4Message) RFXComMessageFactoryImpl.INSTANCE
- .createMessage(PacketType.LIGHTING4, config, channelUID, command);
- assertEquals(deviceId, msg.getDeviceId(), "Sensor Id");
- assertEquals(commandByte, RFXComTestHelper.getActualIntValue(msg, config, CHANNEL_COMMAND_ID), "Command");
- assertEquals(0, msg.seqNbr & 0xFF, "Seq Number");
- assertEquals(0, RFXComTestHelper.getActualIntValue(msg, config, CHANNEL_SIGNAL_LEVEL), "Signal Level");
- assertEquals(hexMsg, HexUtils.bytesToHex(msg.decodeMessage()), "Message bytes");
- }
-
- @Test
- void testTxWithFullConfig() throws RFXComException {
- RFXComLighting4DeviceConfiguration config = new RFXComLighting4DeviceConfiguration();
- config.deviceId = "703696";
- config.subType = PT2262.toString();
- config.onCommandId = 0xA;
- config.offCommandId = 0xB;
- config.openCommandId = 0xC;
- config.closedCommandId = 0xD;
- config.pulse = 417;
-
- testTxWithConfig(config, commandChannelUID, OnOffType.ON, PT2262, "703696", 417, 0xA, "09130000ABCD0A01A100");
- testTxWithConfig(config, commandChannelUID, OnOffType.OFF, PT2262, "703696", 417, 0xB, "09130000ABCD0B01A100");
- testTxWithConfig(config, contactChannelUID, OpenClosedType.OPEN, PT2262, "703696", 417, 0xC,
- "09130000ABCD0C01A100");
- testTxWithConfig(config, contactChannelUID, OpenClosedType.CLOSED, PT2262, "703696", 417, 0xD,
- "09130000ABCD0D01A100");
- }
-
- @Test
- void testTxWithPartialConfig() throws RFXComException {
- RFXComLighting4DeviceConfiguration config = new RFXComLighting4DeviceConfiguration();
- config.deviceId = "703696";
- config.subType = PT2262.toString();
- config.onCommandId = 0xA;
- config.openCommandId = 0xC;
- config.pulse = 417;
-
- testTxWithConfig(config, commandChannelUID, OnOffType.ON, PT2262, "703696", 417, 0xA, "09130000ABCD0A01A100");
- // Falls back on deprecated behaviour, but should be assertThrows in the future.
- testTxWithConfig(config, commandChannelUID, OnOffType.OFF, PT2262, "703696", 417, 0x4, "09130000ABCD0401A100");
- testTxWithConfig(config, contactChannelUID, OpenClosedType.OPEN, PT2262, "703696", 417, 0xC,
- "09130000ABCD0C01A100");
- assertThrows(RFXComInvalidStateException.class, () -> testTxWithConfig(config, contactChannelUID,
- OpenClosedType.CLOSED, PT2262, "703696", 417, 0xD, "??"));
- }
-
- @Test
- void testTxWithNoConfig() throws RFXComException {
- RFXComLighting4DeviceConfiguration config = new RFXComLighting4DeviceConfiguration();
- config.deviceId = "703696";
- config.subType = PT2262.toString();
- config.pulse = 417;
-
- // Falls back on deprecated behaviour, but should be assertThrows in the future.
- testTxWithConfig(config, commandChannelUID, OnOffType.ON, PT2262, "703696", 417, 0x1, "09130000ABCD0101A100");
- // Falls back on deprecated behaviour, but should be assertThrows in the future.
- testTxWithConfig(config, commandChannelUID, OnOffType.OFF, PT2262, "703696", 417, 0x4, "09130000ABCD0401A100");
- assertThrows(RFXComInvalidStateException.class, () -> testTxWithConfig(config, contactChannelUID,
- OpenClosedType.OPEN, PT2262, "703696", 417, 0xC, "??"));
- assertThrows(RFXComInvalidStateException.class, () -> testTxWithConfig(config, contactChannelUID,
- OpenClosedType.CLOSED, PT2262, "703696", 417, 0xD, "??"));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting5MessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting5MessageTest.java
index 1bca6cf76513..64aa2bf72003 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting5MessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting5MessageTest.java
@@ -13,16 +13,15 @@
package org.openhab.binding.rfxcom.internal.messages;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.CHANNEL_COMMAND_STRING;
-import static org.openhab.binding.rfxcom.internal.RFXComTestHelper.commandChannelUID;
+import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.LIGHTING5;
import static org.openhab.binding.rfxcom.internal.messages.RFXComLighting5Message.Commands.*;
+import static org.openhab.binding.rfxcom.internal.messages.RFXComLighting5Message.SubType.IT;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.jupiter.api.Test;
-import org.openhab.binding.rfxcom.internal.RFXComTestHelper;
-import org.openhab.binding.rfxcom.internal.config.RFXComGenericDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
+import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.util.HexUtils;
@@ -35,33 +34,30 @@
@NonNullByDefault
public class RFXComLighting5MessageTest {
private final MockDeviceState deviceState = new MockDeviceState();
- private static final RFXComGenericDeviceConfiguration config = new RFXComGenericDeviceConfiguration();
- static {
- config.deviceId = "2061.1";
- config.subType = RFXComLighting5Message.SubType.IT.toString();
- }
@Test
public void convertFromStateItMessage() throws RFXComException {
- RFXComMessage itMessageObject = RFXComMessageFactoryImpl.INSTANCE.createMessage(LIGHTING5, config,
- commandChannelUID, OnOffType.ON);
+ RFXComDeviceMessage itMessageObject = (RFXComDeviceMessage) RFXComMessageFactoryImpl.INSTANCE
+ .createMessage(LIGHTING5);
+ itMessageObject.setDeviceId("2061.1");
+ itMessageObject.setSubType(IT);
+ itMessageObject.convertFromState(CHANNEL_COMMAND, OnOffType.ON);
byte[] message = itMessageObject.decodeMessage();
String hexMessage = HexUtils.bytesToHex(message);
assertEquals("0A140F0000080D01010000", hexMessage, "Message is not as expected");
RFXComLighting5Message msg = (RFXComLighting5Message) RFXComMessageFactoryImpl.INSTANCE.createMessage(message);
- assertEquals(RFXComLighting5Message.SubType.IT, msg.subType, "SubType");
+ assertEquals(IT, msg.subType, "SubType");
assertEquals("2061.1", msg.getDeviceId(), "Sensor Id");
assertEquals(ON, msg.command, "Command");
}
@Test
public void basicBoundaryCheck() throws RFXComException {
- RFXComGenericDeviceConfiguration config = new RFXComGenericDeviceConfiguration();
- config.deviceId = "206.1";
- config.subType = RFXComLighting5Message.SubType.LIGHTWAVERF.toString();
-
RFXComLighting5Message message = (RFXComLighting5Message) RFXComMessageFactoryImpl.INSTANCE
- .createMessage(LIGHTING5, config, commandChannelUID, OnOffType.ON);
+ .createMessage(LIGHTING5);
+
+ message.subType = RFXComLighting5Message.SubType.LIGHTWAVERF;
+ message.command = ON;
RFXComTestHelper.basicBoundaryCheck(LIGHTING5, message);
}
@@ -69,30 +65,29 @@ public void basicBoundaryCheck() throws RFXComException {
// TODO please add more tests for different messages
@Test
- public void testStringCommandOpenRelay() throws RFXComException {
+ public void testStringCommandOpenRelay() throws RFXComUnsupportedChannelException {
RFXComLighting5Message msg = new RFXComLighting5Message();
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("OPEN_RELAY"));
- assertEquals(StringType.valueOf("OPEN_RELAY"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(StringType.valueOf("OPEN_RELAY"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
assertEquals(OPEN_RELAY, msg.command);
}
@Test
- public void testStringCommandCloseRelay() throws RFXComException {
+ public void testStringCommandCloseRelay() throws RFXComUnsupportedChannelException {
RFXComLighting5Message msg = new RFXComLighting5Message();
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("CLOSE_RELAY"));
- assertEquals(StringType.valueOf("CLOSE_RELAY"),
- msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(StringType.valueOf("CLOSE_RELAY"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
assertEquals(CLOSE_RELAY, msg.command);
}
@Test
- public void testStringCommandStopRelay() throws RFXComException {
+ public void testStringCommandStopRelay() throws RFXComUnsupportedChannelException {
RFXComLighting5Message msg = new RFXComLighting5Message();
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("STOP_RELAY"));
- assertEquals(StringType.valueOf("STOP_RELAY"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(StringType.valueOf("STOP_RELAY"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
assertEquals(STOP_RELAY, msg.command);
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComPowerMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComPowerMessageTest.java
index b75416a891ab..639763e6d78c 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComPowerMessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComPowerMessageTest.java
@@ -28,7 +28,7 @@ public class RFXComPowerMessageTest {
@Test
public void checkNotImplemented() {
// TODO Note that this message is supported in the 1.9 binding
- assertThrows(RFXComMessageNotImplementedException.class, () -> RFXComMessageFactoryImpl.INSTANCE
- .createMessage(RFXComBaseMessage.PacketType.POWER, null, null, null));
+ assertThrows(RFXComMessageNotImplementedException.class,
+ () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(RFXComBaseMessage.PacketType.POWER));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXMeterMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXMeterMessageTest.java
index 45d19afc2873..5d0b48f24d9e 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXMeterMessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXMeterMessageTest.java
@@ -30,6 +30,6 @@ public class RFXComRFXMeterMessageTest {
@Test
public void checkNotImplemented() {
assertThrows(RFXComMessageNotImplementedException.class,
- () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.RFXMETER, null, null, null));
+ () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.RFXMETER));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXSensorMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXSensorMessageTest.java
index d3690a33d4c8..2f9a401aadb9 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXSensorMessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXSensorMessageTest.java
@@ -89,7 +89,7 @@ public void testHumidity() throws RFXComException {
private @Nullable Double getChannelAsDouble(String channelId, RFXComRFXSensorMessage msg, DeviceState deviceState)
throws RFXComException {
- return getStateAsDouble(msg.convertToState(channelId, null, deviceState));
+ return getStateAsDouble(msg.convertToState(channelId, deviceState));
}
private @Nullable Double getStateAsDouble(State state) {
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRadiator1MessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRadiator1MessageTest.java
index 9cf34448f2ed..088f600b8b1f 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRadiator1MessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRadiator1MessageTest.java
@@ -29,6 +29,6 @@ public class RFXComRadiator1MessageTest {
@Test
public void checkNotImplemented() {
assertThrows(RFXComMessageNotImplementedException.class,
- () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(RADIATOR1, null, null, null));
+ () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(RADIATOR1));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRawMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRawMessageTest.java
index e22d4c7f6eff..188c7fc8b620 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRawMessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRawMessageTest.java
@@ -13,18 +13,18 @@
package org.openhab.binding.rfxcom.internal.messages;
import static org.junit.jupiter.api.Assertions.*;
-import static org.openhab.binding.rfxcom.internal.RFXComTestHelper.commandChannelUID;
import java.nio.ByteBuffer;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.jupiter.api.Test;
+import org.openhab.binding.rfxcom.internal.RFXComBindingConstants;
import org.openhab.binding.rfxcom.internal.config.RFXComRawDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidStateException;
import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
import org.openhab.core.library.types.OnOffType;
-import org.openhab.core.types.Command;
+import org.openhab.core.types.Type;
import org.openhab.core.util.HexUtils;
/**
@@ -34,6 +34,7 @@
*/
@NonNullByDefault
public class RFXComRawMessageTest {
+
private void testMessageRx(String hexMsg, RFXComRawMessage.SubType subType, int seqNbr, int repeat, String pulses)
throws RFXComException {
final RFXComRawMessage msg = (RFXComRawMessage) RFXComMessageFactoryImpl.INSTANCE
@@ -52,10 +53,11 @@ public void testSomeRxMessages() throws RFXComException {
testMessageRx("087F0027051356ECC0", RFXComRawMessage.SubType.RAW_PACKET1, 0x27, 5, "1356ECC0");
}
- private void testMessageTx(RFXComRawDeviceConfiguration config, Command command, String hexMsg)
+ private void testMessageTx(RFXComRawDeviceConfiguration config, Type command, String hexMsg)
throws RFXComException {
- RFXComRawMessage msg = (RFXComRawMessage) RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.RAW,
- config, commandChannelUID, command);
+ RFXComRawMessage msg = (RFXComRawMessage) RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.RAW);
+ msg.setConfig(config);
+ msg.convertFromState(RFXComBindingConstants.CHANNEL_COMMAND, command);
byte[] decoded = msg.decodeMessage();
assertEquals(hexMsg, HexUtils.bytesToHex(decoded), "Transmitted message");
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRemoteControlMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRemoteControlMessageTest.java
index 6449de7407d3..6480e870ebba 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRemoteControlMessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRemoteControlMessageTest.java
@@ -29,6 +29,6 @@ public class RFXComRemoteControlMessageTest {
@Test
public void checkNotImplemented() {
assertThrows(RFXComMessageNotImplementedException.class,
- () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.REMOTE_CONTROL, null, null, null));
+ () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.REMOTE_CONTROL));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRfyMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRfyMessageTest.java
index 0511b43d4e77..bc51015ed478 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRfyMessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRfyMessageTest.java
@@ -13,21 +13,13 @@
package org.openhab.binding.rfxcom.internal.messages;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.openhab.binding.rfxcom.internal.RFXComTestHelper.thingUID;
import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.RFY;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.jupiter.api.Test;
-import org.openhab.binding.rfxcom.internal.RFXComBindingConstants;
-import org.openhab.binding.rfxcom.internal.RFXComTestHelper;
-import org.openhab.binding.rfxcom.internal.config.RFXComGenericDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
+import org.openhab.binding.rfxcom.internal.messages.RFXComRfyMessage.Commands;
import org.openhab.binding.rfxcom.internal.messages.RFXComRfyMessage.SubType;
-import org.openhab.core.library.types.IncreaseDecreaseType;
-import org.openhab.core.library.types.OpenClosedType;
-import org.openhab.core.library.types.UpDownType;
-import org.openhab.core.thing.ChannelUID;
-import org.openhab.core.types.Command;
import org.openhab.core.util.HexUtils;
/**
@@ -37,40 +29,33 @@
*/
@NonNullByDefault
public class RFXComRfyMessageTest {
- private static ChannelUID shutterChannelUID = new ChannelUID(thingUID, RFXComBindingConstants.CHANNEL_SHUTTER);
- private static ChannelUID venetionBlindChannelUID = new ChannelUID(thingUID,
- RFXComBindingConstants.CHANNEL_VENETIAN_BLIND);
@Test
public void basicBoundaryCheck() throws RFXComException {
- RFXComGenericDeviceConfiguration config = new RFXComGenericDeviceConfiguration();
- config.deviceId = "1.1";
- config.subType = SubType.RFY.toString();
+ RFXComRfyMessage message = (RFXComRfyMessage) RFXComMessageFactoryImpl.INSTANCE.createMessage(RFY);
- RFXComRfyMessage message = (RFXComRfyMessage) RFXComMessageFactoryImpl.INSTANCE.createMessage(RFY, config,
- shutterChannelUID, UpDownType.UP);
+ message.subType = SubType.RFY;
+ message.command = Commands.UP;
RFXComTestHelper.basicBoundaryCheck(RFY, message);
}
- private void testMessage(SubType subType, Command command, String deviceId, String data) throws RFXComException {
- RFXComGenericDeviceConfiguration config = new RFXComGenericDeviceConfiguration();
- config.deviceId = "66051.4";
- config.subType = subType.toString();
-
- RFXComRfyMessage message = (RFXComRfyMessage) RFXComMessageFactoryImpl.INSTANCE.createMessage(RFY, config,
- venetionBlindChannelUID, command);
+ private void testMessage(SubType subType, Commands command, String deviceId, String data) throws RFXComException {
+ RFXComRfyMessage message = (RFXComRfyMessage) RFXComMessageFactoryImpl.INSTANCE.createMessage(RFY);
+ message.setSubType(subType);
+ message.command = command;
+ message.setDeviceId(deviceId);
assertArrayEquals(HexUtils.hexToBytes(data), message.decodeMessage());
}
@Test
public void testMessage1() throws RFXComException {
- testMessage(SubType.RFY, OpenClosedType.OPEN, "66051.4", "0C1A0000010203040F00000000");
+ testMessage(SubType.RFY, Commands.UP_SHORT, "66051.4", "0C1A0000010203040F00000000");
}
@Test
public void testMessage2() throws RFXComException {
- testMessage(SubType.ASA, IncreaseDecreaseType.INCREASE, "66051.4", "0C1A0300010203041200000000");
+ testMessage(SubType.ASA, Commands.DOWN_LONG, "66051.4", "0C1A0300010203041200000000");
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComTestHelper.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComTestHelper.java
new file mode 100644
index 000000000000..fe7926078f5e
--- /dev/null
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComTestHelper.java
@@ -0,0 +1,63 @@
+/**
+ * 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.rfxcom.internal.messages;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.Map;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
+import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
+import org.openhab.core.config.discovery.DiscoveryResultBuilder;
+import org.openhab.core.library.types.DecimalType;
+import org.openhab.core.thing.ThingUID;
+
+/**
+ * Helper class for testing the RFXCom-binding
+ *
+ * @author Martin van Wingerden - Initial contribution
+ */
+@NonNullByDefault
+class RFXComTestHelper {
+ static void basicBoundaryCheck(PacketType packetType, RFXComMessage message) throws RFXComException {
+ // This is a place where its easy to make mistakes in coding, and can result in errors, normally
+ // array bounds errors
+ byte[] binaryMessage = message.decodeMessage();
+ assertEquals(binaryMessage[0], binaryMessage.length - 1, "Wrong packet length");
+ assertEquals(packetType.toByte(), binaryMessage[1], "Wrong packet type");
+ }
+
+ static void checkDiscoveryResult(RFXComDeviceMessage msg, String deviceId, @Nullable Integer pulse, String subType,
+ int offCommand, int onCommand) throws RFXComException {
+ String thingUID = "homeduino:rfxcom:fssfsd:thing";
+ DiscoveryResultBuilder builder = DiscoveryResultBuilder.create(new ThingUID(thingUID));
+
+ // check whether the pulse is stored
+ msg.addDevicePropertiesTo(builder);
+
+ Map properties = builder.build().getProperties();
+ assertEquals(deviceId, properties.get("deviceId"), "Device Id");
+ assertEquals(subType, properties.get("subType"), "Sub type");
+ if (pulse != null) {
+ assertEquals(pulse, properties.get("pulse"), "Pulse");
+ }
+ assertEquals(onCommand, properties.get("onCommandId"), "On command");
+ assertEquals(offCommand, properties.get("offCommandId"), "Off command");
+ }
+
+ static int getActualIntValue(RFXComDeviceMessage msg, String channelId) throws RFXComException {
+ return ((DecimalType) msg.convertToState(channelId, new MockDeviceState())).intValue();
+ }
+}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat2MessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat2MessageTest.java
index fb61a52008ad..c582dc67426f 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat2MessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat2MessageTest.java
@@ -30,6 +30,6 @@ public class RFXComThermostat2MessageTest {
public void checkNotImplemented() {
// TODO Note that this message is supported in the 1.9 binding
assertThrows(RFXComMessageNotImplementedException.class,
- () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.THERMOSTAT2, null, null, null));
+ () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.THERMOSTAT2));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat3MessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat3MessageTest.java
index 431358e11ca9..fc4319441bd5 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat3MessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat3MessageTest.java
@@ -14,16 +14,14 @@
import static org.junit.jupiter.api.Assertions.*;
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
-import static org.openhab.binding.rfxcom.internal.RFXComTestHelper.commandChannelUID;
import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.THERMOSTAT3;
import static org.openhab.binding.rfxcom.internal.messages.RFXComThermostat3Message.SubType.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.junit.jupiter.api.Test;
-import org.openhab.binding.rfxcom.internal.RFXComTestHelper;
-import org.openhab.binding.rfxcom.internal.config.RFXComGenericDeviceConfiguration;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
+import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.StopMoveType;
import org.openhab.core.library.types.StringType;
@@ -39,24 +37,20 @@
*/
@NonNullByDefault
public class RFXComThermostat3MessageTest {
- private static RFXComGenericDeviceConfiguration config = new RFXComGenericDeviceConfiguration();
-
- static {
- config.deviceId = "106411";
- config.subType = RFXComThermostat3Message.SubType.MERTIK__G6R_H4S_TRANSMIT_ONLY.toString();
- }
-
private final MockDeviceState deviceState = new MockDeviceState();
@Test
public void checkForSupportTest() throws RFXComException {
- RFXComMessageFactoryImpl.INSTANCE.createMessage(THERMOSTAT3, config, commandChannelUID, OnOffType.ON);
+ RFXComMessageFactoryImpl.INSTANCE.createMessage(THERMOSTAT3);
}
@Test
public void basicBoundaryCheck() throws RFXComException {
RFXComThermostat3Message message = (RFXComThermostat3Message) RFXComMessageFactoryImpl.INSTANCE
- .createMessage(THERMOSTAT3, config, commandChannelUID, OnOffType.ON);
+ .createMessage(THERMOSTAT3);
+
+ message.subType = RFXComThermostat3Message.SubType.MERTIK__G6R_H4S_TRANSMIT_ONLY;
+ message.command = RFXComThermostat3Message.Commands.ON;
RFXComTestHelper.basicBoundaryCheck(THERMOSTAT3, message);
}
@@ -83,212 +77,213 @@ private void testMessage(String hexMessage, RFXComThermostat3Message.SubType sub
assertEquals(command, msg.command, CHANNEL_COMMAND);
assertEquals(signalLevel, msg.signalLevel, "Signal Level");
- assertEquals(commandChannel, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(secondCommandChannel, msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
- assertEquals(controlChannel, msg.convertToState(CHANNEL_CONTROL, config, deviceState));
- assertEquals(commandStringChannel, msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(commandChannel, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(secondCommandChannel, msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
+ assertEquals(controlChannel, msg.convertToState(CHANNEL_CONTROL, deviceState));
+ assertEquals(commandStringChannel, msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
byte[] decoded = msg.decodeMessage();
assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
}
+ // TODO please add tests for real messages
@Test
- public void testCommandChannelOn() throws RFXComException {
+ public void testCommandChannelOn() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_COMMAND, OnOffType.ON);
- assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_CONTROL, config, deviceState));
- assertEquals(StringType.valueOf("ON"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
- assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
+ assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_CONTROL, deviceState));
+ assertEquals(StringType.valueOf("ON"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
}
@Test
- public void testCommandChannelOff() throws RFXComException {
+ public void testCommandChannelOff() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_COMMAND, OnOffType.OFF);
- assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_CONTROL, config, deviceState));
- assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
- assertEquals(StringType.valueOf("OFF"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_CONTROL, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
+ assertEquals(StringType.valueOf("OFF"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
}
@Test
- public void testSecondCommandChannelOn() throws RFXComException {
+ public void testSecondCommandChannelOn() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_COMMAND_SECOND, OnOffType.ON);
- assertNull(msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
- assertNull(msg.convertToState(CHANNEL_CONTROL, config, deviceState));
- assertEquals(StringType.valueOf("SECOND_ON"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
+ assertNull(msg.convertToState(CHANNEL_CONTROL, deviceState));
+ assertEquals(StringType.valueOf("SECOND_ON"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
}
@Test
- public void testSecondCommandChannelOff() throws RFXComException {
+ public void testSecondCommandChannelOff() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_COMMAND_SECOND, OnOffType.OFF);
- assertNull(msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
- assertNull(msg.convertToState(CHANNEL_CONTROL, config, deviceState));
- assertEquals(StringType.valueOf("SECOND_OFF"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
+ assertNull(msg.convertToState(CHANNEL_CONTROL, deviceState));
+ assertEquals(StringType.valueOf("SECOND_OFF"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
}
@Test
- public void testControlUp() throws RFXComException {
+ public void testControlUp() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_CONTROL, UpDownType.UP);
- assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(UpDownType.UP, msg.convertToState(CHANNEL_CONTROL, config, deviceState));
- assertEquals(StringType.valueOf("UP"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(UpDownType.UP, msg.convertToState(CHANNEL_CONTROL, deviceState));
+ assertEquals(StringType.valueOf("UP"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
- assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
}
@Test
- public void testControlDown() throws RFXComException {
+ public void testControlDown() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_CONTROL, UpDownType.DOWN);
- assertEquals(UnDefType.UNDEF, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(UpDownType.DOWN, msg.convertToState(CHANNEL_CONTROL, config, deviceState));
- assertEquals(StringType.valueOf("DOWN"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(UnDefType.UNDEF, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(UpDownType.DOWN, msg.convertToState(CHANNEL_CONTROL, deviceState));
+ assertEquals(StringType.valueOf("DOWN"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
- assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
}
@Test
- public void testControlStop() throws RFXComException {
+ public void testControlStop() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_CONTROL, StopMoveType.STOP);
- assertEquals(UnDefType.UNDEF, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(StringType.valueOf("STOP"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(UnDefType.UNDEF, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(StringType.valueOf("STOP"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
- assertNull(msg.convertToState(CHANNEL_CONTROL, config, deviceState));
- assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
+ assertNull(msg.convertToState(CHANNEL_CONTROL, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
}
@Test
- public void testCommandStringOff() throws RFXComException {
+ public void testCommandStringOff() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("OFF"));
- assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_CONTROL, config, deviceState));
- assertEquals(StringType.valueOf("OFF"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
- assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
+ assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_CONTROL, deviceState));
+ assertEquals(StringType.valueOf("OFF"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
}
@Test
- public void testCommandStringOn() throws RFXComException {
+ public void testCommandStringOn() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("On"));
- assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_CONTROL, config, deviceState));
- assertEquals(StringType.valueOf("ON"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
- assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
+ assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_CONTROL, deviceState));
+ assertEquals(StringType.valueOf("ON"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
}
@Test
- public void testCommandStringUp() throws RFXComException {
+ public void testCommandStringUp() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("UP"));
- assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(UpDownType.UP, msg.convertToState(CHANNEL_CONTROL, config, deviceState));
- assertEquals(StringType.valueOf("UP"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(UpDownType.UP, msg.convertToState(CHANNEL_CONTROL, deviceState));
+ assertEquals(StringType.valueOf("UP"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
- assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
}
@Test
- public void testCommandStringDown() throws RFXComException {
+ public void testCommandStringDown() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("down"));
- assertEquals(UnDefType.UNDEF, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(UpDownType.DOWN, msg.convertToState(CHANNEL_CONTROL, config, deviceState));
- assertEquals(StringType.valueOf("DOWN"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
- assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
+ assertEquals(UnDefType.UNDEF, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(UpDownType.DOWN, msg.convertToState(CHANNEL_CONTROL, deviceState));
+ assertEquals(StringType.valueOf("DOWN"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
}
@Test
- public void testCommandStringRunUp() throws RFXComException {
+ public void testCommandStringRunUp() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("RUN_UP"));
- assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(UpDownType.UP, msg.convertToState(CHANNEL_CONTROL, config, deviceState));
- assertEquals(StringType.valueOf("RUN_UP"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
- assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
+ assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(UpDownType.UP, msg.convertToState(CHANNEL_CONTROL, deviceState));
+ assertEquals(StringType.valueOf("RUN_UP"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
}
@Test
- public void testCommandStringRunDown() throws RFXComException {
+ public void testCommandStringRunDown() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("RUN_DOWN"));
- assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(UpDownType.DOWN, msg.convertToState(CHANNEL_CONTROL, config, deviceState));
- assertEquals(StringType.valueOf("RUN_DOWN"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
- assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
+ assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(UpDownType.DOWN, msg.convertToState(CHANNEL_CONTROL, deviceState));
+ assertEquals(StringType.valueOf("RUN_DOWN"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
}
@Test
- public void testCommandStringStop() throws RFXComException {
+ public void testCommandStringStop() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("STOP"));
- assertEquals(UnDefType.UNDEF, msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertEquals(StringType.valueOf("STOP"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(UnDefType.UNDEF, msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertEquals(StringType.valueOf("STOP"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
- assertNull(msg.convertToState(CHANNEL_CONTROL, config, deviceState));
- assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
+ assertNull(msg.convertToState(CHANNEL_CONTROL, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
}
@Test
- public void testCommandStringSecondOn() throws RFXComException {
+ public void testCommandStringSecondOn() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("SECOND_ON"));
- assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
- assertEquals(StringType.valueOf("SECOND_ON"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(OnOffType.ON, msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
+ assertEquals(StringType.valueOf("SECOND_ON"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
- assertNull(msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertNull(msg.convertToState(CHANNEL_CONTROL, config, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertNull(msg.convertToState(CHANNEL_CONTROL, deviceState));
}
@Test
- public void testCommandStringSecondOff() throws RFXComException {
+ public void testCommandStringSecondOff() throws RFXComUnsupportedChannelException {
RFXComThermostat3Message msg = new RFXComThermostat3Message();
msg.convertFromState(CHANNEL_COMMAND_STRING, StringType.valueOf("SECOND_OFF"));
- assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_COMMAND_SECOND, config, deviceState));
- assertEquals(StringType.valueOf("SECOND_OFF"), msg.convertToState(CHANNEL_COMMAND_STRING, config, deviceState));
+ assertEquals(OnOffType.OFF, msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
+ assertEquals(StringType.valueOf("SECOND_OFF"), msg.convertToState(CHANNEL_COMMAND_STRING, deviceState));
- assertNull(msg.convertToState(CHANNEL_COMMAND, config, deviceState));
- assertNull(msg.convertToState(CHANNEL_CONTROL, config, deviceState));
+ assertNull(msg.convertToState(CHANNEL_COMMAND, deviceState));
+ assertNull(msg.convertToState(CHANNEL_CONTROL, deviceState));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat4MessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat4MessageTest.java
index d6e6d9faceec..a724aa902462 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat4MessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat4MessageTest.java
@@ -29,6 +29,6 @@ public class RFXComThermostat4MessageTest {
@Test
public void checkNotImplemented() {
assertThrows(RFXComMessageNotImplementedException.class,
- () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(THERMOSTAT4, null, null, null));
+ () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(THERMOSTAT4));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComUndecodedRFMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComUndecodedRFMessageTest.java
index 09bc5d3a57be..0fe249b5edfc 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComUndecodedRFMessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComUndecodedRFMessageTest.java
@@ -18,6 +18,7 @@
import org.junit.jupiter.api.Test;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageTooLongException;
+import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
import org.openhab.core.util.HexUtils;
/**
@@ -50,9 +51,12 @@ public void testSomeMessages() throws RFXComException {
@Test
public void testLongMessage() throws RFXComException {
- assertThrows(RFXComMessageTooLongException.class,
- () -> testMessage("25030101000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021",
- RFXComUndecodedRFMessage.SubType.ARC, 0x01,
- "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021"));
+ RFXComUndecodedRFMessage msg = (RFXComUndecodedRFMessage) RFXComMessageFactoryImpl.INSTANCE
+ .createMessage(PacketType.UNDECODED_RF_MESSAGE);
+ msg.subType = RFXComUndecodedRFMessage.SubType.ARC;
+ msg.seqNbr = 1;
+ msg.rawPayload = HexUtils.hexToBytes("000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021");
+
+ assertThrows(RFXComMessageTooLongException.class, () -> msg.decodeMessage());
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComWaterMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComWaterMessageTest.java
index 52ebe29e008d..163fd5c635f0 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComWaterMessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComWaterMessageTest.java
@@ -30,6 +30,6 @@ public class RFXComWaterMessageTest {
@Test
public void checkNotImplemented() {
assertThrows(RFXComMessageNotImplementedException.class,
- () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.WATER, null, null, null));
+ () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.WATER));
}
}
diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComWeightMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComWeightMessageTest.java
index bb57550b64a9..96789f029278 100644
--- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComWeightMessageTest.java
+++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComWeightMessageTest.java
@@ -30,6 +30,6 @@ public class RFXComWeightMessageTest {
public void checkNotImplemented() {
// TODO Note that this message is supported in the 1.9 binding
assertThrows(RFXComMessageNotImplementedException.class,
- () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.WEIGHT, null, null, null));
+ () -> RFXComMessageFactoryImpl.INSTANCE.createMessage(PacketType.WEIGHT));
}
}