]> git.basschouten.com Git - openhab-addons.git/blob
66370531b5658b013a4ddfae19d5019bbed3b152
[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.livisismarthome.internal.client.api.entity.capability;
14
15 /**
16  * Defines the structure of a {@link CapabilityDTO}. 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 CapabilityDTO {
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 CapabilityConfigDTO config;
64
65     private CapabilityStateDTO capabilityState;
66
67     public String getId() {
68         return id;
69     }
70
71     public void setId(String id) {
72         this.id = id;
73     }
74
75     public String getType() {
76         return type;
77     }
78
79     public void setType(String type) {
80         this.type = type;
81     }
82
83     public String getDeviceLink() {
84         return device;
85     }
86
87     public void setDeviceLink(String deviceLink) {
88         this.device = deviceLink;
89     }
90
91     public CapabilityConfigDTO getConfig() {
92         return config;
93     }
94
95     public void setConfig(CapabilityConfigDTO config) {
96         this.config = config;
97     }
98
99     /**
100      * Returns the {@link CapabilityStateDTO}. Only available, if capability has a state. Better check with
101      * {@link CapabilityDTO#hasState()} first!
102      *
103      * @return the capabilityState or null
104      */
105     public CapabilityStateDTO getCapabilityState() {
106         return capabilityState;
107     }
108
109     /**
110      * @param capabilityState the capabilityState to set
111      */
112     public void setCapabilityState(CapabilityStateDTO capabilityState) {
113         this.capabilityState = capabilityState;
114     }
115
116     /**
117      * Returns, if the capability has a state. Not all capabilities have a state.
118      *
119      * @return true if the capability has a state, otherwise false
120      */
121     public boolean hasState() {
122         return (capabilityState != null) && (capabilityState.getState() != null);
123     }
124
125     /**
126      * Returns the name of the {@link CapabilityDTO}.
127      *
128      * @return capability name
129      */
130     public String getName() {
131         return getConfig().getName();
132     }
133
134     /**
135      * Returns, if the activity log is active for the {@link CapabilityDTO}.
136      *
137      * @return boolean or null, if the {@link CapabilityDTO} does not have this property.
138      */
139     public boolean getActivityLogActive() {
140         return getConfig().getActivityLogActive();
141     }
142
143     /**
144      * Returns the number of pushbuttons for the {@link CapabilityDTO}.
145      *
146      * @return int or null, if the {@link CapabilityDTO} does not have this property.
147      */
148     public int getPushButtons() {
149         return getConfig().getPushButtons();
150     }
151
152     /**
153      * Returns true, if the {@link CapabilityDTO} is of type VariableActuator.
154      *
155      * @return true if it is a VariableActuator, otherwise false
156      */
157     public boolean isTypeVariableActuator() {
158         return TYPE_VARIABLEACTUATOR.equals(getType());
159     }
160
161     /**
162      * Returns true, if the {@link CapabilityDTO} is of type SwitchActuator.
163      *
164      * @return true if it is a SwitchActuator, otherwise false
165      */
166     public boolean isTypeSwitchActuator() {
167         return TYPE_SWITCHACTUATOR.equals(getType());
168     }
169
170     /**
171      * Returns true, if the {@link CapabilityDTO} is of type ThermostatActuator.
172      *
173      * @return true if it is a SwitchActuator, otherwise false
174      */
175     public boolean isTypeThermostatActuator() {
176         return TYPE_THERMOSTATACTUATOR.equals(getType());
177     }
178
179     /**
180      * Returns true, if the {@link CapabilityDTO} is of type TemperatureSensor.
181      *
182      * @return true if it is a TemperatureSensor, otherwise false
183      */
184     public boolean isTypeTemperatureSensor() {
185         return TYPE_TEMPERATURESENSOR.equals(getType());
186     }
187
188     /**
189      * Returns true, if the {@link CapabilityDTO} is of type HumiditySensor.
190      *
191      * @return true if it is a HumiditySensor, otherwise false
192      */
193     public boolean isTypeHumiditySensor() {
194         return TYPE_HUMIDITYSENSOR.equals(getType());
195     }
196
197     /**
198      * Returns true, if the {@link CapabilityDTO} is of type WindowDoorSensor.
199      *
200      * @return true if it is a WindowDoorSensor, otherwise false
201      */
202     public boolean isTypeWindowDoorSensor() {
203         return TYPE_WINDOWDOORSENSOR.equals(getType());
204     }
205
206     /**
207      * Returns true, if the {@link CapabilityDTO} is of type SmokeDetectorSensor.
208      *
209      * @return true if it is a SmokeDetector, otherwise false
210      */
211     public boolean isTypeSmokeDetectorSensor() {
212         return TYPE_SMOKEDETECTORSENSOR.equals(getType());
213     }
214
215     /**
216      * Returns true, if the {@link CapabilityDTO} is of type AlarmActuator.
217      *
218      * @return true if it is an AlarmActuator, otherwise false
219      */
220     public boolean isTypeAlarmActuator() {
221         return TYPE_ALARMACTUATOR.equals(getType());
222     }
223
224     /**
225      * Returns true, if the {@link CapabilityDTO} is of type MotionDetectionSensor.
226      *
227      * @return true if it is a MotionDetectionSensor, otherwise false
228      */
229     public boolean isTypeMotionDetectionSensor() {
230         return TYPE_MOTIONDETECTIONSENSOR.equals(getType());
231     }
232
233     /**
234      * Returns true, if the {@link CapabilityDTO} is of type LuminanceSensor.
235      *
236      * @return true if it is a LuminanceSensor, otherwise false
237      */
238     public boolean isTypeLuminanceSensor() {
239         return TYPE_LUMINANCESENSOR.equals(getType());
240     }
241
242     /**
243      * Returns true, if the {@link CapabilityDTO} is of type PushButtonSensor.
244      *
245      * @return true if it is a PushButtonSensor, otherwise false
246      */
247     public boolean isTypePushButtonSensor() {
248         return TYPE_PUSHBUTTONSENSOR.equals(getType());
249     }
250
251     /**
252      * Returns true, if the {@link CapabilityDTO} is of type DimmerActuator.
253      *
254      * @return true if it is a DimmerActuator, otherwise false
255      */
256     public boolean isTypeDimmerActuator() {
257         return TYPE_DIMMERACTUATOR.equals(getType());
258     }
259
260     /**
261      * Returns true, if the {@link CapabilityDTO} is of type RollerShutterActuator.
262      *
263      * @return true if it is a RollerShutterActuator, otherwise false
264      */
265     public boolean isTypeRollerShutterActuator() {
266         return TYPE_ROLLERSHUTTERACTUATOR.equals(getType());
267     }
268
269     /**
270      * Returns true, if the {@link CapabilityDTO} is of type EnergyConsumptionSensor.
271      *
272      * @return true if it is an EnergyConsumptionSensor, otherwise false
273      */
274     public boolean isTypeEnergyConsumptionSensor() {
275         return TYPE_ENERGYCONSUMPTIONSENSOR.equals(getType());
276     }
277
278     /**
279      * Returns true, if the {@link CapabilityDTO} is of type PowerConsumptionSensor.
280      *
281      * @return true if it is a PowerConsumptionSensor, otherwise false
282      */
283     public boolean isTypePowerConsumptionSensor() {
284         return TYPE_POWERCONSUMPTIONSENSOR.equals(getType());
285     }
286
287     /**
288      * Returns true, if the {@link CapabilityDTO} is of type GenerationMeterEnergySensor.
289      *
290      * @return true if it is a GenerationMeterEnergySensor, otherwise false
291      */
292     public boolean isTypeGenerationMeterEnergySensor() {
293         return TYPE_GENERATIONMETERENERGYSENSOR.equals(getType());
294     }
295
296     /**
297      * Returns true, if the {@link CapabilityDTO} is of type GenerationMeterPowerConsumptionSensor.
298      *
299      * @return true if it is a GenerationMeterPowerConsumptionSensor, otherwise false
300      */
301     public boolean isTypeGenerationMeterPowerConsumptionSensor() {
302         return TYPE_GENERATIONMETERPOWERCONSUMPTIONSENSOR.equals(getType());
303     }
304
305     /**
306      * Returns true, if the {@link CapabilityDTO} is of type TwoWayMeterEnergyConsumptionSensor.
307      *
308      * @return true if it is a TwoWayMeterEnergyConsumptionSensor, otherwise false
309      */
310     public boolean isTypeTwoWayMeterEnergyConsumptionSensor() {
311         return TYPE_TWOWAYMETERENERGYCONSUMPTIONSENSOR.equals(getType());
312     }
313
314     /**
315      * Returns true, if the {@link CapabilityDTO} is of type TwoWayMeterEnergyFeedSensor.
316      *
317      * @return true if it is a TwoWayMeterEnergyFeedSensor, otherwise false
318      */
319     public boolean isTypeTwoWayMeterEnergyFeedSensor() {
320         return TYPE_TWOWAYMETERENERGYFEEDSENSOR.equals(getType());
321     }
322
323     /**
324      * Returns true, if the {@link CapabilityDTO} is of type TwoWayMeterPowerConsumptionSensor.
325      *
326      * @return true if it is a TwoWayMeterPowerConsumptionSensor, otherwise false
327      */
328     public boolean isTypeTwoWayMeterPowerConsumptionSensor() {
329         return TYPE_TWOWAYMETERPOWERCONSUMPTIONSENSOR.equals(getType());
330     }
331 }