diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoVacuumHandler.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoVacuumHandler.java index a36bcf46304..df76917b550 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoVacuumHandler.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoVacuumHandler.java @@ -539,7 +539,7 @@ public class MiIoVacuumHandler extends MiIoAbstractHandler { } private void updateHistoryRecord(HistoryRecordDTO historyRecordDTO) { - JsonObject historyRecord = new JsonObject(); + JsonObject historyRecord = GSON.toJsonTree(historyRecordDTO).getAsJsonObject(); if (historyRecordDTO.getStart() != null) { historyRecord.addProperty("start", historyRecordDTO.getStart().split("\\+")[0]); updateState(CHANNEL_HISTORY_START_TIME, new DateTimeType(historyRecordDTO.getStart().split("\\+")[0])); @@ -703,6 +703,13 @@ public class MiIoVacuumHandler extends MiIoAbstractHandler { if (response.getResult().isJsonArray() && response.getResult().getAsJsonArray().size() > 0 && response.getResult().getAsJsonArray().get(0).isJsonArray()) { updateHistoryRecordLegacy(response.getResult().getAsJsonArray().get(0).getAsJsonArray()); + } else if (response.getResult().isJsonArray() && response.getResult().getAsJsonArray().size() > 0 + && response.getResult().getAsJsonArray().get(0).isJsonObject()) { + final HistoryRecordDTO historyRecordDTO = GSON.fromJson( + response.getResult().getAsJsonArray().get(0).getAsJsonObject(), HistoryRecordDTO.class); + if (historyRecordDTO != null) { + updateHistoryRecord(historyRecordDTO); + } } else if (response.getResult().isJsonObject()) { final HistoryRecordDTO historyRecordDTO = GSON.fromJson(response.getResult().getAsJsonObject(), HistoryRecordDTO.class); @@ -710,7 +717,7 @@ public class MiIoVacuumHandler extends MiIoAbstractHandler { updateHistoryRecord(historyRecordDTO); } } else { - logger.debug("Could not extract cleaning history record from: {}", response); + logger.debug("Could not extract cleaning history record from: {}", response.getResult()); } break; case GET_MAP: @@ -734,11 +741,9 @@ public class MiIoVacuumHandler extends MiIoAbstractHandler { case GET_FW_FEATURES: case GET_CUSTOMIZED_CLEAN_MODE: case GET_MULTI_MAP_LIST: - case SET_COLLECT_DUST: case SET_CLEAN_MOP_START: case SET_CLEAN_MOP_STOP: - for (RobotCababilities cmd : FEATURES_CHANNELS) { if (response.getCommand().getCommand().contentEquals(cmd.getCommand())) { updateState(cmd.getChannel(), new StringType(response.getResult().toString())); diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/HistoryRecordDTO.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/HistoryRecordDTO.java index c30b044536b..ca21f465de5 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/HistoryRecordDTO.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/HistoryRecordDTO.java @@ -27,6 +27,9 @@ public class HistoryRecordDTO { @SerializedName("start") @Expose private String start; + @SerializedName("begin") + @Expose + private String begin; @SerializedName("end") @Expose private String end; @@ -45,6 +48,9 @@ public class HistoryRecordDTO { @SerializedName("finished") @Expose private Integer finished; + @SerializedName("complete") + @Expose + private Integer complete; @SerializedName("start_type") @Expose private Integer startType; @@ -57,9 +63,12 @@ public class HistoryRecordDTO { @SerializedName("dust_collection_status") @Expose private Integer dustCollectionStatus; + @SerializedName("map_flag") + @Expose + private Integer mapFlag; public final String getStart() { - return start; + return start != null ? start : begin; } public final void setStart(String start) { @@ -107,7 +116,7 @@ public class HistoryRecordDTO { } public final Integer getFinished() { - return finished; + return finished != null ? finished : complete; } public final void setFinished(Integer finished) { @@ -145,4 +154,12 @@ public class HistoryRecordDTO { public final void setDustCollectionStatus(Integer dustCollectionStatus) { this.dustCollectionStatus = dustCollectionStatus; } + + public final Integer getMapFlag() { + return mapFlag; + } + + public final void setMapFlag(Integer mapFlag) { + this.mapFlag = mapFlag; + } }