mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Simplify DateTimeType handling for Mi IO
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
daabae72e0
commit
bad29eb653
@ -552,12 +552,12 @@ public class MiIoVacuumHandler extends MiIoAbstractHandler {
|
|||||||
JsonObject historyRecord = GSON.toJsonTree(historyRecordDTO).getAsJsonObject();
|
JsonObject historyRecord = GSON.toJsonTree(historyRecordDTO).getAsJsonObject();
|
||||||
if (historyRecordDTO.getStart() != null) {
|
if (historyRecordDTO.getStart() != null) {
|
||||||
DateTimeType start = new DateTimeType(historyRecordDTO.getStart());
|
DateTimeType start = new DateTimeType(historyRecordDTO.getStart());
|
||||||
historyRecord.addProperty("start", start.toLocaleZone().format(null));
|
historyRecord.addProperty("start", start.format(null));
|
||||||
updateState(CHANNEL_HISTORY_START_TIME, start);
|
updateState(CHANNEL_HISTORY_START_TIME, start);
|
||||||
}
|
}
|
||||||
if (historyRecordDTO.getEnd() != null) {
|
if (historyRecordDTO.getEnd() != null) {
|
||||||
DateTimeType end = new DateTimeType(historyRecordDTO.getEnd());
|
DateTimeType end = new DateTimeType(historyRecordDTO.getEnd());
|
||||||
historyRecord.addProperty("end", end.toLocaleZone().format(null));
|
historyRecord.addProperty("end", end.format(null));
|
||||||
updateState(CHANNEL_HISTORY_END_TIME, end);
|
updateState(CHANNEL_HISTORY_END_TIME, end);
|
||||||
}
|
}
|
||||||
if (historyRecordDTO.getDuration() != null) {
|
if (historyRecordDTO.getDuration() != null) {
|
||||||
|
@ -17,7 +17,6 @@ import static org.mockito.ArgumentMatchers.*;
|
|||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -132,11 +131,11 @@ public class MiIoVacuumHandlerTest {
|
|||||||
|
|
||||||
verify(callback, description("Test the start time parsing")).stateUpdated(
|
verify(callback, description("Test the start time parsing")).stateUpdated(
|
||||||
eq(new ChannelUID(thingUID, MiIoBindingConstants.CHANNEL_HISTORY_START_TIME)),
|
eq(new ChannelUID(thingUID, MiIoBindingConstants.CHANNEL_HISTORY_START_TIME)),
|
||||||
eq(new DateTimeType(ZonedDateTime.parse("2024-08-20T19:20:13+02:00")).toZone(ZoneId.systemDefault())));
|
eq(new DateTimeType(ZonedDateTime.parse("2024-08-20T19:20:13+02:00"))));
|
||||||
|
|
||||||
verify(callback, description("Test the end time parsing")).stateUpdated(
|
verify(callback, description("Test the end time parsing")).stateUpdated(
|
||||||
eq(new ChannelUID(thingUID, MiIoBindingConstants.CHANNEL_HISTORY_END_TIME)),
|
eq(new ChannelUID(thingUID, MiIoBindingConstants.CHANNEL_HISTORY_END_TIME)),
|
||||||
eq(new DateTimeType(ZonedDateTime.parse("2024-08-20T19:20:59+02:00")).toZone(ZoneId.systemDefault())));
|
eq(new DateTimeType(ZonedDateTime.parse("2024-08-20T19:20:59+02:00"))));
|
||||||
|
|
||||||
verify(callback, description("Test the duration parsing")).stateUpdated(
|
verify(callback, description("Test the duration parsing")).stateUpdated(
|
||||||
eq(new ChannelUID(thingUID, MiIoBindingConstants.CHANNEL_HISTORY_DURATION)),
|
eq(new ChannelUID(thingUID, MiIoBindingConstants.CHANNEL_HISTORY_DURATION)),
|
||||||
|
Loading…
Reference in New Issue
Block a user