]> git.basschouten.com Git - openhab-addons.git/blob
7a0c00ea4a8036db493ae70406010577daccc914
[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.digitalstrom.internal.lib.structure.devices.deviceparameters;
14
15 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.DeviceBinarayInputEnum;
16 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.SensorEnum;
17
18 /**
19  * Represents a device state update for lights, joker, shades and sensor data.
20  *
21  * @author Michael Ochel - Initial contribution
22  * @author Matthias Siegele - Initial contribution
23  */
24 public interface DeviceStateUpdate {
25
26     // Update types
27     // in certain circumstances it is also better to rename SLAT_ANGLE to e.g. SECONDARY_OUTPUT
28     // light
29     static final String OUTPUT = "output";
30     static final String ON_OFF = "OnOff";
31     static final String OUTPUT_INCREASE = "outputIncrese";
32     static final String OUTPUT_DECREASE = "outputDecrese";
33     static final String OUTPUT_STOP = "outputStop";
34     static final String OUTPUT_MOVE = "outputMove";
35
36     // shades
37     static final String SLATPOSITION = "slatposition";
38     static final String SLAT_ANGLE = "slatAngle";
39     static final String SLAT_INCREASE = "slatIncrese";
40     static final String SLAT_DECREASE = "slatDecrese";
41     static final String SLAT_ANGLE_INCREASE = "slatAngleIncrese";
42     static final String SLAT_ANGLE_DECREASE = "slatAngleDecrese";
43     static final String OPEN_CLOSE = "openClose";
44     static final String OPEN_CLOSE_ANGLE = "openCloseAngle";
45     static final String SLAT_MOVE = "slatMove";
46     static final String SLAT_STOP = "slatStop";
47
48     // sensor data
49     static final String UPDATE_OUTPUT_VALUE = "outputValue";
50     static final String UPDATE_DEVICE_SENSOR = "deviceSensor-";
51
52     // metering data
53     static final String UPDATE_CIRCUIT_METER = "circuitMeter";
54
55     // binary inputs
56     static final String BINARY_INPUT = "binaryInput-";
57
58     // scene
59     /** A scene call can have the value between 0 and 127. */
60     static final String UPDATE_CALL_SCENE = "callScene";
61     static final String UPDATE_UNDO_SCENE = "undoScene";
62     static final String UPDATE_SCENE_OUTPUT = "sceneOutput";
63     static final String UPDATE_SCENE_CONFIG = "sceneConfig";
64
65     // general
66     /** command to refresh the output value of a device. */
67     static final String REFRESH_OUTPUT = "refreshOutput";
68
69     // standard values
70     static final int ON_VALUE = 1;
71     static final int OFF_VALUE = -1;
72
73     /**
74      * Returns the state update value.
75      * <p>
76      * <b>NOTE:</b>
77      * </p>
78      * <ul>
79      * <li>For all OnOff-types the value for off is lower than 0 and for on higher than 0.</li>
80      * <li>For all Increase- and Decrease-types the value is the new output value.</li>
81      * <li>For SceneCall-type the value is between 0 and 127.</li>
82      * <li>For all SceneUndo-types the value is the new output value.</li>
83      * <li>For all SensorUpdate-types will read the sensor data directly, if the value is 0, otherwise a
84      * {@link SensorJob} will be added to the {@link SensorJobExecutor}.</li>
85      * </ul>
86      *
87      * @return new state value
88      */
89     Object getValue();
90
91     /**
92      * Returns the value as {@link Integer}.
93      *
94      * @return integer value
95      * @see #getValue()
96      */
97     Integer getValueAsInteger();
98
99     /**
100      * Returns the value as {@link String}.
101      *
102      * @return string value
103      * @see #getValue()
104      */
105     String getValueAsString();
106
107     /**
108      * Returns the value as {@link Short}.
109      *
110      * @return short value
111      * @see #getValue()
112      */
113     Short getValueAsShort();
114
115     /**
116      * Returns the value as {@link Float}.
117      *
118      * @return float value
119      * @see #getValue()
120      */
121     Float getValueAsFloat();
122
123     /**
124      * Returns the value as {@link Short}-array.
125      *
126      * @return short[] value
127      * @see #getValue()
128      */
129     Short[] getValueAsShortArray();
130
131     /**
132      * Returns the state update type.
133      *
134      * @return state update type
135      */
136     String getType();
137
138     /**
139      * Returns the update type as {@link SensorEnum} or null, if the type is not a {@link #UPDATE_DEVICE_SENSOR} type.
140      *
141      * @return type as {@link SensorEnum} or null
142      */
143     SensorEnum getTypeAsSensorEnum();
144
145     /**
146      * Returns true, if this {@link DeviceStateUpdate} is a {@link #UPDATE_DEVICE_SENSOR} type, otherwise false.
147      *
148      * @return true, if it is a sensor type
149      */
150     boolean isSensorUpdateType();
151
152     /**
153      * Returns the scene id of this {@link DeviceStateUpdate}, if this {@link DeviceStateUpdate} is a scene update type,
154      * otherwise it will be returned -1.
155      *
156      * @return the scene id or -1
157      */
158     Short getSceneId();
159
160     /**
161      * Returns the scene configuration or output reading priority, if this {@link DeviceStateUpdate} is a
162      * {@link #UPDATE_SCENE_CONFIG} or {@link #UPDATE_SCENE_OUTPUT} type.
163      *
164      * @return scene reading priority
165      */
166     Short getScenePriority();
167
168     /**
169      * Returns true, if this {@link DeviceStateUpdate} is a {@link #UPDATE_SCENE_CONFIG} or {@link #UPDATE_SCENE_OUTPUT}
170      * type, otherwise false.
171      *
172      * @return true, if it is a scene reading type
173      */
174     boolean isSceneUpdateType();
175
176     /**
177      * Returns the update type as {@link DeviceBinarayInputEnum} or null, if the type is not a {@link #BINARY_INPUT}
178      * type.
179      *
180      * @return type as {@link DeviceBinarayInputEnum} or null
181      */
182     DeviceBinarayInputEnum getTypeAsDeviceBinarayInputEnum();
183
184     /**
185      * Returns true, if this {@link DeviceStateUpdate} is a {@link #BINARY_INPUT} type, otherwise false.
186      *
187      * @return true, if it is a binary input type
188      */
189     boolean isBinarayInputType();
190 }