Skip to content

Commit

Permalink
[innogysmarthome] Fix Battery Warnings (Bug (openhab#7956))
Browse files Browse the repository at this point in the history
* Renamed DeviceLinkList to Devices
* Updates Javadocs + Added 2 Annotations
Closes openhab#6932

Signed-off-by: Marco Mans <[email protected]>
  • Loading branch information
mmans authored and markus7017 committed Sep 18, 2020
1 parent 1368c0a commit 35660bf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,8 @@ public List<Device> getFullDevices() throws IOException, ApiException, Authentic
final List<Message> messageList = getMessages();
final Map<String, List<Message>> 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<Message> ml;
if (deviceMessageMap.containsKey(deviceId)) {
ml = deviceMessageMap.get(deviceId);
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.message;

import com.google.gson.annotations.SerializedName;

import java.util.List;

/**
Expand Down Expand Up @@ -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.
Expand All @@ -103,7 +107,7 @@ public class Message {
*
* Optional.
*/
private List<String> deviceLinkList;
private List<String> devices;

/**
* Container for all parameters of the message. The parameters are contained in Property entities.
Expand Down Expand Up @@ -188,17 +192,17 @@ public void setRead(boolean isRead) {
}

/**
* @return the deviceLinkList
* @return the devices
*/
public List<String> getDeviceLinkList() {
return deviceLinkList;
public List<String> getDevices() {
return devices;
}

/**
* @param deviceLinkList the deviceLinkList to set
* @param devices the devices to set
*/
public void setDeviceLinkList(List<String> deviceLinkList) {
this.deviceLinkList = deviceLinkList;
public void setDevices(List<String> devices) {
this.devices = devices;
}

/**
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 35660bf

Please sign in to comment.