Skip to content

Commit

Permalink
[miio] Fix date parsing issue last cleaning details (openhab#16380)
Browse files Browse the repository at this point in the history
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: Jørgen Austvik <jaustvik@acm.org>
  • Loading branch information
marcelrv authored and austvik committed Mar 27, 2024
1 parent 05afc7b commit 2dc420b
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,14 @@ private void updateHistoryRecordLegacy(JsonArray historyData) {
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());
Expand Down

0 comments on commit 2dc420b

Please sign in to comment.