2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.mqtt.ruuvigateway.internal;
15 import java.time.Instant;
16 import java.time.ZoneId;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.mqtt.generic.ChannelConfig;
20 import org.openhab.binding.mqtt.generic.ChannelState;
21 import org.openhab.binding.mqtt.generic.values.DateTimeValue;
22 import org.openhab.core.library.types.DateTimeType;
23 import org.openhab.core.thing.ChannelUID;
26 * Simplified state cache for purposes of caching DateTime values
28 * Unlike parent class {@link ChannelState}, this class by definition is not interacting with MQTT subscriptions nor
29 * does it update any channels
31 * @author Sami Salonen - Initial contribution
34 public class RuuviCachedDateTimeState extends ChannelState {
36 private static final ZoneId UTC = ZoneId.of("UTC");
39 * Construct cache for DateTime values
41 * @param channelUID associated channel UID
44 public RuuviCachedDateTimeState(ChannelUID channelUID) {
45 super(new ChannelConfig(), channelUID, new DateTimeValue(), null);
49 * Update cached state with given value
51 * @param value instant representing value
53 public void update(Instant value) {
54 cachedValue.update(new DateTimeType(value.atZone(UTC)));