mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[enocean] Fix unusable bundle after a refactoring about null annotation (#15302)
Fix bundle unusable after #14023 (closes #15181) Fix a case issue with some directory Fix trigger channel issue Signed-off-by: Gwendal Roulleau <gwendal.roulleau@gmail.com>
This commit is contained in:
parent
6dccbcb005
commit
2961593cfd
@ -49,7 +49,7 @@ public class A5_20_04 extends A5_20 {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
|
||||
Configuration config) {
|
||||
switch (channelId) {
|
||||
case CHANNEL_STATUS_REQUEST_EVENT:
|
||||
|
@ -48,7 +48,7 @@ public class D2_03_0A extends _VLDMessage {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
|
||||
Configuration config) {
|
||||
switch (channelId) {
|
||||
case CHANNEL_PUSHBUTTON:
|
||||
|
@ -38,7 +38,7 @@ import org.openhab.core.types.UnDefType;
|
||||
* battery channels may be not supported by the physical device (depending on the actual model). If a channel is not
|
||||
* supported by a device it will transmit a 'not supported' message which is ignored by this implementation.
|
||||
* Consequently channels that are not supported by the physical device will never send updates to linked items.
|
||||
*
|
||||
*
|
||||
* @author Thomas Lauterbach - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
@ -164,7 +164,7 @@ public class D2_06_01 extends _VLDMessage {
|
||||
}
|
||||
|
||||
protected State getTemperature() {
|
||||
double unscaledTemp = (double) (bytes[5] & 0xFF);
|
||||
double unscaledTemp = bytes[5] & 0xFF;
|
||||
if (unscaledTemp <= 250) {
|
||||
double scaledTemp = unscaledTemp * 0.32 - 20;
|
||||
return new QuantityType<>(scaledTemp, SIUnits.CELSIUS);
|
||||
@ -198,7 +198,7 @@ public class D2_06_01 extends _VLDMessage {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
|
||||
Configuration config) {
|
||||
// Sensor values
|
||||
if (bytes[0] == MessageType.SENSORVALUES.getIntValue()) {
|
||||
|
@ -115,7 +115,7 @@ public class D2_06_50 extends _VLDMessage {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
|
||||
Configuration config) {
|
||||
// Alarm
|
||||
if (bytes[0] == 0x02) {
|
||||
|
@ -114,7 +114,7 @@ public abstract class EEP {
|
||||
return convertToStateImpl(channelId, channelTypeId, getCurrentStateFunc, config);
|
||||
}
|
||||
|
||||
public @Nullable String convertToEvent(String channelId, String channelTypeId, String lastEvent,
|
||||
public @Nullable String convertToEvent(String channelId, String channelTypeId, @Nullable String lastEvent,
|
||||
Configuration config) {
|
||||
if (!getEEPType().isChannelSupported(channelId, channelTypeId)) {
|
||||
throw new IllegalArgumentException(
|
||||
@ -223,7 +223,7 @@ public abstract class EEP {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
|
||||
Configuration config) {
|
||||
return null;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class F6_01_01 extends _RPSMessage {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
|
||||
Configuration config) {
|
||||
return getBit(bytes[0], 4) ? CommonTriggerEvents.PRESSED : CommonTriggerEvents.RELEASED;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class F6_02_01 extends F6_02 {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
|
||||
Configuration config) {
|
||||
if (t21 && nu) {
|
||||
if (CHANNEL_ROCKERSWITCH_ACTION.equals(channelTypeId)) {
|
||||
@ -59,7 +59,7 @@ public class F6_02_01 extends F6_02 {
|
||||
} else if (t21 && !nu) {
|
||||
if (CHANNEL_ROCKERSWITCH_ACTION.equals(channelTypeId)) {
|
||||
return CommonTriggerEvents.RELEASED;
|
||||
} else {
|
||||
} else if (lastEvent != null) {
|
||||
if (lastEvent.equals(CommonTriggerEvents.DIR1_PRESSED)) {
|
||||
return CommonTriggerEvents.DIR1_RELEASED;
|
||||
} else if (lastEvent.equals(CommonTriggerEvents.DIR2_PRESSED)) {
|
||||
|
@ -45,7 +45,7 @@ public class F6_02_02 extends F6_02 {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
|
||||
protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
|
||||
Configuration config) {
|
||||
if (t21 && nu) {
|
||||
if (CHANNEL_ROCKERSWITCH_ACTION.equals(channelTypeId)) {
|
||||
@ -58,7 +58,7 @@ public class F6_02_02 extends F6_02 {
|
||||
} else if (t21 && !nu) {
|
||||
if (CHANNEL_ROCKERSWITCH_ACTION.equals(channelTypeId)) {
|
||||
return CommonTriggerEvents.RELEASED;
|
||||
} else {
|
||||
} else if (lastEvent != null) {
|
||||
if (lastEvent.equals(CommonTriggerEvents.DIR1_PRESSED)) {
|
||||
return CommonTriggerEvents.DIR1_RELEASED;
|
||||
} else if (lastEvent.equals(CommonTriggerEvents.DIR2_PRESSED)) {
|
||||
|
@ -189,13 +189,10 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements
|
||||
break;
|
||||
case TRIGGER:
|
||||
String lastEvent = lastEvents.get(channelId);
|
||||
if (lastEvent != null) {
|
||||
String event = eep.convertToEvent(channelId, channelTypeId, lastEvent,
|
||||
channelConfig);
|
||||
if (event != null) {
|
||||
triggerChannel(channel.getUID(), event);
|
||||
lastEvents.put(channelId, event);
|
||||
}
|
||||
String event = eep.convertToEvent(channelId, channelTypeId, lastEvent, channelConfig);
|
||||
if (event != null) {
|
||||
triggerChannel(channel.getUID(), event);
|
||||
lastEvents.put(channelId, event);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
|
||||
}
|
||||
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_PENDING, "opening serial port...");
|
||||
localTransceiver.initilize();
|
||||
localTransceiver.initialize();
|
||||
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_PENDING, "starting rx thread...");
|
||||
localTransceiver.startReceiving(scheduler);
|
||||
|
@ -180,7 +180,7 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public void initilize()
|
||||
public void initialize()
|
||||
throws UnsupportedCommOperationException, PortInUseException, IOException, TooManyListenersException {
|
||||
SerialPortManager localSerialPortManager = serialPortManager;
|
||||
if (localSerialPortManager == null) {
|
||||
@ -224,7 +224,7 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
|
||||
@Nullable
|
||||
Future<?> localReadingTask = readingTask;
|
||||
if (localReadingTask == null || localReadingTask.isCancelled()) {
|
||||
localReadingTask = scheduler.submit(new Runnable() {
|
||||
readingTask = scheduler.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
receivePackets();
|
||||
@ -313,13 +313,24 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
|
||||
InputStream localInputStream = inputStream;
|
||||
if (localInputStream != null) {
|
||||
try {
|
||||
localInputStream.read(buffer, 0, length);
|
||||
return localInputStream.read(buffer, 0, length);
|
||||
} catch (IOException e) {
|
||||
logger.debug("IOException occured while reading the input stream", e);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
logger.warn("Cannot read from null stream");
|
||||
Future<?> localReadingTask = readingTask;
|
||||
if (localReadingTask != null) {
|
||||
localReadingTask.cancel(true);
|
||||
readingTask = null;
|
||||
}
|
||||
TransceiverErrorListener localListener = errorListener;
|
||||
if (localListener != null) {
|
||||
localListener.errorOccured(new IOException("Cannot read from null stream"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected void informListeners(BasePacket packet) {
|
||||
|
Loading…
Reference in New Issue
Block a user