]> git.basschouten.com Git - openhab-addons.git/blob
1a453a54355886216a33daf7ace612670312abc0
[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 org.openhab.binding.digitalstrom.internal.lib.sensorjobexecutor.sensorjob.SensorJob}
85      * will be added to the
86      * {@link org.openhab.binding.digitalstrom.internal.lib.sensorjobexecutor.SensorJobExecutor}.</li>
87      * </ul>
88      *
89      * @return new state value
90      */
91     Object getValue();
92
93     /**
94      * Returns the value as {@link Integer}.
95      *
96      * @return integer value
97      * @see #getValue()
98      */
99     Integer getValueAsInteger();
100
101     /**
102      * Returns the value as {@link String}.
103      *
104      * @return string value
105      * @see #getValue()
106      */
107     String getValueAsString();
108
109     /**
110      * Returns the value as {@link Short}.
111      *
112      * @return short value
113      * @see #getValue()
114      */
115     Short getValueAsShort();
116
117     /**
118      * Returns the value as {@link Float}.
119      *
120      * @return float value
121      * @see #getValue()
122      */
123     Float getValueAsFloat();
124
125     /**
126      * Returns the value as {@link Short}-array.
127      *
128      * @return short[] value
129      * @see #getValue()
130      */
131     Short[] getValueAsShortArray();
132
133     /**
134      * Returns the state update type.
135      *
136      * @return state update type
137      */
138     String getType();
139
140     /**
141      * Returns the update type as {@link SensorEnum} or null, if the type is not a {@link #UPDATE_DEVICE_SENSOR} type.
142      *
143      * @return type as {@link SensorEnum} or null
144      */
145     SensorEnum getTypeAsSensorEnum();
146
147     /**
148      * Returns true, if this {@link DeviceStateUpdate} is a {@link #UPDATE_DEVICE_SENSOR} type, otherwise false.
149      *
150      * @return true, if it is a sensor type
151      */
152     boolean isSensorUpdateType();
153
154     /**
155      * Returns the scene id of this {@link DeviceStateUpdate}, if this {@link DeviceStateUpdate} is a scene update type,
156      * otherwise it will be returned -1.
157      *
158      * @return the scene id or -1
159      */
160     Short getSceneId();
161
162     /**
163      * Returns the scene configuration or output reading priority, if this {@link DeviceStateUpdate} is a
164      * {@link #UPDATE_SCENE_CONFIG} or {@link #UPDATE_SCENE_OUTPUT} type.
165      *
166      * @return scene reading priority
167      */
168     Short getScenePriority();
169
170     /**
171      * Returns true, if this {@link DeviceStateUpdate} is a {@link #UPDATE_SCENE_CONFIG} or {@link #UPDATE_SCENE_OUTPUT}
172      * type, otherwise false.
173      *
174      * @return true, if it is a scene reading type
175      */
176     boolean isSceneUpdateType();
177
178     /**
179      * Returns the update type as {@link DeviceBinarayInputEnum} or null, if the type is not a {@link #BINARY_INPUT}
180      * type.
181      *
182      * @return type as {@link DeviceBinarayInputEnum} or null
183      */
184     DeviceBinarayInputEnum getTypeAsDeviceBinarayInputEnum();
185
186     /**
187      * Returns true, if this {@link DeviceStateUpdate} is a {@link #BINARY_INPUT} type, otherwise false.
188      *
189      * @return true, if it is a binary input type
190      */
191     boolean isBinarayInputType();
192 }