mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-26 15:21:41 +01:00
[miio] add new robo map blocks to map parser (#15591)
* [miio] add new robo map blocks to map parser Adding new block types in map parser. close #15068 * [miio] fix history for newer robot models closes #11001 --------- Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
This commit is contained in:
parent
798119305e
commit
d782ac96bc
@ -402,7 +402,7 @@ public class MiIoVacuumHandler extends MiIoAbstractHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean updateHistory(JsonArray historyData) {
|
private boolean updateHistoryLegacy(JsonArray historyData) {
|
||||||
logger.trace("Cleaning history data: {}", historyData.toString());
|
logger.trace("Cleaning history data: {}", historyData.toString());
|
||||||
updateState(CHANNEL_HISTORY_TOTALTIME,
|
updateState(CHANNEL_HISTORY_TOTALTIME,
|
||||||
new QuantityType<>(TimeUnit.SECONDS.toMinutes(historyData.get(0).getAsLong()), Units.MINUTE));
|
new QuantityType<>(TimeUnit.SECONDS.toMinutes(historyData.get(0).getAsLong()), Units.MINUTE));
|
||||||
@ -419,6 +419,32 @@ public class MiIoVacuumHandler extends MiIoAbstractHandler {
|
|||||||
return true;
|
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) {
|
private void updateHistoryRecord(JsonArray historyData) {
|
||||||
ZonedDateTime startTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(historyData.get(0).getAsLong()),
|
ZonedDateTime startTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(historyData.get(0).getAsLong()),
|
||||||
ZoneId.systemDefault());
|
ZoneId.systemDefault());
|
||||||
@ -536,7 +562,9 @@ public class MiIoVacuumHandler extends MiIoAbstractHandler {
|
|||||||
break;
|
break;
|
||||||
case CLEAN_SUMMARY_GET:
|
case CLEAN_SUMMARY_GET:
|
||||||
if (response.getResult().isJsonArray()) {
|
if (response.getResult().isJsonArray()) {
|
||||||
updateHistory(response.getResult().getAsJsonArray());
|
updateHistoryLegacy(response.getResult().getAsJsonArray());
|
||||||
|
} else if (response.getResult().isJsonObject()) {
|
||||||
|
updateHistory(response.getResult().getAsJsonObject());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CLEAN_RECORD_GET:
|
case CLEAN_RECORD_GET:
|
||||||
|
@ -68,6 +68,13 @@ public class RRMapFileParser {
|
|||||||
public static final int FURNITURES = 25;
|
public static final int FURNITURES = 25;
|
||||||
public static final int DOCK_TYPE = 26;
|
public static final int DOCK_TYPE = 26;
|
||||||
public static final int ENEMIES = 27;
|
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 DIGEST = 1024;
|
||||||
public static final int HEADER = 0x7272;
|
public static final int HEADER = 0x7272;
|
||||||
|
|
||||||
@ -287,6 +294,13 @@ public class RRMapFileParser {
|
|||||||
case FURNITURES:
|
case FURNITURES:
|
||||||
case DOCK_TYPE:
|
case DOCK_TYPE:
|
||||||
case ENEMIES:
|
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
|
// new blocktypes not yet decoded
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user