bugfix, null check before switch
This commit is contained in:
parent
d622648bab
commit
e7655b380e
1 changed files with 9 additions and 4 deletions
|
|
@ -5,6 +5,7 @@ import se.hal.plugin.tellstick.TellstickDevice;
|
||||||
import se.hal.plugin.tellstick.TellstickProtocol;
|
import se.hal.plugin.tellstick.TellstickProtocol;
|
||||||
import se.hal.plugin.tellstick.TellstickSerialComm;
|
import se.hal.plugin.tellstick.TellstickSerialComm;
|
||||||
import se.hal.plugin.tellstick.device.Oregon0x1A2D;
|
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.HumiditySensorData;
|
||||||
import se.hal.struct.devicedata.LightSensorData;
|
import se.hal.struct.devicedata.LightSensorData;
|
||||||
import se.hal.struct.devicedata.PowerConsumptionSensorData;
|
import se.hal.struct.devicedata.PowerConsumptionSensorData;
|
||||||
|
|
@ -66,16 +67,20 @@ public class Oregon0x1A2DProtocol extends TellstickProtocol {
|
||||||
ArrayList<TellstickDecodedEntry> list = new ArrayList<>();
|
ArrayList<TellstickDecodedEntry> list = new ArrayList<>();
|
||||||
for (Oregon0x1A2D device : getSensorByAddress(address)) {
|
for (Oregon0x1A2D device : getSensorByAddress(address)) {
|
||||||
HalSensorData dataObj;
|
HalSensorData dataObj;
|
||||||
switch (device.getSensorType()){
|
OregonSensorType sensorType = device.getSensorType();
|
||||||
|
if (sensorType == null)
|
||||||
|
sensorType = OregonSensorType.POWER;
|
||||||
|
switch (sensorType){
|
||||||
case HUMIDITY:
|
case HUMIDITY:
|
||||||
dataObj = new HumiditySensorData(humidity); break;
|
dataObj = new HumiditySensorData(humidity); break;
|
||||||
case LIGHT:
|
case LIGHT:
|
||||||
dataObj = new LightSensorData(temperature); break;
|
dataObj = new LightSensorData(temperature); break;
|
||||||
|
case TEMPERATURE:
|
||||||
|
dataObj = new TemperatureSensorData(temperature); break;
|
||||||
|
default:
|
||||||
case POWER:
|
case POWER:
|
||||||
dataObj = new PowerConsumptionSensorData(temperature); break;
|
dataObj = new PowerConsumptionSensorData(temperature); break;
|
||||||
case TEMPERATURE:
|
|
||||||
default:
|
|
||||||
dataObj = new TemperatureSensorData(temperature); break;
|
|
||||||
}
|
}
|
||||||
list.add(new TellstickDecodedEntry(device, dataObj));
|
list.add(new TellstickDecodedEntry(device, dataObj));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue