Simplify DateTimeType handling for Enphase

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
Jacob Laursen 2024-12-09 23:17:09 +01:00 committed by lsiepel
parent 4c176a8c82
commit d5d01b0623

View File

@ -15,8 +15,6 @@ package org.openhab.binding.enphase.internal.handler;
import static org.openhab.binding.enphase.internal.EnphaseBindingConstants.*; import static org.openhab.binding.enphase.internal.EnphaseBindingConstants.*;
import java.time.Instant; import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
@ -92,11 +90,7 @@ public class EnphaseInverterHandler extends EnphaseDeviceHandler {
if (inverterDTO == null) { if (inverterDTO == null) {
state = UnDefType.UNDEF; state = UnDefType.UNDEF;
} else { } else {
final Instant instant = Instant.ofEpochSecond(inverterDTO.lastReportDate); state = new DateTimeType(Instant.ofEpochSecond(inverterDTO.lastReportDate));
final ZonedDateTime zonedDateTime = instant.atZone(ZoneId.systemDefault());
logger.trace("[{}] Epoch time {}, zonedDateTime: {}", getThing().getUID(), inverterDTO.lastReportDate,
zonedDateTime);
state = new DateTimeType(zonedDateTime);
} }
updateState(INVERTER_CHANNEL_LAST_REPORT_DATE, state); updateState(INVERTER_CHANNEL_LAST_REPORT_DATE, state);
} }