From e9186a9eb341e2a589976fcba8b4ef00ce73d348 Mon Sep 17 00:00:00 2001 From: Christoph Weitkamp Date: Wed, 26 Jul 2017 12:18:01 +0200 Subject: [PATCH] Avoid NPE while handling INCREASE/DECREASE commands Signed-off-by: Christoph Weitkamp --- .../binding/tradfri/handler/TradfriLightHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/binding/org.eclipse.smarthome.binding.tradfri/src/main/java/org/eclipse/smarthome/binding/tradfri/handler/TradfriLightHandler.java b/extensions/binding/org.eclipse.smarthome.binding.tradfri/src/main/java/org/eclipse/smarthome/binding/tradfri/handler/TradfriLightHandler.java index f8633f0348a..61116b10a80 100644 --- a/extensions/binding/org.eclipse.smarthome.binding.tradfri/src/main/java/org/eclipse/smarthome/binding/tradfri/handler/TradfriLightHandler.java +++ b/extensions/binding/org.eclipse.smarthome.binding.tradfri/src/main/java/org/eclipse/smarthome/binding/tradfri/handler/TradfriLightHandler.java @@ -181,7 +181,7 @@ private void handleBrightnessCommand(Command command) { } else if (command instanceof OnOffType) { setState(((OnOffType) command)); } else if (command instanceof IncreaseDecreaseType) { - if (state != null) { + if (state != null && state.getBrightness() != null) { int current = state.getBrightness().intValue(); if (IncreaseDecreaseType.INCREASE.equals(command)) { setBrightness(new PercentType(Math.min(current + STEP, PercentType.HUNDRED.intValue()))); @@ -200,7 +200,7 @@ private void handleColorTemperatureCommand(Command command) { if (command instanceof PercentType) { setColorTemperature((PercentType) command); } else if (command instanceof IncreaseDecreaseType) { - if (state != null) { + if (state != null && state.getColorTemperature() != null) { int current = state.getColorTemperature().intValue(); if (IncreaseDecreaseType.INCREASE.equals(command)) { setColorTemperature(new PercentType(Math.min(current + STEP, PercentType.HUNDRED.intValue())));