diff --git a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/action/DimmerActions.java b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/action/DimmerActions.java index 14310ddeb2a..b7d4f40e3ee 100644 --- a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/action/DimmerActions.java +++ b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/action/DimmerActions.java @@ -15,6 +15,7 @@ package org.openhab.binding.lutron.action; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.math.BigDecimal; +import java.math.RoundingMode; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -90,7 +91,7 @@ public class DimmerActions implements ThingActions, IDimmerActions { lightLevel = 0.0; } try { - dimmerHandler.setLightLevel(new BigDecimal(lightLevel).setScale(2, BigDecimal.ROUND_HALF_UP), + dimmerHandler.setLightLevel(new BigDecimal(lightLevel).setScale(2, RoundingMode.HALF_UP), new LutronDuration(fadeTime), new LutronDuration(delayTime)); } catch (IllegalArgumentException e) { logger.debug("Ignoring setLevel command due to illegal argument exception: {}", e.getMessage()); diff --git a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/config/DimmerConfig.java b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/config/DimmerConfig.java index 8a1d57c571f..0be4cd2823d 100644 --- a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/config/DimmerConfig.java +++ b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/config/DimmerConfig.java @@ -31,5 +31,5 @@ public class DimmerConfig { public BigDecimal fadeInTime = new BigDecimal(DEFAULT_FADE); public BigDecimal fadeOutTime = new BigDecimal(DEFAULT_FADE); public BigDecimal onLevel = new BigDecimal(DEFAULT_ONLEVEL); - public Boolean onToLast = new Boolean(DEFAULT_ONTOLAST); + public Boolean onToLast = DEFAULT_ONTOLAST; } diff --git a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/handler/GreenModeHandler.java b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/handler/GreenModeHandler.java index 55a57129953..62d81ba2a58 100644 --- a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/handler/GreenModeHandler.java +++ b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/handler/GreenModeHandler.java @@ -113,10 +113,11 @@ public class GreenModeHandler extends LutronHandler { } private void stopPolling() { + ScheduledFuture pollJob = this.pollJob; if (pollJob != null) { + this.pollJob = null; logger.debug("Canceling green mode polling job for integration ID {}", integrationId); pollJob.cancel(true); - pollJob = null; } } @@ -140,7 +141,7 @@ public class GreenModeHandler extends LutronHandler { } else if (command == OnOffType.OFF) { greenMode(ACTION_STEP, 1); } else if (command instanceof Number) { - Integer step = new Integer(((Number) command).intValue()); + Integer step = ((Number) command).intValue(); if (step.intValue() >= GREENSTEP_MIN) { greenMode(ACTION_STEP, step); } @@ -159,7 +160,7 @@ public class GreenModeHandler extends LutronHandler { try { if (type == LutronCommandType.MODE && parameters.length > 1 && ACTION_STEP.toString().equals(parameters[0])) { - Long step = new Long(parameters[1]); + Long step = Long.valueOf(parameters[1]); if (getThing().getStatus() == ThingStatus.UNKNOWN) { updateStatus(ThingStatus.ONLINE); startPolling(); diff --git a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/handler/TimeclockHandler.java b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/handler/TimeclockHandler.java index ec6ab63ebb3..6113103a716 100644 --- a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/handler/TimeclockHandler.java +++ b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/handler/TimeclockHandler.java @@ -102,7 +102,7 @@ public class TimeclockHandler extends LutronHandler { if (channelUID.getId().equals(CHANNEL_CLOCKMODE)) { if (command instanceof DecimalType) { - Integer mode = new Integer(((DecimalType) command).intValue()); + Integer mode = ((DecimalType) command).intValue(); timeclock(ACTION_CLOCKMODE, mode); } else if (command instanceof RefreshType) { queryTimeclock(ACTION_CLOCKMODE); @@ -111,7 +111,7 @@ public class TimeclockHandler extends LutronHandler { } } else if (channelUID.getId().equals(CHANNEL_EXECEVENT)) { if (command instanceof DecimalType) { - Integer index = new Integer(((DecimalType) command).intValue()); + Integer index = ((DecimalType) command).intValue(); timeclock(ACTION_EXECEVENT, index); } else { logger.debug("Invalid command type for execevent channnel"); @@ -130,14 +130,14 @@ public class TimeclockHandler extends LutronHandler { } } else if (channelUID.getId().equals(CHANNEL_ENABLEEVENT)) { if (command instanceof DecimalType) { - Integer index = new Integer(((DecimalType) command).intValue()); + Integer index = ((DecimalType) command).intValue(); timeclock(ACTION_SETEVENT, index, EVENT_ENABLE); } else { logger.debug("Invalid command type for enableevent channnel"); } } else if (channelUID.getId().equals(CHANNEL_DISABLEEVENT)) { if (command instanceof DecimalType) { - Integer index = new Integer(((DecimalType) command).intValue()); + Integer index = ((DecimalType) command).intValue(); timeclock(ACTION_SETEVENT, index, EVENT_DISABLE); } else { logger.debug("Invalid command type for disableevent channnel"); @@ -173,7 +173,7 @@ public class TimeclockHandler extends LutronHandler { try { if (parameters.length >= 2 && ACTION_CLOCKMODE.toString().equals(parameters[0])) { - Integer mode = new Integer(parameters[1]); + Integer mode = Integer.valueOf(parameters[1]); if (getThing().getStatus() == ThingStatus.UNKNOWN) { updateStatus(ThingStatus.ONLINE); } @@ -194,12 +194,12 @@ public class TimeclockHandler extends LutronHandler { } } else if (parameters.length >= 2 && ACTION_EXECEVENT.toString().equals(parameters[0])) { - Integer index = new Integer(parameters[1]); + Integer index = Integer.valueOf(parameters[1]); updateState(CHANNEL_EXECEVENT, new DecimalType(index)); } else if (parameters.length >= 3 && ACTION_SETEVENT.toString().equals(parameters[0])) { - Integer index = new Integer(parameters[1]); - Integer state = new Integer(parameters[2]); + Integer index = Integer.valueOf(parameters[1]); + Integer state = Integer.valueOf(parameters[2]); if (state.equals(EVENT_ENABLE)) { updateState(CHANNEL_ENABLEEVENT, new DecimalType(index)); } else if (state.equals(EVENT_DISABLE)) { diff --git a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/protocol/LutronDuration.java b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/protocol/LutronDuration.java index ef1c1aded81..a8b97bc7838 100644 --- a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/protocol/LutronDuration.java +++ b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/protocol/LutronDuration.java @@ -13,6 +13,7 @@ package org.openhab.binding.lutron.internal.protocol; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -75,7 +76,7 @@ public class LutronDuration { * Constructor accepting duration in seconds as a Double */ public LutronDuration(Double seconds) { - this(new BigDecimal(seconds).setScale(2, BigDecimal.ROUND_HALF_UP)); + this(new BigDecimal(seconds).setScale(2, RoundingMode.HALF_UP)); } /**