diff --git a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyBridgeHandler.java b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyBridgeHandler.java index e1e2cbdf64efb..0a7157eec6dee 100644 --- a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyBridgeHandler.java +++ b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyBridgeHandler.java @@ -651,7 +651,7 @@ public void handleNewMessageReceivedEvent(final MessageEvent event) logger.trace("Message: {}", gson.toJson(message)); logger.trace("Messagetype: {}", message.getType()); } - if (Message.TYPE_DEVICE_LOW_BATTERY.equals(message.getType())) { + if (Message.TYPE_DEVICE_LOW_BATTERY.equals(message.getType()) && message.getDeviceLinkList() != null) { for (final String link : message.getDeviceLinkList()) { deviceStructMan.refreshDevice(Link.getId(link)); final Device device = deviceStructMan.getDeviceById(Link.getId(link)); @@ -688,11 +688,17 @@ public void handleMessageDeletedEvent(final Event event) throws ApiException, IO logger.debug("handleMessageDeletedEvent with messageId '{}'", messageId); Device device = deviceStructMan.getDeviceWithMessageId(messageId); + if (device != null) { - deviceStructMan.refreshDevice(device.getId()); - device = deviceStructMan.getDeviceById(device.getId()); - for (final DeviceStatusListener deviceStatusListener : deviceStatusListeners) { - deviceStatusListener.onDeviceStateChanged(device); + String id = device.getId(); + deviceStructMan.refreshDevice(id); + device = deviceStructMan.getDeviceById(id); + if (device != null) { + for (final DeviceStatusListener deviceStatusListener : deviceStatusListeners) { + deviceStatusListener.onDeviceStateChanged(device); + } + } else { + logger.debug("No device with id {} found after refresh.", id); } } else { logger.debug("No device found with message id {}.", messageId); diff --git a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/manager/DeviceStructureManager.java b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/manager/DeviceStructureManager.java index 8cb1641b2e64a..fd68904a9e0ba 100644 --- a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/manager/DeviceStructureManager.java +++ b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/manager/DeviceStructureManager.java @@ -166,7 +166,7 @@ public void addDeviceToStructure(Device device) { * @param id * @return the {@link Device} or null, if it does not exist */ - public Device getDeviceById(String id) { + public @Nullable Device getDeviceById(String id) { logger.debug("getDeviceById {}:{}", id, getDeviceMap().containsKey(id)); return getDeviceMap().get(id); } @@ -177,7 +177,7 @@ public Device getDeviceById(String id) { * @param capabilityId * @return {@link Device} or null */ - public Device getDeviceByCapabilityId(String capabilityId) { + public @Nullable Device getDeviceByCapabilityId(String capabilityId) { return capabilityIdToDeviceMap.get(capabilityId); }