From 75b5110935f601feec02c789ef153c79e58a833e Mon Sep 17 00:00:00 2001 From: Leo Siepel Date: Tue, 24 Dec 2024 20:15:27 +0100 Subject: [PATCH 1/6] Update async-http-client Signed-off-by: Leo Siepel --- bundles/org.openhab.binding.tellstick/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.tellstick/pom.xml b/bundles/org.openhab.binding.tellstick/pom.xml index 05f2bd68f4dba..0667c8ae4a1c1 100644 --- a/bundles/org.openhab.binding.tellstick/pom.xml +++ b/bundles/org.openhab.binding.tellstick/pom.xml @@ -36,13 +36,13 @@ org.asynchttpclient async-http-client - 2.10.4 + 2.12.4 compile org.asynchttpclient async-http-client-netty-utils - 2.10.4 + 2.12.4 compile From f6e7960ce5ddc8a58b536b7345577207759a96b8 Mon Sep 17 00:00:00 2001 From: Leo Siepel Date: Tue, 24 Dec 2024 21:08:19 +0100 Subject: [PATCH 2/6] Add annotations and fix some warnings Signed-off-by: Leo Siepel --- .../internal/TelldusBindingException.java | 5 +- .../internal/TellstickRuntimeException.java | 3 ++ .../conf/TelldusLiveConfiguration.java | 13 +++-- .../conf/TelldusLocalConfiguration.java | 7 ++- .../conf/TellstickBridgeConfiguration.java | 7 ++- .../core/TelldusCoreBridgeHandler.java | 34 ++++++++----- .../core/TelldusCoreDeviceController.java | 17 ++++--- .../discovery/TellstickBridgeDiscovery.java | 2 + .../discovery/TellstickDiscoveryService.java | 11 ++-- .../handler/DeviceStatusListener.java | 4 +- .../handler/TelldusBridgeHandler.java | 6 +++ .../handler/TelldusDeviceController.java | 4 ++ .../handler/TelldusDevicesHandler.java | 28 +++++----- .../live/TelldusLiveBridgeHandler.java | 51 +++++++++++-------- .../live/TelldusLiveDeviceController.java | 31 ++++++----- .../internal/live/TelldusLiveException.java | 5 +- .../live/{xml => dto}/DataTypeValue.java | 2 +- .../live/{xml => dto}/LiveDataType.java | 2 +- .../live/{xml => dto}/NameToDataType.java | 2 +- .../{xml => dto}/NumberToBooleanMapper.java | 2 +- .../{xml => dto}/TelldusLiveResponse.java | 2 +- .../live/{xml => dto}/TellstickNetDevice.java | 2 +- .../{xml => dto}/TellstickNetDevices.java | 2 +- .../live/{xml => dto}/TellstickNetSensor.java | 2 +- .../{xml => dto}/TellstickNetSensorEvent.java | 2 +- .../{xml => dto}/TellstickNetSensors.java | 2 +- .../local/TelldusLocalBridgeHandler.java | 33 +++++++----- .../local/TelldusLocalDeviceController.java | 10 ++-- .../internal/local/TelldusLocalException.java | 4 +- .../local/dto/LocalDataTypeValueDTO.java | 2 +- .../local/dto/TellstickLocalSensorDTO.java | 2 +- 31 files changed, 189 insertions(+), 110 deletions(-) rename bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/{xml => dto}/DataTypeValue.java (96%) rename bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/{xml => dto}/LiveDataType.java (95%) rename bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/{xml => dto}/NameToDataType.java (93%) rename bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/{xml => dto}/NumberToBooleanMapper.java (93%) rename bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/{xml => dto}/TelldusLiveResponse.java (93%) rename bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/{xml => dto}/TellstickNetDevice.java (98%) rename bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/{xml => dto}/TellstickNetDevices.java (94%) rename bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/{xml => dto}/TellstickNetSensor.java (98%) rename bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/{xml => dto}/TellstickNetSensorEvent.java (95%) rename bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/{xml => dto}/TellstickNetSensors.java (94%) diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/TelldusBindingException.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/TelldusBindingException.java index 3485b0151afcf..a64b9c9329848 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/TelldusBindingException.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/TelldusBindingException.java @@ -12,6 +12,8 @@ */ package org.openhab.binding.tellstick.internal; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.tellstick.device.TellstickException; /** @@ -20,6 +22,7 @@ * * @author Jarle Hjortland - Initial contribution */ +@NonNullByDefault public class TelldusBindingException extends TellstickException { private static final long serialVersionUID = 30671795474333158L; @@ -32,7 +35,7 @@ public TelldusBindingException(String message) { } @Override - public String getMessage() { + public @Nullable String getMessage() { return msg; } } diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/TellstickRuntimeException.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/TellstickRuntimeException.java index 600f4d3ff9bed..340884454bf9c 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/TellstickRuntimeException.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/TellstickRuntimeException.java @@ -12,11 +12,14 @@ */ package org.openhab.binding.tellstick.internal; +import org.eclipse.jdt.annotation.NonNullByDefault; + /** * Runtime exception in tellstick binding. * * @author Jarle Hjortland - Initial contribution */ +@NonNullByDefault public class TellstickRuntimeException extends RuntimeException { private static final long serialVersionUID = -1644730263645760297L; diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TelldusLiveConfiguration.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TelldusLiveConfiguration.java index 4c1b34f3992af..b5479df6109f8 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TelldusLiveConfiguration.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TelldusLiveConfiguration.java @@ -12,16 +12,19 @@ */ package org.openhab.binding.tellstick.internal.conf; +import org.eclipse.jdt.annotation.NonNullByDefault; + /** * Configuration class for Tellstick bridge used to connect to the * Telldus Live service. * * @author Jarle Hjortland - Initial contribution */ +@NonNullByDefault public class TelldusLiveConfiguration { - public String publicKey; - public String privateKey; - public String token; - public String tokenSecret; - public long refreshInterval; + public String publicKey = ""; + public String privateKey = ""; + public String token = ""; + public String tokenSecret = ""; + public long refreshInterval = 60000; } diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TelldusLocalConfiguration.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TelldusLocalConfiguration.java index 08bad3bc03b9f..b320765b7be9c 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TelldusLocalConfiguration.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TelldusLocalConfiguration.java @@ -12,14 +12,17 @@ */ package org.openhab.binding.tellstick.internal.conf; +import org.eclipse.jdt.annotation.NonNullByDefault; + /** * Configuration class for Tellstick bridge used to connect to the * Telldus local API. * * @author Jan Gustafsson - Initial contribution */ +@NonNullByDefault public class TelldusLocalConfiguration { - public String ipAddress; - public String accessToken; + public String ipAddress = ""; + public String accessToken = ""; public long refreshInterval; } diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TellstickBridgeConfiguration.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TellstickBridgeConfiguration.java index ccd883958811f..cb2d3a68138d4 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TellstickBridgeConfiguration.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TellstickBridgeConfiguration.java @@ -12,13 +12,16 @@ */ package org.openhab.binding.tellstick.internal.conf; +import org.eclipse.jdt.annotation.NonNullByDefault; + /** * Configuration class for Tellstick bridge used to connect to the * Telldus Core service on the local machine. * * @author Jarle Hjortland - Initial contribution */ +@NonNullByDefault public class TellstickBridgeConfiguration { - public int resendInterval; - public String libraryPath; + public String libraryPath = "C:/Program Files/Telldus/;C:/Program Files (x86)/Telldus/"; + public int resendInterval = 100; } diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreBridgeHandler.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreBridgeHandler.java index 97b3f701be171..418a68210383d 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreBridgeHandler.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreBridgeHandler.java @@ -20,6 +20,8 @@ import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.tellstick.internal.conf.TellstickBridgeConfiguration; import org.openhab.binding.tellstick.internal.handler.DeviceStatusListener; import org.openhab.binding.tellstick.internal.handler.TelldusBridgeHandler; @@ -54,6 +56,7 @@ * * @author Jarle Hjortland - Initial contribution */ +@NonNullByDefault public class TelldusCoreBridgeHandler extends BaseBridgeHandler implements DeviceChangeListener, SensorListener, TelldusBridgeHandler { @@ -62,10 +65,10 @@ public TelldusCoreBridgeHandler(Bridge br) { } private Logger logger = LoggerFactory.getLogger(TelldusCoreBridgeHandler.class); - private TelldusDeviceController deviceController = null; + private @Nullable TelldusDeviceController deviceController; private List deviceList = new Vector<>(); private List sensorList = new Vector<>(); - private TellstickEventHandler eventHandler; + private @Nullable TellstickEventHandler eventHandler; private static boolean initialized = false; private Set deviceStatusListeners = ConcurrentHashMap.newKeySet(); @@ -82,10 +85,13 @@ public void handleCommand(ChannelUID channelUID, Command command) { @Override public void dispose() { logger.debug("Telldus Core Handler disposed."); + TelldusDeviceController deviceController = this.deviceController; if (deviceController != null) { deviceController.dispose(); deviceController = null; } + + TellstickEventHandler eventHandler = this.eventHandler; if (eventHandler != null) { eventHandler.remove(); eventHandler = null; @@ -96,7 +102,7 @@ public void dispose() { super.dispose(); } - private String init(String libraryPath) { + private @Nullable String init(@Nullable String libraryPath) { if (!initialized) { if (libraryPath != null) { logger.info("Loading {} from {}", JNA.nativeLibrary, libraryPath); @@ -131,7 +137,10 @@ public void initialize() { private void setupDeviceController(TellstickBridgeConfiguration configuration) { deviceController = new TelldusCoreDeviceController(configuration.resendInterval, "OH-binding-" + getThing().getUID() + "-worker"); - eventHandler.addListener((TelldusCoreDeviceController) deviceController); + TellstickEventHandler eventHandler = this.eventHandler; + if (eventHandler != null) { + eventHandler.addListener((TelldusCoreDeviceController) deviceController); + } } @Override @@ -168,8 +177,9 @@ public void rescanTelldusDevices() { } private synchronized void setupListeners() { - eventHandler = new TellstickEventHandler(deviceList); + TellstickEventHandler eventHandler = new TellstickEventHandler(deviceList); eventHandler.addListener(this); + this.eventHandler = eventHandler; } public void onConnectionLost() { @@ -183,7 +193,7 @@ public void onConnection() { } @Override - public boolean registerDeviceStatusListener(DeviceStatusListener deviceStatusListener) { + public boolean registerDeviceStatusListener(@Nullable DeviceStatusListener deviceStatusListener) { if (deviceStatusListener == null) { throw new IllegalArgumentException("It's not allowed to pass a null deviceStatusListener."); } @@ -200,7 +210,7 @@ public void clearDeviceList() { sensorList.clear(); } - private Device getDevice(String id, List devices) { + private @Nullable Device getDevice(String id, List devices) { for (Device device : devices) { if (device.getId() == Integer.valueOf(id)) { return device; @@ -210,12 +220,12 @@ private Device getDevice(String id, List devices) { } @Override - public Device getDevice(String serialNumber) { + public @Nullable Device getDevice(String serialNumber) { return getDevice(serialNumber, deviceList); } @Override - public void onRequest(TellstickSensorEvent newEvent) { + public void onRequest(@NonNullByDefault({}) TellstickSensorEvent newEvent) { String uuid = TellstickSensor.createUUId(newEvent.getSensorId(), newEvent.getModel(), newEvent.getProtocol()); Device device = getSensor(uuid); logger.debug("Sensor Event for {} event {}", device, newEvent); @@ -248,7 +258,7 @@ public void onRequest(TellstickSensorEvent newEvent) { } @Override - public void onRequest(TellstickDeviceEvent newEvent) { + public void onRequest(@NonNullByDefault({}) TellstickDeviceEvent newEvent) { if (newEvent.getChangeType() == ChangeType.ADDED) { for (DeviceStatusListener listener : deviceStatusListeners) { listener.onDeviceAdded(getThing(), newEvent.getDevice()); @@ -265,7 +275,7 @@ public void onRequest(TellstickDeviceEvent newEvent) { } @Override - public Device getSensor(String deviceUUId) { + public @Nullable Device getSensor(String deviceUUId) { for (Device device : sensorList) { if (device.getUUId().equals(deviceUUId)) { return device; @@ -275,7 +285,7 @@ public Device getSensor(String deviceUUId) { } @Override - public TelldusDeviceController getController() { + public @Nullable TelldusDeviceController getController() { return this.deviceController; } } diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreDeviceController.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreDeviceController.java index a37e21352a248..51c677060798a 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreDeviceController.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreDeviceController.java @@ -18,6 +18,8 @@ import java.util.SortedMap; import java.util.TreeMap; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.tellstick.internal.TelldusBindingException; import org.openhab.binding.tellstick.internal.handler.TelldusDeviceController; import org.openhab.core.library.types.IncreaseDecreaseType; @@ -45,6 +47,7 @@ * * @author Jarle Hjortland, Elias Gabrielsson - Initial contribution */ +@NonNullByDefault public class TelldusCoreDeviceController implements DeviceChangeListener, SensorListener, TelldusDeviceController { private final Logger logger = LoggerFactory.getLogger(TelldusCoreDeviceController.class); private long lastSend = 0; @@ -82,7 +85,7 @@ public void handleSendEvent(Device device, int resendCount, boolean isDimmer, Co } @Override - public State calcState(Device dev) { + public @Nullable State calcState(Device dev) { TellstickDevice device = (TellstickDevice) dev; State st = null; switch (device.getStatus()) { @@ -137,12 +140,12 @@ public void setLastSend(long currentTimeMillis) { } @Override - public void onRequest(TellstickSensorEvent newDevices) { + public void onRequest(@NonNullByDefault({}) TellstickSensorEvent newDevices) { setLastSend(newDevices.getTimestamp()); } @Override - public void onRequest(TellstickDeviceEvent newDevices) { + public void onRequest(@NonNullByDefault({}) TellstickDeviceEvent newDevices) { setLastSend(newDevices.getTimestamp()); } @@ -179,10 +182,12 @@ private void sendEvent(Device device, int resendCount, boolean isdimmer, Command } private void increaseDecrease(Device dev, IncreaseDecreaseType increaseDecreaseType) throws TellstickException { - String strValue = ((TellstickDevice) dev).getData(); double value = 0; - if (strValue != null) { - value = Double.valueOf(strValue); + if (dev instanceof TellstickDevice device) { + String strValue = null; + if ((strValue = device.getData()) != null) { + value = Double.valueOf(strValue); + } } int percent = (int) Math.round((value / 255) * 100); if (IncreaseDecreaseType.INCREASE == increaseDecreaseType) { diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/discovery/TellstickBridgeDiscovery.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/discovery/TellstickBridgeDiscovery.java index 66a193784454d..d9aaa7b857773 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/discovery/TellstickBridgeDiscovery.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/discovery/TellstickBridgeDiscovery.java @@ -17,6 +17,7 @@ import java.util.Map; import java.util.Set; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.binding.tellstick.internal.TellstickBindingConstants; import org.openhab.core.config.discovery.AbstractDiscoveryService; import org.openhab.core.config.discovery.DiscoveryResultBuilder; @@ -34,6 +35,7 @@ * @author Jarle Hjortland - Initial contribution * */ +@NonNullByDefault @Component(service = DiscoveryService.class, configurationPid = "discovery.tellstick") public class TellstickBridgeDiscovery extends AbstractDiscoveryService { diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/discovery/TellstickDiscoveryService.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/discovery/TellstickDiscoveryService.java index 4e6ebdaa89b35..ac3720e88ef99 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/discovery/TellstickDiscoveryService.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/discovery/TellstickDiscoveryService.java @@ -16,12 +16,14 @@ import java.util.Set; import java.util.Vector; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.tellstick.internal.TellstickBindingConstants; import org.openhab.binding.tellstick.internal.handler.DeviceStatusListener; import org.openhab.binding.tellstick.internal.handler.TelldusBridgeHandler; -import org.openhab.binding.tellstick.internal.live.xml.LiveDataType; -import org.openhab.binding.tellstick.internal.live.xml.TellstickNetDevice; -import org.openhab.binding.tellstick.internal.live.xml.TellstickNetSensor; +import org.openhab.binding.tellstick.internal.live.dto.LiveDataType; +import org.openhab.binding.tellstick.internal.live.dto.TellstickNetDevice; +import org.openhab.binding.tellstick.internal.live.dto.TellstickNetSensor; import org.openhab.binding.tellstick.internal.local.dto.TellstickLocalDeviceDTO; import org.openhab.binding.tellstick.internal.local.dto.TellstickLocalSensorDTO; import org.openhab.core.config.discovery.AbstractDiscoveryService; @@ -46,6 +48,7 @@ * * @author Jarle Hjortland - Initial contribution */ +@NonNullByDefault public class TellstickDiscoveryService extends AbstractDiscoveryService implements DeviceStatusListener { private static final long DEFAULT_TTL = 60 * 60; // 1 Hour @@ -121,7 +124,7 @@ public void onDeviceRemoved(Bridge bridge, Device device) { } } - private ThingUID getThingUID(Bridge bridge, Device device) { + private @Nullable ThingUID getThingUID(Bridge bridge, Device device) { ThingUID thingUID = null; switch (device.getDeviceType()) { case SENSOR: diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/DeviceStatusListener.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/DeviceStatusListener.java index 81cefb89ee7c2..3c666aed7d55f 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/DeviceStatusListener.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/DeviceStatusListener.java @@ -12,6 +12,7 @@ */ package org.openhab.binding.tellstick.internal.handler; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.thing.Bridge; import org.tellstick.device.iface.Device; import org.tellstick.device.iface.TellstickEvent; @@ -22,12 +23,13 @@ * * @author Jarle Hjortland - Initial contribution */ +@NonNullByDefault public interface DeviceStatusListener { /** * This method is called whenever the state of the given device has changed. * The new state can be obtained by - * {@link org.openhab.binding.tellstick.internal.live.xml.TellstickNetDevice#getState()} / + * {@link org.openhab.binding.tellstick.internal.live.dto.TellstickNetDevice#getState()} / * {@link org.openhab.binding.tellstick.internal.local.dto.TellstickLocalDeviceDTO#getState()}. * * @param bridge diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/TelldusBridgeHandler.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/TelldusBridgeHandler.java index c6aa4d979fc93..62590f0da9464 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/TelldusBridgeHandler.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/TelldusBridgeHandler.java @@ -12,6 +12,8 @@ */ package org.openhab.binding.tellstick.internal.handler; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.thing.ChannelUID; import org.openhab.core.types.Command; import org.tellstick.device.iface.Device; @@ -21,6 +23,7 @@ * * @author Jarle Hjortland - Initial contribution */ +@NonNullByDefault public interface TelldusBridgeHandler { /** @@ -46,6 +49,7 @@ public interface TelldusBridgeHandler { * @param serialNumber * @return */ + @Nullable Device getDevice(String serialNumber); /** @@ -54,6 +58,7 @@ public interface TelldusBridgeHandler { * @param deviceUUId * @return */ + @Nullable Device getSensor(String deviceUUId); /** @@ -67,6 +72,7 @@ public interface TelldusBridgeHandler { * * @return */ + @Nullable TelldusDeviceController getController(); /** diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/TelldusDeviceController.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/TelldusDeviceController.java index fc292b3f9beb6..8429d8a0e93c9 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/TelldusDeviceController.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/TelldusDeviceController.java @@ -14,6 +14,8 @@ import java.math.BigDecimal; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.types.Command; import org.openhab.core.types.State; import org.tellstick.device.TellstickException; @@ -24,6 +26,7 @@ * * @author Jarle Hjortland - Initial contribution */ +@NonNullByDefault public interface TelldusDeviceController { /** @@ -43,6 +46,7 @@ public interface TelldusDeviceController { * @param dev * @return */ + @Nullable State calcState(Device dev); /** diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/TelldusDevicesHandler.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/TelldusDevicesHandler.java index 165cec6482966..35ba52ce2ce1e 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/TelldusDevicesHandler.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/TelldusDevicesHandler.java @@ -17,10 +17,12 @@ import java.math.BigDecimal; import java.time.Instant; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.tellstick.internal.TellstickBindingConstants; -import org.openhab.binding.tellstick.internal.live.xml.DataTypeValue; -import org.openhab.binding.tellstick.internal.live.xml.TellstickNetSensor; -import org.openhab.binding.tellstick.internal.live.xml.TellstickNetSensorEvent; +import org.openhab.binding.tellstick.internal.live.dto.DataTypeValue; +import org.openhab.binding.tellstick.internal.live.dto.TellstickNetSensor; +import org.openhab.binding.tellstick.internal.live.dto.TellstickNetSensorEvent; import org.openhab.binding.tellstick.internal.local.dto.LocalDataTypeValueDTO; import org.openhab.binding.tellstick.internal.local.dto.TellstickLocalSensorDTO; import org.openhab.binding.tellstick.internal.local.dto.TellstickLocalSensorEventDTO; @@ -58,13 +60,14 @@ * * @author Jarle Hjortland - Initial contribution */ +@NonNullByDefault public class TelldusDevicesHandler extends BaseThingHandler implements DeviceStatusListener { private Logger logger = LoggerFactory.getLogger(TelldusDevicesHandler.class); - private String deviceId; + private @Nullable String deviceId; private Boolean isDimmer = Boolean.FALSE; private int resend = 1; - private TelldusBridgeHandler bridgeHandler = null; + private @Nullable TelldusBridgeHandler bridgeHandler; private final ChannelUID stateChannel; private final ChannelUID dimChannel; private final ChannelUID humidityChannel; @@ -225,7 +228,7 @@ public void dispose() { super.dispose(); } - private Device getDevice(TelldusBridgeHandler tellHandler, String deviceId) { + private @Nullable Device getDevice(TelldusBridgeHandler tellHandler, @Nullable String deviceId) { Device dev = null; if (deviceId != null) { if (isSensor()) { @@ -267,7 +270,7 @@ private void updateSensorStates(Device dev) { } } - private synchronized TelldusBridgeHandler getTellstickBridgeHandler() { + private @Nullable synchronized TelldusBridgeHandler getTellstickBridgeHandler() { if (this.bridgeHandler == null) { logger.debug("No available bridge handler found for {} bridge {} .", deviceId, getBridge()); } @@ -401,17 +404,18 @@ private void updateSensorDataState(LocalDataTypeValueDTO dataType) { } } - private void updateDeviceState(Device device) { + private void updateDeviceState(@Nullable Device device) { if (device != null) { logger.debug("Updating state of {} {} ({}) id: {}", device.getDeviceType(), device.getName(), device.getUUId(), getThing().getUID()); TelldusBridgeHandler bridgeHandler = getTellstickBridgeHandler(); State st = null; - if (bridgeHandler != null && bridgeHandler.getController() != null) { - st = bridgeHandler.getController().calcState(device); + TelldusDeviceController controller = null; + if (bridgeHandler != null && (controller = bridgeHandler.getController()) != null) { + st = controller.calcState(device); } - if (st != null && bridgeHandler != null) { - BigDecimal dimValue = bridgeHandler.getController().calcDimValue(device); + if (st != null && controller != null) { + BigDecimal dimValue = controller.calcDimValue(device); updateState(stateChannel, st); if (device instanceof DimmableDevice) { updateState(dimChannel, new PercentType(dimValue)); diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveBridgeHandler.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveBridgeHandler.java index 54ef9cdf03410..ae1f3e4b0dadb 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveBridgeHandler.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveBridgeHandler.java @@ -20,17 +20,19 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.tellstick.internal.conf.TelldusLiveConfiguration; import org.openhab.binding.tellstick.internal.handler.DeviceStatusListener; import org.openhab.binding.tellstick.internal.handler.TelldusBridgeHandler; import org.openhab.binding.tellstick.internal.handler.TelldusDeviceController; import org.openhab.binding.tellstick.internal.handler.TelldusDevicesHandler; -import org.openhab.binding.tellstick.internal.live.xml.DataTypeValue; -import org.openhab.binding.tellstick.internal.live.xml.TellstickNetDevice; -import org.openhab.binding.tellstick.internal.live.xml.TellstickNetDevices; -import org.openhab.binding.tellstick.internal.live.xml.TellstickNetSensor; -import org.openhab.binding.tellstick.internal.live.xml.TellstickNetSensorEvent; -import org.openhab.binding.tellstick.internal.live.xml.TellstickNetSensors; +import org.openhab.binding.tellstick.internal.live.dto.DataTypeValue; +import org.openhab.binding.tellstick.internal.live.dto.TellstickNetDevice; +import org.openhab.binding.tellstick.internal.live.dto.TellstickNetDevices; +import org.openhab.binding.tellstick.internal.live.dto.TellstickNetSensor; +import org.openhab.binding.tellstick.internal.live.dto.TellstickNetSensorEvent; +import org.openhab.binding.tellstick.internal.live.dto.TellstickNetSensors; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.Thing; @@ -52,14 +54,15 @@ * * @author Jarle Hjortland - Initial contribution */ +@NonNullByDefault public class TelldusLiveBridgeHandler extends BaseBridgeHandler implements TelldusBridgeHandler { private static final int REFRESH_DELAY = 10; private final Logger logger = LoggerFactory.getLogger(TelldusLiveBridgeHandler.class); - private TellstickNetDevices deviceList = null; - private TellstickNetSensors sensorList = null; + private @Nullable TellstickNetDevices deviceList; + private @Nullable TellstickNetSensors sensorList; private TelldusLiveDeviceController controller = new TelldusLiveDeviceController(); private Set deviceStatusListeners = ConcurrentHashMap.newKeySet(); @@ -72,17 +75,19 @@ public TelldusLiveBridgeHandler(Bridge bridge) { super(bridge); } - private ScheduledFuture pollingJob; - private ScheduledFuture immediateRefreshJob; + private @Nullable ScheduledFuture pollingJob; + private @Nullable ScheduledFuture immediateRefreshJob; @Override public void dispose() { logger.debug("Live Handler disposed."); + ScheduledFuture pollingJob = this.pollingJob; if (pollingJob != null) { pollingJob.cancel(true); } - if (this.controller != null) { - this.controller.dispose(); + TelldusDeviceController controller = this.controller; + if (controller != null) { + controller.dispose(); } deviceList = null; sensorList = null; @@ -101,6 +106,7 @@ public void initialize() { } private synchronized void startAutomaticRefresh(long refreshInterval) { + ScheduledFuture pollingJob = this.pollingJob; if (pollingJob != null && !pollingJob.isCancelled()) { pollingJob.cancel(true); } @@ -110,8 +116,13 @@ private synchronized void startAutomaticRefresh(long refreshInterval) { private void scheduleImmediateRefresh() { // We schedule in 10 sec, to avoid multiple updates + ScheduledFuture pollingJob = this.pollingJob; + if (pollingJob == null) { + return; + } logger.debug("Current remaining delay {}", pollingJob.getDelay(TimeUnit.SECONDS)); if (pollingJob.getDelay(TimeUnit.SECONDS) > REFRESH_DELAY) { + ScheduledFuture immediateRefreshJob = this.immediateRefreshJob; if (immediateRefreshJob == null || immediateRefreshJob.isDone()) { immediateRefreshJob = scheduler.schedule(this::refreshDeviceList, REFRESH_DELAY, TimeUnit.SECONDS); } @@ -151,7 +162,7 @@ private void monitorAdditionalRefresh(Instant start, Instant end) { controller.getMaxRequestDuration(), controller.getNbTimeouts(), controller.getNbErrors()); } - private synchronized void updateDevices(TellstickNetDevices previouslist) throws TellstickException { + private synchronized void updateDevices(@Nullable TellstickNetDevices previouslist) throws TellstickException { TellstickNetDevices newList = controller.callRestMethod(TelldusLiveDeviceController.HTTP_TELLDUS_DEVICES, TellstickNetDevices.class); if (newList.getDevices() != null) { @@ -203,7 +214,7 @@ private synchronized void updateDevices(TellstickNetDevices previouslist) throws } } - private synchronized void updateSensors(TellstickNetSensors previouslist) throws TellstickException { + private synchronized void updateSensors(@Nullable TellstickNetSensors previouslist) throws TellstickException { TellstickNetSensors newList = controller.callRestMethod(TelldusLiveDeviceController.HTTP_TELLDUS_SENSORS, TellstickNetSensors.class); logger.debug("Updated sensors:{}", newList.getSensors()); @@ -280,7 +291,7 @@ public void thingUpdated(Thing thing) { } @Override - public boolean registerDeviceStatusListener(DeviceStatusListener deviceStatusListener) { + public boolean registerDeviceStatusListener(@Nullable DeviceStatusListener deviceStatusListener) { if (deviceStatusListener == null) { throw new IllegalArgumentException("It's not allowed to pass a null deviceStatusListener."); } @@ -292,7 +303,7 @@ public boolean unregisterDeviceStatusListener(DeviceStatusListener deviceStatusL return deviceStatusListeners.remove(deviceStatusListener); } - private Device getDevice(String id, List devices) { + private @Nullable Device getDevice(String id, List devices) { for (Device device : devices) { if (device.getId() == Integer.valueOf(id)) { return device; @@ -301,7 +312,7 @@ private Device getDevice(String id, List devices) { return null; } - private Device getSensor(String id, List sensors) { + private @Nullable Device getSensor(String id, List sensors) { for (Device sensor : sensors) { if (sensor.getId() == Integer.valueOf(id)) { return sensor; @@ -311,7 +322,7 @@ private Device getSensor(String id, List sensors) { } @Override - public Device getDevice(String serialNumber) { + public @Nullable Device getDevice(String serialNumber) { return getDevice(serialNumber, getDevices()); } @@ -323,7 +334,7 @@ private List getDevices() { } @Override - public Device getSensor(String deviceUUId) { + public @Nullable Device getSensor(String deviceUUId) { Device result = null; if (sensorList != null) { result = getSensor(deviceUUId, sensorList.getSensors()); @@ -339,7 +350,7 @@ public void rescanTelldusDevices() { } @Override - public TelldusDeviceController getController() { + public @Nullable TelldusDeviceController getController() { return controller; } } diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveDeviceController.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveDeviceController.java index 44a16abb65fd2..ace5e9f695bdd 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveDeviceController.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveDeviceController.java @@ -37,11 +37,12 @@ import org.asynchttpclient.oauth.ConsumerKey; import org.asynchttpclient.oauth.OAuthSignatureCalculator; import org.asynchttpclient.oauth.RequestToken; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.tellstick.internal.TelldusBindingException; import org.openhab.binding.tellstick.internal.handler.TelldusDeviceController; -import org.openhab.binding.tellstick.internal.live.xml.TelldusLiveResponse; -import org.openhab.binding.tellstick.internal.live.xml.TellstickNetDevice; +import org.openhab.binding.tellstick.internal.live.dto.TelldusLiveResponse; +import org.openhab.binding.tellstick.internal.live.dto.TellstickNetDevice; import org.openhab.core.library.types.IncreaseDecreaseType; import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.PercentType; @@ -65,12 +66,13 @@ * * @author Jarle Hjortland - Initial contribution */ +@NonNullByDefault public class TelldusLiveDeviceController implements DeviceChangeListener, SensorListener, TelldusDeviceController { private final Logger logger = LoggerFactory.getLogger(TelldusLiveDeviceController.class); private long lastSend = 0; public static final long DEFAULT_INTERVAL_BETWEEN_SEND = 250; private static final int REQUEST_TIMEOUT_MS = 15000; - private AsyncHttpClient client; + private @Nullable AsyncHttpClient client; static final String HTTP_API_TELLDUS_COM_XML = "http://pa-api.telldus.com/xml/"; static final String HTTP_TELLDUS_CLIENTS = HTTP_API_TELLDUS_COM_XML + "clients/list"; static final String HTTP_TELLDUS_DEVICES = HTTP_API_TELLDUS_COM_XML + "devices/list?supportedMethods=19"; @@ -93,10 +95,13 @@ public TelldusLiveDeviceController() { @Override public void dispose() { - try { - client.close(); - } catch (Exception e) { - logger.debug("Failed to close client", e); + AsyncHttpClient client = this.client; + if (client != null) { + try { + client.close(); + } catch (Exception e) { + logger.debug("Failed to close client", e); + } } } @@ -104,10 +109,12 @@ void connectHttpClient(String publicKey, String privateKey, String token, String ConsumerKey consumer = new ConsumerKey(publicKey, privateKey); RequestToken user = new RequestToken(token, tokenSecret); OAuthSignatureCalculator calc = new OAuthSignatureCalculator(consumer, user); - this.client = new DefaultAsyncHttpClient(createAsyncHttpClientConfig()); + AsyncHttpClient client = new DefaultAsyncHttpClient(createAsyncHttpClientConfig()); + client.setSignatureCalculator(calc); + this.client = client; try { - this.client.setSignatureCalculator(calc); Response response = client.prepareGet(HTTP_TELLDUS_CLIENTS).execute().get(); + this.client = client; logger.debug("Response {} statusText {}", response.getResponseBody(), response.getStatusText()); } catch (InterruptedException | ExecutionException e) { logger.warn("Failed to connect", e); @@ -217,7 +224,7 @@ private void turnOn(Device dev) throws TellstickException { } @Override - public State calcState(Device dev) { + public @Nullable State calcState(Device dev) { TellstickNetDevice device = (TellstickNetDevice) dev; State st = null; if (device.getOnline()) { @@ -274,12 +281,12 @@ public void setLastSend(long currentTimeMillis) { } @Override - public void onRequest(TellstickSensorEvent newDevices) { + public void onRequest(@NonNullByDefault({}) TellstickSensorEvent newDevices) { setLastSend(newDevices.getTimestamp()); } @Override - public void onRequest(TellstickDeviceEvent newDevices) { + public void onRequest(@NonNullByDefault({}) TellstickDeviceEvent newDevices) { setLastSend(newDevices.getTimestamp()); } diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveException.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveException.java index a7b016f679945..0cb916b3d77f7 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveException.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveException.java @@ -12,6 +12,8 @@ */ package org.openhab.binding.tellstick.internal.live; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.tellstick.device.TellstickException; /** @@ -20,6 +22,7 @@ * * @author Jarle Hjortland - Initial contribution */ +@NonNullByDefault public class TelldusLiveException extends TellstickException { public TelldusLiveException(Exception source) { @@ -30,7 +33,7 @@ public TelldusLiveException(Exception source) { private static final long serialVersionUID = 3067179547449451158L; @Override - public String getMessage() { + public @Nullable String getMessage() { return getCause().getMessage(); } } diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/DataTypeValue.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/DataTypeValue.java similarity index 96% rename from bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/DataTypeValue.java rename to bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/DataTypeValue.java index f851568290dd2..c9c259175c5c7 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/DataTypeValue.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/DataTypeValue.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.tellstick.internal.live.xml; +package org.openhab.binding.tellstick.internal.live.dto; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/LiveDataType.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/LiveDataType.java similarity index 95% rename from bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/LiveDataType.java rename to bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/LiveDataType.java index a1801cb3169ce..af8f8310f4343 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/LiveDataType.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/LiveDataType.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.tellstick.internal.live.xml; +package org.openhab.binding.tellstick.internal.live.dto; /** * This enum is used to describe the value types in the Live API from telldus. diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/NameToDataType.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/NameToDataType.java similarity index 93% rename from bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/NameToDataType.java rename to bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/NameToDataType.java index 5c0e0fede57a6..c85055e2b05ac 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/NameToDataType.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/NameToDataType.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.tellstick.internal.live.xml; +package org.openhab.binding.tellstick.internal.live.dto; import javax.xml.bind.annotation.adapters.XmlAdapter; diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/NumberToBooleanMapper.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/NumberToBooleanMapper.java similarity index 93% rename from bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/NumberToBooleanMapper.java rename to bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/NumberToBooleanMapper.java index d4992c3f679d9..8de8b8bbffa24 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/NumberToBooleanMapper.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/NumberToBooleanMapper.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.tellstick.internal.live.xml; +package org.openhab.binding.tellstick.internal.live.dto; import javax.xml.bind.annotation.adapters.XmlAdapter; diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TelldusLiveResponse.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TelldusLiveResponse.java similarity index 93% rename from bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TelldusLiveResponse.java rename to bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TelldusLiveResponse.java index 627306ecd2571..9160f56376c22 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TelldusLiveResponse.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TelldusLiveResponse.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.tellstick.internal.live.xml; +package org.openhab.binding.tellstick.internal.live.dto; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TellstickNetDevice.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TellstickNetDevice.java similarity index 98% rename from bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TellstickNetDevice.java rename to bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TellstickNetDevice.java index 1b6895ef25e22..81a51477209ce 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TellstickNetDevice.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TellstickNetDevice.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.tellstick.internal.live.xml; +package org.openhab.binding.tellstick.internal.live.dto; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TellstickNetDevices.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TellstickNetDevices.java similarity index 94% rename from bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TellstickNetDevices.java rename to bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TellstickNetDevices.java index 938f7a4e419b6..0ec5714e03eab 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TellstickNetDevices.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TellstickNetDevices.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.tellstick.internal.live.xml; +package org.openhab.binding.tellstick.internal.live.dto; import java.util.List; diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TellstickNetSensor.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TellstickNetSensor.java similarity index 98% rename from bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TellstickNetSensor.java rename to bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TellstickNetSensor.java index 6811cca040b12..0bca6293b09fe 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TellstickNetSensor.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TellstickNetSensor.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.tellstick.internal.live.xml; +package org.openhab.binding.tellstick.internal.live.dto; import java.util.List; diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TellstickNetSensorEvent.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TellstickNetSensorEvent.java similarity index 95% rename from bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TellstickNetSensorEvent.java rename to bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TellstickNetSensorEvent.java index aeb7565e2cb1a..52ef374298d95 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TellstickNetSensorEvent.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TellstickNetSensorEvent.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.tellstick.internal.live.xml; +package org.openhab.binding.tellstick.internal.live.dto; import org.openhab.binding.tellstick.internal.TellstickRuntimeException; import org.tellstick.device.TellstickSensorEvent; diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TellstickNetSensors.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TellstickNetSensors.java similarity index 94% rename from bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TellstickNetSensors.java rename to bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TellstickNetSensors.java index 52f6ea23f405c..a651f85a22da1 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/xml/TellstickNetSensors.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/dto/TellstickNetSensors.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.tellstick.internal.live.xml; +package org.openhab.binding.tellstick.internal.live.dto; import java.util.List; diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalBridgeHandler.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalBridgeHandler.java index 8cf7f35f40ad7..a2e521fbc9ce6 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalBridgeHandler.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalBridgeHandler.java @@ -19,6 +19,8 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jetty.client.HttpClient; import org.openhab.binding.tellstick.internal.conf.TelldusLocalConfiguration; import org.openhab.binding.tellstick.internal.handler.DeviceStatusListener; @@ -52,16 +54,17 @@ * * @author Jan Gustafsson - Initial contribution */ +@NonNullByDefault public class TelldusLocalBridgeHandler extends BaseBridgeHandler implements TelldusBridgeHandler { private final Logger logger = LoggerFactory.getLogger(TelldusLocalBridgeHandler.class); - private TellstickLocalDevicesDTO deviceList = null; - private TellstickLocalSensorsDTO sensorList = null; - private TelldusLocalDeviceController controller = null; + private @Nullable TellstickLocalDevicesDTO deviceList; + private @Nullable TellstickLocalSensorsDTO sensorList; + private @Nullable TelldusLocalDeviceController controller; private Set deviceStatusListeners = ConcurrentHashMap.newKeySet(); private final HttpClient httpClient; - private ScheduledFuture pollingJob; + private @Nullable ScheduledFuture pollingJob; /** * Use cache for refresh command to not update again when call is made within 10 seconds of previous call. */ @@ -84,11 +87,13 @@ public void initialize() { @Override public void dispose() { + ScheduledFuture pollingJob = this.pollingJob; if (pollingJob != null) { pollingJob.cancel(true); } - if (this.controller != null) { - this.controller.dispose(); + TelldusDeviceController controller = this.controller; + if (controller != null) { + controller.dispose(); } deviceList = null; sensorList = null; @@ -107,7 +112,7 @@ private boolean refreshDeviceList() { return false; } - private synchronized void updateDevices(TellstickLocalDevicesDTO previouslist) + private synchronized void updateDevices(@Nullable TellstickLocalDevicesDTO previouslist) throws TellstickException, InterruptedException { TellstickLocalDevicesDTO newList = controller .callRestMethod(TelldusLocalDeviceController.HTTP_LOCAL_API_DEVICES, TellstickLocalDevicesDTO.class); @@ -163,7 +168,7 @@ private synchronized void updateDevices(TellstickLocalDevicesDTO previouslist) } } - private synchronized void updateSensors(TellstickLocalSensorsDTO previouslist) + private synchronized void updateSensors(@Nullable TellstickLocalSensorsDTO previouslist) throws TellstickException, InterruptedException { TellstickLocalSensorsDTO newList = controller .callRestMethod(TelldusLocalDeviceController.HTTP_LOCAL_API_SENSORS, TellstickLocalSensorsDTO.class); @@ -227,7 +232,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { } @Override - public boolean registerDeviceStatusListener(DeviceStatusListener deviceStatusListener) { + public boolean registerDeviceStatusListener(@Nullable DeviceStatusListener deviceStatusListener) { if (deviceStatusListener == null) { throw new IllegalArgumentException("It's not allowed to pass a null deviceStatusListener."); } @@ -239,7 +244,7 @@ public boolean unregisterDeviceStatusListener(DeviceStatusListener deviceStatusL return deviceStatusListeners.remove(deviceStatusListener); } - private Device getDevice(String id, List devices) { + private @Nullable Device getDevice(String id, List devices) { for (Device device : devices) { if (device.getId() == Integer.valueOf(id)) { return device; @@ -248,7 +253,7 @@ private Device getDevice(String id, List devices) { return null; } - private Device getSensor(String id, List sensors) { + private @Nullable Device getSensor(String id, List sensors) { for (Device sensor : sensors) { if (sensor.getId() == Integer.valueOf(id)) { return sensor; @@ -258,7 +263,7 @@ private Device getSensor(String id, List sensors) { } @Override - public Device getDevice(String serialNumber) { + public @Nullable Device getDevice(String serialNumber) { return getDevice(serialNumber, getDevices()); } @@ -270,7 +275,7 @@ private List getDevices() { } @Override - public Device getSensor(String deviceUUId) { + public @Nullable Device getSensor(String deviceUUId) { Device result = null; if (sensorList != null) { result = getSensor(deviceUUId, sensorList.getSensors()); @@ -286,7 +291,7 @@ public void rescanTelldusDevices() { } @Override - public TelldusDeviceController getController() { + public @Nullable TelldusDeviceController getController() { return controller; } } diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalDeviceController.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalDeviceController.java index 307d20c208de3..8a1fc2ef1014e 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalDeviceController.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalDeviceController.java @@ -18,6 +18,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; @@ -54,6 +55,7 @@ * * @author Jan Gustafsson - Initial contribution */ +@NonNullByDefault public class TelldusLocalDeviceController implements DeviceChangeListener, SensorListener, TelldusDeviceController { private final Logger logger = LoggerFactory.getLogger(TelldusLocalDeviceController.class); private long lastSend = 0; @@ -161,7 +163,7 @@ private void turnOff(Device dev) throws TellstickException, InterruptedException } } - private void handleResponse(TellstickLocalDeviceDTO device, TelldusLocalResponseDTO response) + private void handleResponse(TellstickLocalDeviceDTO device, @Nullable TelldusLocalResponseDTO response) throws TellstickException { if (response == null || (response.getStatus() == null && response.getError() == null)) { throw new TelldusBindingException("No response " + response); @@ -184,7 +186,7 @@ private void turnOn(Device dev) throws TellstickException, InterruptedException } @Override - public State calcState(Device dev) { + public @Nullable State calcState(Device dev) { TellstickLocalDeviceDTO device = (TellstickLocalDeviceDTO) dev; State st = null; @@ -241,12 +243,12 @@ public void setLastSend(long currentTimeMillis) { } @Override - public void onRequest(TellstickSensorEvent newDevices) { + public void onRequest(@NonNullByDefault({}) TellstickSensorEvent newDevices) { setLastSend(newDevices.getTimestamp()); } @Override - public void onRequest(TellstickDeviceEvent newDevices) { + public void onRequest(@NonNullByDefault({}) TellstickDeviceEvent newDevices) { setLastSend(newDevices.getTimestamp()); } diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalException.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalException.java index 0a5d773f5b236..a05d04b0a01dc 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalException.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalException.java @@ -12,8 +12,8 @@ */ package org.openhab.binding.tellstick.internal.local; -import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.tellstick.device.TellstickException; /** @@ -33,7 +33,7 @@ public TelldusLocalException(Exception source) { private static final long serialVersionUID = 3067179547449454711L; @Override - public @NonNull String getMessage() { + public @Nullable String getMessage() { Throwable throwable = getCause(); if (throwable != null) { String localMessage = throwable.getMessage(); diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/dto/LocalDataTypeValueDTO.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/dto/LocalDataTypeValueDTO.java index acfc5ea1bfb91..4554fa90b7631 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/dto/LocalDataTypeValueDTO.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/dto/LocalDataTypeValueDTO.java @@ -12,7 +12,7 @@ */ package org.openhab.binding.tellstick.internal.local.dto; -import org.openhab.binding.tellstick.internal.live.xml.LiveDataType; +import org.openhab.binding.tellstick.internal.live.dto.LiveDataType; /** * Class used to deserialize JSON from Telldus local API. diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/dto/TellstickLocalSensorDTO.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/dto/TellstickLocalSensorDTO.java index 9fd9b33575640..982670bc9b3b5 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/dto/TellstickLocalSensorDTO.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/dto/TellstickLocalSensorDTO.java @@ -14,7 +14,7 @@ import java.util.List; -import org.openhab.binding.tellstick.internal.live.xml.LiveDataType; +import org.openhab.binding.tellstick.internal.live.dto.LiveDataType; import org.tellstick.device.iface.Device; import org.tellstick.enums.DeviceType; From f62861b99033f445cfd321ddb983504fdf912710 Mon Sep 17 00:00:00 2001 From: lsiepel Date: Sat, 28 Dec 2024 14:57:46 +0100 Subject: [PATCH 3/6] Update bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreBridgeHandler.java Co-authored-by: Jacob Laursen Signed-off-by: lsiepel --- .../tellstick/internal/core/TelldusCoreBridgeHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreBridgeHandler.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreBridgeHandler.java index 418a68210383d..7ab0afba5bc2c 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreBridgeHandler.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreBridgeHandler.java @@ -88,7 +88,7 @@ public void dispose() { TelldusDeviceController deviceController = this.deviceController; if (deviceController != null) { deviceController.dispose(); - deviceController = null; + this.deviceController = null; } TellstickEventHandler eventHandler = this.eventHandler; From 1329b3e143cd80526305a0e4e3a0f352214a3067 Mon Sep 17 00:00:00 2001 From: lsiepel Date: Sat, 28 Dec 2024 14:57:58 +0100 Subject: [PATCH 4/6] Update bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreBridgeHandler.java Co-authored-by: Jacob Laursen Signed-off-by: lsiepel --- .../tellstick/internal/core/TelldusCoreBridgeHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreBridgeHandler.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreBridgeHandler.java index 7ab0afba5bc2c..e4ead5336a49b 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreBridgeHandler.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreBridgeHandler.java @@ -94,7 +94,7 @@ public void dispose() { TellstickEventHandler eventHandler = this.eventHandler; if (eventHandler != null) { eventHandler.remove(); - eventHandler = null; + this.eventHandler = null; } clearDeviceList(); initialized = false; From e83c1970d2ca3a1732770b3056386eb4afd50610 Mon Sep 17 00:00:00 2001 From: lsiepel Date: Sat, 28 Dec 2024 14:59:28 +0100 Subject: [PATCH 5/6] Update bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveDeviceController.java Co-authored-by: Jacob Laursen Signed-off-by: lsiepel --- .../tellstick/internal/live/TelldusLiveDeviceController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveDeviceController.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveDeviceController.java index ace5e9f695bdd..ec55372eb0c1b 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveDeviceController.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveDeviceController.java @@ -114,7 +114,6 @@ void connectHttpClient(String publicKey, String privateKey, String token, String this.client = client; try { Response response = client.prepareGet(HTTP_TELLDUS_CLIENTS).execute().get(); - this.client = client; logger.debug("Response {} statusText {}", response.getResponseBody(), response.getStatusText()); } catch (InterruptedException | ExecutionException e) { logger.warn("Failed to connect", e); From d718cb64341c97dbbc17f9e3178f84e077364351 Mon Sep 17 00:00:00 2001 From: Leo Siepel Date: Tue, 31 Dec 2024 21:21:36 +0100 Subject: [PATCH 6/6] Fix review comments Signed-off-by: Leo Siepel --- .../tellstick/internal/conf/TelldusLocalConfiguration.java | 2 +- .../tellstick/internal/core/TelldusCoreDeviceController.java | 4 ++-- .../tellstick/internal/live/TelldusLiveBridgeHandler.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TelldusLocalConfiguration.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TelldusLocalConfiguration.java index b320765b7be9c..16fd1f6fea366 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TelldusLocalConfiguration.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/conf/TelldusLocalConfiguration.java @@ -24,5 +24,5 @@ public class TelldusLocalConfiguration { public String ipAddress = ""; public String accessToken = ""; - public long refreshInterval; + public long refreshInterval = 60000; } diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreDeviceController.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreDeviceController.java index 51c677060798a..23e4af3c8e076 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreDeviceController.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreDeviceController.java @@ -184,8 +184,8 @@ private void sendEvent(Device device, int resendCount, boolean isdimmer, Command private void increaseDecrease(Device dev, IncreaseDecreaseType increaseDecreaseType) throws TellstickException { double value = 0; if (dev instanceof TellstickDevice device) { - String strValue = null; - if ((strValue = device.getData()) != null) { + String strValue = device.getData(); + if (strValue != null) { value = Double.valueOf(strValue); } } diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveBridgeHandler.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveBridgeHandler.java index ae1f3e4b0dadb..b727cb92dbac6 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveBridgeHandler.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveBridgeHandler.java @@ -124,7 +124,7 @@ private void scheduleImmediateRefresh() { if (pollingJob.getDelay(TimeUnit.SECONDS) > REFRESH_DELAY) { ScheduledFuture immediateRefreshJob = this.immediateRefreshJob; if (immediateRefreshJob == null || immediateRefreshJob.isDone()) { - immediateRefreshJob = scheduler.schedule(this::refreshDeviceList, REFRESH_DELAY, TimeUnit.SECONDS); + this.immediateRefreshJob = scheduler.schedule(this::refreshDeviceList, REFRESH_DELAY, TimeUnit.SECONDS); } } }