From e7655b380edfe27ff342090c34e34ee4f0530bcf Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Thu, 25 Aug 2016 21:21:18 +0200 Subject: [PATCH] bugfix, null check before switch --- .../tellstick/protocol/Oregon0x1A2DProtocol.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/se/hal/plugin/tellstick/protocol/Oregon0x1A2DProtocol.java b/src/se/hal/plugin/tellstick/protocol/Oregon0x1A2DProtocol.java index 3c89a0f8..39a9d610 100755 --- a/src/se/hal/plugin/tellstick/protocol/Oregon0x1A2DProtocol.java +++ b/src/se/hal/plugin/tellstick/protocol/Oregon0x1A2DProtocol.java @@ -5,6 +5,7 @@ import se.hal.plugin.tellstick.TellstickDevice; import se.hal.plugin.tellstick.TellstickProtocol; import se.hal.plugin.tellstick.TellstickSerialComm; import se.hal.plugin.tellstick.device.Oregon0x1A2D; +import se.hal.plugin.tellstick.device.Oregon0x1A2D.OregonSensorType; import se.hal.struct.devicedata.HumiditySensorData; import se.hal.struct.devicedata.LightSensorData; import se.hal.struct.devicedata.PowerConsumptionSensorData; @@ -66,16 +67,20 @@ public class Oregon0x1A2DProtocol extends TellstickProtocol { ArrayList list = new ArrayList<>(); for (Oregon0x1A2D device : getSensorByAddress(address)) { HalSensorData dataObj; - switch (device.getSensorType()){ + OregonSensorType sensorType = device.getSensorType(); + if (sensorType == null) + sensorType = OregonSensorType.POWER; + switch (sensorType){ case HUMIDITY: dataObj = new HumiditySensorData(humidity); break; case LIGHT: dataObj = new LightSensorData(temperature); break; + case TEMPERATURE: + dataObj = new TemperatureSensorData(temperature); break; + default: case POWER: dataObj = new PowerConsumptionSensorData(temperature); break; - case TEMPERATURE: - default: - dataObj = new TemperatureSensorData(temperature); break; + } list.add(new TellstickDecodedEntry(device, dataObj)); }