]> git.basschouten.com Git - openhab-addons.git/blob
285ee326ae3bf820198dddfc430cd5e193bb159b
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.innogysmarthome.internal.client.entity.capability;
14
15 /**
16  * Defines the structure of a {@link Capability}. A capability is a specific functionality of a device like a
17  * temperature sensor.
18  *
19  * @author Oliver Kuhl - Initial contribution
20  */
21 public class Capability {
22
23     /** capability types */
24     public static final String TYPE_SWITCHACTUATOR = "SwitchActuator";
25     public static final String TYPE_VARIABLEACTUATOR = "BooleanStateActuator";
26     public static final String TYPE_THERMOSTATACTUATOR = "ThermostatActuator";
27     public static final String TYPE_TEMPERATURESENSOR = "TemperatureSensor";
28     public static final String TYPE_HUMIDITYSENSOR = "HumiditySensor";
29     public static final String TYPE_WINDOWDOORSENSOR = "WindowDoorSensor";
30     public static final String TYPE_SMOKEDETECTORSENSOR = "SmokeDetectorSensor";
31     public static final String TYPE_ALARMACTUATOR = "AlarmActuator";
32     public static final String TYPE_MOTIONDETECTIONSENSOR = "MotionDetectionSensor";
33     public static final String TYPE_LUMINANCESENSOR = "LuminanceSensor";
34     public static final String TYPE_PUSHBUTTONSENSOR = "PushButtonSensor";
35     public static final String TYPE_DIMMERACTUATOR = "DimmerActuator";
36     public static final String TYPE_ROLLERSHUTTERACTUATOR = "RollerShutterActuator";
37     public static final String TYPE_ENERGYCONSUMPTIONSENSOR = "EnergyConsumptionSensor";
38     public static final String TYPE_POWERCONSUMPTIONSENSOR = "PowerConsumptionSensor";
39     public static final String TYPE_GENERATIONMETERENERGYSENSOR = "GenerationMeterEnergySensor";
40     public static final String TYPE_GENERATIONMETERPOWERCONSUMPTIONSENSOR = "GenerationMeterPowerConsumptionSensor";
41     public static final String TYPE_TWOWAYMETERENERGYCONSUMPTIONSENSOR = "TwoWayMeterEnergyConsumptionSensor";
42     public static final String TYPE_TWOWAYMETERENERGYFEEDSENSOR = "TwoWayMeterEnergyFeedSensor";
43     public static final String TYPE_TWOWAYMETERPOWERCONSUMPTIONSENSOR = "TwoWayMeterPowerConsumptionSensor";
44
45     /**
46      * Unique id for the Capability.
47      */
48     private String id;
49
50     /**
51      * Type of the capability – must be unique per device, since the device links to the capability via the type.
52      */
53     private String type;
54
55     /**
56      * Contains the link to the parent device, which offers the capability.
57      */
58     private String device;
59
60     /**
61      * This represents a container of all configuration properties.
62      */
63     private CapabilityConfig config;
64
65     private CapabilityState capabilityState;
66
67     /**
68      * @return the id
69      */
70     public String getId() {
71         return id;
72     }
73
74     /**
75      * @param id the id to set
76      */
77     public void setId(String id) {
78         this.id = id;
79     }
80
81     /**
82      * @return the type
83      */
84     public String getType() {
85         return type;
86     }
87
88     /**
89      * @param type the type to set
90      */
91     public void setType(String type) {
92         this.type = type;
93     }
94
95     /**
96      * @return
97      */
98     public String getDeviceLink() {
99         return device;
100     }
101
102     /**
103      * @param deviceLink
104      */
105     public void setDeviceLink(String deviceLink) {
106         this.device = deviceLink;
107     }
108
109     /**
110      * @return the config
111      */
112     public CapabilityConfig getConfig() {
113         return config;
114     }
115
116     /**
117      * @param config the config to set
118      */
119     public void setConfig(CapabilityConfig config) {
120         this.config = config;
121     }
122
123     /**
124      * Returns the {@link CapabilityState}. Only available, if capability has a state. Better check with
125      * {@link Capability#hasState()} first!
126      *
127      * @return the capabilityState or null
128      */
129     public CapabilityState getCapabilityState() {
130         return capabilityState;
131     }
132
133     /**
134      * @param capabilityState the capabilityState to set
135      */
136     public void setCapabilityState(CapabilityState capabilityState) {
137         this.capabilityState = capabilityState;
138     }
139
140     /**
141      * Returns, if the capability has a state. Not all capabilities have a state.
142      *
143      * @return
144      */
145     public boolean hasState() {
146         return (capabilityState != null) && (capabilityState.getState() != null);
147     }
148
149     /**
150      * Returns the name of the {@link Capability}.
151      *
152      * @return
153      */
154     public String getName() {
155         return getConfig().getName();
156     }
157
158     /**
159      * Returns, if the activity log is active for the {@link Capability}.
160      *
161      * @return boolean or null, if the {@link Capability} does not have this property.
162      */
163     public boolean getActivityLogActive() {
164         return getConfig().getActivityLogActive();
165     }
166
167     /**
168      * Returns the number of pushbuttons for the {@link Capability}.
169      *
170      * @return int or null, if the {@link Capability} does not have this property.
171      */
172     public int getPushButtons() {
173         return getConfig().getPushButtons();
174     }
175
176     /**
177      * Returns true, if the {@link Capability} is of type VariableActuator.
178      *
179      * @return
180      */
181     public boolean isTypeVariableActuator() {
182         return TYPE_VARIABLEACTUATOR.equals(getType());
183     }
184
185     /**
186      * Returns true, if the {@link Capability} is of type SwitchActuator.
187      *
188      * @return
189      */
190     public boolean isTypeSwitchActuator() {
191         return TYPE_SWITCHACTUATOR.equals(getType());
192     }
193
194     /**
195      * Returns true, if the {@link Capability} is of type ThermostatActuator.
196      *
197      * @return
198      */
199     public boolean isTypeThermostatActuator() {
200         return TYPE_THERMOSTATACTUATOR.equals(getType());
201     }
202
203     /**
204      * Returns true, if the {@link Capability} is of type TemperatureSensor.
205      *
206      * @return
207      */
208     public boolean isTypeTemperatureSensor() {
209         return TYPE_TEMPERATURESENSOR.equals(getType());
210     }
211
212     /**
213      * Returns true, if the {@link Capability} is of type HumiditySensor.
214      *
215      * @return
216      */
217     public boolean isTypeHumiditySensor() {
218         return TYPE_HUMIDITYSENSOR.equals(getType());
219     }
220
221     /**
222      * Returns true, if the {@link Capability} is of type WindowDoorSensor.
223      *
224      * @return
225      */
226     public boolean isTypeWindowDoorSensor() {
227         return TYPE_WINDOWDOORSENSOR.equals(getType());
228     }
229
230     /**
231      * Returns true, if the {@link Capability} is of type SmokeDetectorSensor.
232      *
233      * @return
234      */
235     public boolean isTypeSmokeDetectorSensor() {
236         return TYPE_SMOKEDETECTORSENSOR.equals(getType());
237     }
238
239     /**
240      * Returns true, if the {@link Capability} is of type AlarmActuator.
241      *
242      * @return
243      */
244     public boolean isTypeAlarmActuator() {
245         return TYPE_ALARMACTUATOR.equals(getType());
246     }
247
248     /**
249      * Returns true, if the {@link Capability} is of type MotionDetectionSensor.
250      *
251      * @return
252      */
253     public boolean isTypeMotionDetectionSensor() {
254         return TYPE_MOTIONDETECTIONSENSOR.equals(getType());
255     }
256
257     /**
258      * Returns true, if the {@link Capability} is of type LuminanceSensor.
259      *
260      * @return
261      */
262     public boolean isTypeLuminanceSensor() {
263         return TYPE_LUMINANCESENSOR.equals(getType());
264     }
265
266     /**
267      * Returns true, if the {@link Capability} is of type PushButtonSensor.
268      *
269      * @return
270      */
271     public boolean isTypePushButtonSensor() {
272         return TYPE_PUSHBUTTONSENSOR.equals(getType());
273     }
274
275     /**
276      * Returns true, if the {@link Capability} is of type DimmerActuator.
277      *
278      * @return
279      */
280     public boolean isTypeDimmerActuator() {
281         return TYPE_DIMMERACTUATOR.equals(getType());
282     }
283
284     /**
285      * Returns true, if the {@link Capability} is of type RollerShutterActuator.
286      *
287      * @return
288      */
289     public boolean isTypeRollerShutterActuator() {
290         return TYPE_ROLLERSHUTTERACTUATOR.equals(getType());
291     }
292
293     /**
294      * Returns true, if the {@link Capability} is of type EnergyConsumptionSensor.
295      *
296      * @return
297      */
298     public boolean isTypeEnergyConsumptionSensor() {
299         return TYPE_ENERGYCONSUMPTIONSENSOR.equals(getType());
300     }
301
302     /**
303      * Returns true, if the {@link Capability} is of type PowerConsumptionSensor.
304      *
305      * @return
306      */
307     public boolean isTypePowerConsumptionSensor() {
308         return TYPE_POWERCONSUMPTIONSENSOR.equals(getType());
309     }
310
311     /**
312      * Returns true, if the {@link Capability} is of type GenerationMeterEnergySensor.
313      *
314      * @return
315      */
316     public boolean isTypeGenerationMeterEnergySensor() {
317         return TYPE_GENERATIONMETERENERGYSENSOR.equals(getType());
318     }
319
320     /**
321      * Returns true, if the {@link Capability} is of type GenerationMeterPowerConsumptionSensor.
322      *
323      * @return
324      */
325     public boolean isTypeGenerationMeterPowerConsumptionSensor() {
326         return TYPE_GENERATIONMETERPOWERCONSUMPTIONSENSOR.equals(getType());
327     }
328
329     /**
330      * Returns true, if the {@link Capability} is of type TwoWayMeterEnergyConsumptionSensor.
331      *
332      * @return
333      */
334     public boolean isTypeTwoWayMeterEnergyConsumptionSensor() {
335         return TYPE_TWOWAYMETERENERGYCONSUMPTIONSENSOR.equals(getType());
336     }
337
338     /**
339      * Returns true, if the {@link Capability} is of type TwoWayMeterEnergyFeedSensor.
340      *
341      * @return
342      */
343     public boolean isTypeTwoWayMeterEnergyFeedSensor() {
344         return TYPE_TWOWAYMETERENERGYFEEDSENSOR.equals(getType());
345     }
346
347     /**
348      * Returns true, if the {@link Capability} is of type TwoWayMeterPowerConsumptionSensor.
349      *
350      * @return
351      */
352     public boolean isTypeTwoWayMeterPowerConsumptionSensor() {
353         return TYPE_TWOWAYMETERPOWERCONSUMPTIONSENSOR.equals(getType());
354     }
355 }