[miio] Fix date parsing issue last cleaning details (#16380)

https://community.openhab.org/t/miio-binding-roborock-s4max-no-longer-getting-last-cleaning-details/153260/3

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
Marcel 2024-02-06 20:33:32 +01:00 committed by Ciprian Pascu
parent 3c88bd1a33
commit 56a4ca07e7

View File

@ -541,12 +541,14 @@ public class MiIoVacuumHandler extends MiIoAbstractHandler {
private void updateHistoryRecord(HistoryRecordDTO historyRecordDTO) {
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]));
historyRecord.addProperty("start", historyRecordDTO.getStart().split("\\+")[0].split("\\-")[0]);
updateState(CHANNEL_HISTORY_START_TIME,
new DateTimeType(historyRecordDTO.getStart().split("\\+")[0].split("\\-")[0]));
}
if (historyRecordDTO.getEnd() != null) {
historyRecord.addProperty("end", historyRecordDTO.getEnd().split("\\+")[0]);
updateState(CHANNEL_HISTORY_END_TIME, new DateTimeType(historyRecordDTO.getEnd().split("\\+")[0]));
historyRecord.addProperty("end", historyRecordDTO.getEnd().split("\\+")[0].split("\\-")[0]);
updateState(CHANNEL_HISTORY_END_TIME,
new DateTimeType(historyRecordDTO.getEnd().split("\\+")[0].split("\\-")[0]));
}
if (historyRecordDTO.getDuration() != null) {
long duration = TimeUnit.SECONDS.toMinutes(historyRecordDTO.getDuration().longValue());