Simplify DateTimeType handling for Ruuvi Gateway MQTT

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
Jacob Laursen 2024-11-24 23:28:31 +01:00 committed by lsiepel
parent cb74dd6497
commit d00d654976
2 changed files with 3 additions and 7 deletions

View File

@ -13,7 +13,6 @@
package org.openhab.binding.mqtt.ruuvigateway.internal; package org.openhab.binding.mqtt.ruuvigateway.internal;
import java.time.Instant; import java.time.Instant;
import java.time.ZoneId;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.mqtt.generic.ChannelConfig; import org.openhab.binding.mqtt.generic.ChannelConfig;
@ -33,8 +32,6 @@ import org.openhab.core.thing.ChannelUID;
@NonNullByDefault @NonNullByDefault
public class RuuviCachedDateTimeState extends ChannelState { public class RuuviCachedDateTimeState extends ChannelState {
private static final ZoneId UTC = ZoneId.of("UTC");
/** /**
* Construct cache for DateTime values * Construct cache for DateTime values
* *
@ -51,6 +48,6 @@ public class RuuviCachedDateTimeState extends ChannelState {
* @param value instant representing value * @param value instant representing value
*/ */
public void update(Instant value) { public void update(Instant value) {
cachedValue.update(new DateTimeType(value.atZone(UTC))); cachedValue.update(new DateTimeType(value));
} }
} }

View File

@ -24,7 +24,6 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.Instant; import java.time.Instant;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -360,8 +359,8 @@ public class RuuviGatewayTest extends MqttOSGiTest {
assertEquals(new QuantityType<>(new BigDecimal(rssiDecibelMilliwatts), Units.DECIBEL_MILLIWATTS), assertEquals(new QuantityType<>(new BigDecimal(rssiDecibelMilliwatts), Units.DECIBEL_MILLIWATTS),
channelStateGetter.apply(CHANNEL_ID_RSSI)); channelStateGetter.apply(CHANNEL_ID_RSSI));
assertEquals(new DateTimeType(ts.atZone(ZoneId.of("UTC"))), channelStateGetter.apply(CHANNEL_ID_TS)); assertEquals(new DateTimeType(ts), channelStateGetter.apply(CHANNEL_ID_TS));
assertEquals(new DateTimeType(gwts.atZone(ZoneId.of("UTC"))), channelStateGetter.apply(CHANNEL_ID_GWTS)); assertEquals(new DateTimeType(gwts), channelStateGetter.apply(CHANNEL_ID_GWTS));
assertEquals(new StringType(gwMac), channelStateGetter.apply(CHANNEL_ID_GWMAC)); assertEquals(new StringType(gwMac), channelStateGetter.apply(CHANNEL_ID_GWMAC));
} }