From 65871bda7395864adcb717beb90b4944dc6c66b9 Mon Sep 17 00:00:00 2001 From: mmans Date: Mon, 22 Jun 2020 13:31:32 +0200 Subject: [PATCH] [innogysmarthome] Fix Battery Warnings (Bug (#7956)) * Renamed DeviceLinkList to Devices * Updates Javadocs + Added 2 Annotations Closes #6932 Signed-off-by: Marco Mans Signed-off-by: MPH80 --- .../internal/client/InnogyClient.java | 8 ++++---- .../client/entity/message/Message.java | 20 +++++++++++-------- .../internal/handler/InnogyBridgeHandler.java | 4 ++-- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/InnogyClient.java b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/InnogyClient.java index 5b91c47b8fe03..2707832d8e7e7 100644 --- a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/InnogyClient.java +++ b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/InnogyClient.java @@ -446,8 +446,8 @@ public List getFullDevices() throws IOException, ApiException, Authentic final List messageList = getMessages(); final Map> deviceMessageMap = new HashMap<>(); for (final Message m : messageList) { - if (m.getDeviceLinkList() != null && !m.getDeviceLinkList().isEmpty()) { - final String deviceId = m.getDeviceLinkList().get(0).replace("/device/", ""); + if (m.getDevices() != null && !m.getDevices().isEmpty()) { + final String deviceId = m.getDevices().get(0).replace("/device/", ""); List ml; if (deviceMessageMap.containsKey(deviceId)) { ml = deviceMessageMap.get(deviceId); @@ -544,8 +544,8 @@ public Device getFullDeviceById(final String deviceId) throws IOException, ApiEx for (final Message m : messageList) { logger.trace("Message Type {} with ID {}", m.getType(), m.getId()); - if (m.getDeviceLinkList() != null && !m.getDeviceLinkList().isEmpty()) { - for (final String li : m.getDeviceLinkList()) { + if (m.getDevices() != null && !m.getDevices().isEmpty()) { + for (final String li : m.getDevices()) { if (deviceIdPath.equals(li)) { ml.add(m); } diff --git a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/message/Message.java b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/message/Message.java index 372dd349e64b4..b57dd639b9097 100644 --- a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/message/Message.java +++ b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/message/Message.java @@ -12,6 +12,8 @@ */ package org.openhab.binding.innogysmarthome.internal.client.entity.message; +import com.google.gson.annotations.SerializedName; + import java.util.List; /** @@ -85,11 +87,13 @@ public class Message { /** * Defines whether the message has been viewed by a user. */ + @SerializedName("read") private boolean isRead; /** * Defines whether it is an alert or a message, default is message. */ + @SerializedName("class") private String messageClass; /** * Timestamp when the message was created. @@ -103,7 +107,7 @@ public class Message { * * Optional. */ - private List deviceLinkList; + private List devices; /** * Container for all parameters of the message. The parameters are contained in Property entities. @@ -188,17 +192,17 @@ public void setRead(boolean isRead) { } /** - * @return the deviceLinkList + * @return the devices */ - public List getDeviceLinkList() { - return deviceLinkList; + public List getDevices() { + return devices; } /** - * @param deviceLinkList the deviceLinkList to set + * @param devices the devices to set */ - public void setDeviceLinkList(List deviceLinkList) { - this.deviceLinkList = deviceLinkList; + public void setDevices(List devices) { + this.devices = devices; } /** @@ -209,7 +213,7 @@ public MessageProperties getProperties() { } /** - * @param dataPropertyList the dataPropertyList to set + * @param properties the dataPropertyList to set */ public void setProperties(MessageProperties properties) { this.properties = properties; 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 fd14643445cc8..76b6c498f6f31 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 @@ -650,8 +650,8 @@ 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()) && message.getDeviceLinkList() != null) { - for (final String link : message.getDeviceLinkList()) { + if (Message.TYPE_DEVICE_LOW_BATTERY.equals(message.getType()) && message.getDevices() != null) { + for (final String link : message.getDevices()) { deviceStructMan.refreshDevice(Link.getId(link)); final Device device = deviceStructMan.getDeviceById(Link.getId(link)); if (device != null) {