This commit is contained in:
Ziver Koc 2016-08-19 16:02:50 +02:00
parent d692c30bd9
commit aeef862ab4

View file

@ -174,13 +174,11 @@ public class TellstickSerialComm implements Runnable,
} }
} }
private void reportEvent(TellstickDevice tellstickDevice, HalDeviceData deviceData){ private void reportEvent(TellstickDevice tellstickDevice, HalDeviceData deviceData){
if (sensorListener != null) { if (sensorListener != null && tellstickDevice instanceof HalSensorConfig)
if (tellstickDevice instanceof HalSensorConfig)
sensorListener.reportReceived((HalSensorConfig) tellstickDevice, deviceData); sensorListener.reportReceived((HalSensorConfig) tellstickDevice, deviceData);
else if (tellstickDevice instanceof HalEventConfig) else if (eventListener != null && tellstickDevice instanceof HalEventConfig)
eventListener.reportReceived((HalEventConfig) tellstickDevice, deviceData); eventListener.reportReceived((HalEventConfig) tellstickDevice, deviceData);
} }
}
@Override @Override
public void send(HalEventConfig deviceConfig, HalEventData deviceData) { public void send(HalEventConfig deviceConfig, HalEventData deviceData) {
@ -214,14 +212,14 @@ public class TellstickSerialComm implements Runnable,
if(event instanceof TellstickDevice) if(event instanceof TellstickDevice)
registeredDevices.add((TellstickDevice) event); registeredDevices.add((TellstickDevice) event);
else throw new IllegalArgumentException( else throw new IllegalArgumentException(
"Device configuration is not an instance of "+TellstickDevice.class+": "+event.getClass()); "Device config is not an instance of "+TellstickDevice.class+": "+event.getClass());
} }
@Override @Override
public void register(HalSensorConfig sensor) { public void register(HalSensorConfig sensor) {
if(sensor instanceof TellstickDevice) if(sensor instanceof TellstickDevice)
registeredDevices.add((TellstickDevice) sensor); registeredDevices.add((TellstickDevice) sensor);
else throw new IllegalArgumentException( else throw new IllegalArgumentException(
"Device configuration is not an instance of "+TellstickDevice.class+": "+sensor.getClass()); "Device config is not an instance of "+TellstickDevice.class+": "+sensor.getClass());
} }
@Override @Override