return true;
}
- private boolean updateHistory(JsonArray historyData) {
+ private boolean updateHistoryLegacy(JsonArray historyData) {
logger.trace("Cleaning history data: {}", historyData.toString());
updateState(CHANNEL_HISTORY_TOTALTIME,
new QuantityType<>(TimeUnit.SECONDS.toMinutes(historyData.get(0).getAsLong()), Units.MINUTE));
return true;
}
+ private boolean updateHistory(JsonObject historyData) {
+ logger.trace("Cleaning history data: {}", historyData);
+ if (historyData.has("clean_time")) {
+ updateState(CHANNEL_HISTORY_TOTALTIME, new QuantityType<>(
+ TimeUnit.SECONDS.toMinutes(historyData.get("clean_time").getAsLong()), Units.MINUTE));
+ }
+ if (historyData.has("clean_area")) {
+ updateState(CHANNEL_HISTORY_TOTALAREA,
+ new QuantityType<>(historyData.get("clean_area").getAsDouble() / 1000000D, SIUnits.SQUARE_METRE));
+ }
+ if (historyData.has("clean_count")) {
+ updateState(CHANNEL_HISTORY_COUNT, new DecimalType(historyData.get("clean_count").getAsLong()));
+ }
+ if (historyData.has("records") & historyData.get("records").isJsonArray()) {
+ JsonArray historyRecords = historyData.get("records").getAsJsonArray();
+ if (!historyRecords.isEmpty()) {
+ String lastClean = historyRecords.get(0).getAsString();
+ if (!lastClean.equals(lastHistoryId)) {
+ lastHistoryId = lastClean;
+ sendCommand(MiIoCommand.CLEAN_RECORD_GET, "[" + lastClean + "]");
+ }
+ }
+ }
+ return true;
+ }
+
private void updateHistoryRecord(JsonArray historyData) {
ZonedDateTime startTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(historyData.get(0).getAsLong()),
ZoneId.systemDefault());
break;
case CLEAN_SUMMARY_GET:
if (response.getResult().isJsonArray()) {
- updateHistory(response.getResult().getAsJsonArray());
+ updateHistoryLegacy(response.getResult().getAsJsonArray());
+ } else if (response.getResult().isJsonObject()) {
+ updateHistory(response.getResult().getAsJsonObject());
}
break;
case CLEAN_RECORD_GET:
public static final int FURNITURES = 25;
public static final int DOCK_TYPE = 26;
public static final int ENEMIES = 27;
+ public static final int DOOR_ZONES = 28;
+ public static final int STUCK_POINTS = 29;
+ public static final int CLIFF_ZONES = 30;
+ public static final int SMARTDS = 31;
+ public static final int FLDIREC = 32;
+ public static final int MAP_DATE = 33;
+ public static final int NONCE_DATA = 34;
public static final int DIGEST = 1024;
public static final int HEADER = 0x7272;
case FURNITURES:
case DOCK_TYPE:
case ENEMIES:
+ case DOOR_ZONES:
+ case STUCK_POINTS:
+ case CLIFF_ZONES:
+ case SMARTDS:
+ case FLDIREC:
+ case MAP_DATE:
+ case NONCE_DATA:
// new blocktypes not yet decoded
break;
default: