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.pixometer.internal.data;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.pixometer.internal.config.ReadingInstance;
17 import org.openhab.core.library.types.DateTimeType;
20 * Abstract data class to store shared/common meter state values
22 * @author Jerome Luckenbach - Initial contribution
26 public class MeterState {
28 private final DateTimeType lastReadingDate;
29 private final DateTimeType lastRefreshTime;
30 private final double readingValue;
33 * Initialize times from the given timestamps
35 * @param lastReadingDate time of last reading as ZonedDateTime
36 * @param lastRefreshTime time of last refresh as ZonedDateTime
38 public MeterState(ReadingInstance reading) {
39 this.readingValue = reading.getValue();
40 this.lastReadingDate = new DateTimeType(reading.getReadingDate());
41 this.lastRefreshTime = new DateTimeType();
45 * @return returns the current reading value
47 public double getReadingValue() {
52 * @return returns the last time that the meter has been read into pixometer
54 public DateTimeType getLastReadingDate() {
55 return lastReadingDate;
59 * @return returns the last time, the item has been refreshed
61 public DateTimeType getLastRefreshTime() {
62 return lastRefreshTime;