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.neohub.internal;
15 import java.math.BigDecimal;
16 import java.util.List;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
22 * An abstract prototype for wrappers around JSON responses to JSON INFO or
23 * GET_LIVE_DATA requests
25 * @author Andrew Fiddian-Green - Initial contribution
28 public abstract class NeoHubAbstractDeviceData {
30 @SuppressWarnings("null")
32 public abstract static class AbstractRecord {
34 public abstract String getDeviceName();
36 public abstract BigDecimal getTargetTemperature();
38 public abstract BigDecimal getActualTemperature();
40 public abstract BigDecimal getFloorTemperature();
42 public abstract boolean isStandby();
44 public abstract boolean isHeating();
46 public abstract boolean isPreHeating();
48 public abstract boolean isTimerOn();
50 public abstract boolean offline();
52 public abstract boolean stateManual();
54 public abstract boolean stateAuto();
56 public abstract boolean isWindowOpen();
58 public abstract boolean isBatteryLow();
60 protected BigDecimal safeBigDecimal(@Nullable BigDecimal value) {
61 return value != null ? value : BigDecimal.ZERO;
66 * returns the device record corresponding to a given device name
68 * @param deviceName the device name
69 * @return its respective device record
71 public abstract @Nullable AbstractRecord getDeviceRecord(String deviceName);
74 * @return the full list of device records
76 public abstract @Nullable List<? extends AbstractRecord> getDevices();