]> git.basschouten.com Git - openhab-addons.git/blob
2853954b35c06aa1fceca8df489a8b87126fc924
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.neohub.internal;
14
15 import java.math.BigDecimal;
16 import java.util.List;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20
21 /**
22  * An abstract prototype for wrappers around JSON responses to JSON INFO or
23  * GET_LIVE_DATA requests
24  *
25  * @author Andrew Fiddian-Green - Initial contribution
26  */
27 @NonNullByDefault
28 public abstract class NeoHubAbstractDeviceData {
29
30     @SuppressWarnings("null")
31     @NonNullByDefault
32     public abstract static class AbstractRecord {
33
34         public abstract String getDeviceName();
35
36         public abstract BigDecimal getTargetTemperature();
37
38         public abstract BigDecimal getActualTemperature();
39
40         public abstract BigDecimal getFloorTemperature();
41
42         public abstract boolean isStandby();
43
44         public abstract boolean isHeating();
45
46         public abstract boolean isPreHeating();
47
48         public abstract boolean isTimerOn();
49
50         public abstract boolean offline();
51
52         public abstract boolean stateManual();
53
54         public abstract boolean stateAuto();
55
56         public abstract boolean isWindowOpen();
57
58         public abstract boolean isBatteryLow();
59
60         protected BigDecimal safeBigDecimal(@Nullable BigDecimal value) {
61             return value != null ? value : BigDecimal.ZERO;
62         }
63     }
64
65     /**
66      * returns the device record corresponding to a given device name
67      * 
68      * @param deviceName the device name
69      * @return its respective device record
70      */
71     public abstract @Nullable AbstractRecord getDeviceRecord(String deviceName);
72
73     /**
74      * @return the full list of device records
75      */
76     public abstract @Nullable List<? extends AbstractRecord> getDevices();
77 }