2 * Copyright (c) 2010-2024 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.livisismarthome.internal.client.api.entity.capability;
16 * Defines the structure of a {@link CapabilityDTO}. A capability is a specific functionality of a device like a
19 * @author Oliver Kuhl - Initial contribution
21 public class CapabilityDTO {
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";
46 * Unique id for the Capability.
51 * Type of the capability – must be unique per device, since the device links to the capability via the type.
56 * Contains the link to the parent device, which offers the capability.
58 private String device;
61 * This represents a container of all configuration properties.
63 private CapabilityConfigDTO config;
65 private CapabilityStateDTO capabilityState;
67 public String getId() {
71 public void setId(String id) {
75 public String getType() {
79 public void setType(String type) {
83 public String getDeviceLink() {
87 public void setDeviceLink(String deviceLink) {
88 this.device = deviceLink;
91 public CapabilityConfigDTO getConfig() {
95 public void setConfig(CapabilityConfigDTO config) {
100 * Returns the {@link CapabilityStateDTO}. Only available, if capability has a state. Better check with
101 * {@link CapabilityDTO#hasState()} first!
103 * @return the capabilityState or null
105 public CapabilityStateDTO getCapabilityState() {
106 return capabilityState;
110 * @param capabilityState the capabilityState to set
112 public void setCapabilityState(CapabilityStateDTO capabilityState) {
113 this.capabilityState = capabilityState;
117 * Returns, if the capability has a state. Not all capabilities have a state.
119 * @return true if the capability has a state, otherwise false
121 public boolean hasState() {
122 return (capabilityState != null) && (capabilityState.getState() != null);
126 * Returns the name of the {@link CapabilityDTO}.
128 * @return capability name
130 public String getName() {
131 return getConfig().getName();
135 * Returns, if the activity log is active for the {@link CapabilityDTO}.
137 * @return boolean or null, if the {@link CapabilityDTO} does not have this property.
139 public boolean getActivityLogActive() {
140 return getConfig().getActivityLogActive();
144 * Returns the number of pushbuttons for the {@link CapabilityDTO}.
146 * @return int or null, if the {@link CapabilityDTO} does not have this property.
148 public int getPushButtons() {
149 return getConfig().getPushButtons();
153 * Returns true, if the {@link CapabilityDTO} is of type VariableActuator.
155 * @return true if it is a VariableActuator, otherwise false
157 public boolean isTypeVariableActuator() {
158 return TYPE_VARIABLEACTUATOR.equals(getType());
162 * Returns true, if the {@link CapabilityDTO} is of type SwitchActuator.
164 * @return true if it is a SwitchActuator, otherwise false
166 public boolean isTypeSwitchActuator() {
167 return TYPE_SWITCHACTUATOR.equals(getType());
171 * Returns true, if the {@link CapabilityDTO} is of type ThermostatActuator.
173 * @return true if it is a SwitchActuator, otherwise false
175 public boolean isTypeThermostatActuator() {
176 return TYPE_THERMOSTATACTUATOR.equals(getType());
180 * Returns true, if the {@link CapabilityDTO} is of type TemperatureSensor.
182 * @return true if it is a TemperatureSensor, otherwise false
184 public boolean isTypeTemperatureSensor() {
185 return TYPE_TEMPERATURESENSOR.equals(getType());
189 * Returns true, if the {@link CapabilityDTO} is of type HumiditySensor.
191 * @return true if it is a HumiditySensor, otherwise false
193 public boolean isTypeHumiditySensor() {
194 return TYPE_HUMIDITYSENSOR.equals(getType());
198 * Returns true, if the {@link CapabilityDTO} is of type WindowDoorSensor.
200 * @return true if it is a WindowDoorSensor, otherwise false
202 public boolean isTypeWindowDoorSensor() {
203 return TYPE_WINDOWDOORSENSOR.equals(getType());
207 * Returns true, if the {@link CapabilityDTO} is of type SmokeDetectorSensor.
209 * @return true if it is a SmokeDetector, otherwise false
211 public boolean isTypeSmokeDetectorSensor() {
212 return TYPE_SMOKEDETECTORSENSOR.equals(getType());
216 * Returns true, if the {@link CapabilityDTO} is of type AlarmActuator.
218 * @return true if it is an AlarmActuator, otherwise false
220 public boolean isTypeAlarmActuator() {
221 return TYPE_ALARMACTUATOR.equals(getType());
225 * Returns true, if the {@link CapabilityDTO} is of type MotionDetectionSensor.
227 * @return true if it is a MotionDetectionSensor, otherwise false
229 public boolean isTypeMotionDetectionSensor() {
230 return TYPE_MOTIONDETECTIONSENSOR.equals(getType());
234 * Returns true, if the {@link CapabilityDTO} is of type LuminanceSensor.
236 * @return true if it is a LuminanceSensor, otherwise false
238 public boolean isTypeLuminanceSensor() {
239 return TYPE_LUMINANCESENSOR.equals(getType());
243 * Returns true, if the {@link CapabilityDTO} is of type PushButtonSensor.
245 * @return true if it is a PushButtonSensor, otherwise false
247 public boolean isTypePushButtonSensor() {
248 return TYPE_PUSHBUTTONSENSOR.equals(getType());
252 * Returns true, if the {@link CapabilityDTO} is of type DimmerActuator.
254 * @return true if it is a DimmerActuator, otherwise false
256 public boolean isTypeDimmerActuator() {
257 return TYPE_DIMMERACTUATOR.equals(getType());
261 * Returns true, if the {@link CapabilityDTO} is of type RollerShutterActuator.
263 * @return true if it is a RollerShutterActuator, otherwise false
265 public boolean isTypeRollerShutterActuator() {
266 return TYPE_ROLLERSHUTTERACTUATOR.equals(getType());
270 * Returns true, if the {@link CapabilityDTO} is of type EnergyConsumptionSensor.
272 * @return true if it is an EnergyConsumptionSensor, otherwise false
274 public boolean isTypeEnergyConsumptionSensor() {
275 return TYPE_ENERGYCONSUMPTIONSENSOR.equals(getType());
279 * Returns true, if the {@link CapabilityDTO} is of type PowerConsumptionSensor.
281 * @return true if it is a PowerConsumptionSensor, otherwise false
283 public boolean isTypePowerConsumptionSensor() {
284 return TYPE_POWERCONSUMPTIONSENSOR.equals(getType());
288 * Returns true, if the {@link CapabilityDTO} is of type GenerationMeterEnergySensor.
290 * @return true if it is a GenerationMeterEnergySensor, otherwise false
292 public boolean isTypeGenerationMeterEnergySensor() {
293 return TYPE_GENERATIONMETERENERGYSENSOR.equals(getType());
297 * Returns true, if the {@link CapabilityDTO} is of type GenerationMeterPowerConsumptionSensor.
299 * @return true if it is a GenerationMeterPowerConsumptionSensor, otherwise false
301 public boolean isTypeGenerationMeterPowerConsumptionSensor() {
302 return TYPE_GENERATIONMETERPOWERCONSUMPTIONSENSOR.equals(getType());
306 * Returns true, if the {@link CapabilityDTO} is of type TwoWayMeterEnergyConsumptionSensor.
308 * @return true if it is a TwoWayMeterEnergyConsumptionSensor, otherwise false
310 public boolean isTypeTwoWayMeterEnergyConsumptionSensor() {
311 return TYPE_TWOWAYMETERENERGYCONSUMPTIONSENSOR.equals(getType());
315 * Returns true, if the {@link CapabilityDTO} is of type TwoWayMeterEnergyFeedSensor.
317 * @return true if it is a TwoWayMeterEnergyFeedSensor, otherwise false
319 public boolean isTypeTwoWayMeterEnergyFeedSensor() {
320 return TYPE_TWOWAYMETERENERGYFEEDSENSOR.equals(getType());
324 * Returns true, if the {@link CapabilityDTO} is of type TwoWayMeterPowerConsumptionSensor.
326 * @return true if it is a TwoWayMeterPowerConsumptionSensor, otherwise false
328 public boolean isTypeTwoWayMeterPowerConsumptionSensor() {
329 return TYPE_TWOWAYMETERPOWERCONSUMPTIONSENSOR.equals(getType());