2 * Copyright (c) 2010-2023 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.innogysmarthome.internal.client.entity.capability;
16 * Defines the structure of a {@link Capability}. A capability is a specific functionality of a device like a
19 * @author Oliver Kuhl - Initial contribution
21 public class Capability {
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 CapabilityConfig config;
65 private CapabilityState capabilityState;
70 public String getId() {
75 * @param id the id to set
77 public void setId(String id) {
84 public String getType() {
89 * @param type the type to set
91 public void setType(String type) {
98 public String getDeviceLink() {
105 public void setDeviceLink(String deviceLink) {
106 this.device = deviceLink;
112 public CapabilityConfig getConfig() {
117 * @param config the config to set
119 public void setConfig(CapabilityConfig config) {
120 this.config = config;
124 * Returns the {@link CapabilityState}. Only available, if capability has a state. Better check with
125 * {@link Capability#hasState()} first!
127 * @return the capabilityState or null
129 public CapabilityState getCapabilityState() {
130 return capabilityState;
134 * @param capabilityState the capabilityState to set
136 public void setCapabilityState(CapabilityState capabilityState) {
137 this.capabilityState = capabilityState;
141 * Returns, if the capability has a state. Not all capabilities have a state.
145 public boolean hasState() {
146 return (capabilityState != null) && (capabilityState.getState() != null);
150 * Returns the name of the {@link Capability}.
154 public String getName() {
155 return getConfig().getName();
159 * Returns, if the activity log is active for the {@link Capability}.
161 * @return boolean or null, if the {@link Capability} does not have this property.
163 public boolean getActivityLogActive() {
164 return getConfig().getActivityLogActive();
168 * Returns the number of pushbuttons for the {@link Capability}.
170 * @return int or null, if the {@link Capability} does not have this property.
172 public int getPushButtons() {
173 return getConfig().getPushButtons();
177 * Returns true, if the {@link Capability} is of type VariableActuator.
181 public boolean isTypeVariableActuator() {
182 return TYPE_VARIABLEACTUATOR.equals(getType());
186 * Returns true, if the {@link Capability} is of type SwitchActuator.
190 public boolean isTypeSwitchActuator() {
191 return TYPE_SWITCHACTUATOR.equals(getType());
195 * Returns true, if the {@link Capability} is of type ThermostatActuator.
199 public boolean isTypeThermostatActuator() {
200 return TYPE_THERMOSTATACTUATOR.equals(getType());
204 * Returns true, if the {@link Capability} is of type TemperatureSensor.
208 public boolean isTypeTemperatureSensor() {
209 return TYPE_TEMPERATURESENSOR.equals(getType());
213 * Returns true, if the {@link Capability} is of type HumiditySensor.
217 public boolean isTypeHumiditySensor() {
218 return TYPE_HUMIDITYSENSOR.equals(getType());
222 * Returns true, if the {@link Capability} is of type WindowDoorSensor.
226 public boolean isTypeWindowDoorSensor() {
227 return TYPE_WINDOWDOORSENSOR.equals(getType());
231 * Returns true, if the {@link Capability} is of type SmokeDetectorSensor.
235 public boolean isTypeSmokeDetectorSensor() {
236 return TYPE_SMOKEDETECTORSENSOR.equals(getType());
240 * Returns true, if the {@link Capability} is of type AlarmActuator.
244 public boolean isTypeAlarmActuator() {
245 return TYPE_ALARMACTUATOR.equals(getType());
249 * Returns true, if the {@link Capability} is of type MotionDetectionSensor.
253 public boolean isTypeMotionDetectionSensor() {
254 return TYPE_MOTIONDETECTIONSENSOR.equals(getType());
258 * Returns true, if the {@link Capability} is of type LuminanceSensor.
262 public boolean isTypeLuminanceSensor() {
263 return TYPE_LUMINANCESENSOR.equals(getType());
267 * Returns true, if the {@link Capability} is of type PushButtonSensor.
271 public boolean isTypePushButtonSensor() {
272 return TYPE_PUSHBUTTONSENSOR.equals(getType());
276 * Returns true, if the {@link Capability} is of type DimmerActuator.
280 public boolean isTypeDimmerActuator() {
281 return TYPE_DIMMERACTUATOR.equals(getType());
285 * Returns true, if the {@link Capability} is of type RollerShutterActuator.
289 public boolean isTypeRollerShutterActuator() {
290 return TYPE_ROLLERSHUTTERACTUATOR.equals(getType());
294 * Returns true, if the {@link Capability} is of type EnergyConsumptionSensor.
298 public boolean isTypeEnergyConsumptionSensor() {
299 return TYPE_ENERGYCONSUMPTIONSENSOR.equals(getType());
303 * Returns true, if the {@link Capability} is of type PowerConsumptionSensor.
307 public boolean isTypePowerConsumptionSensor() {
308 return TYPE_POWERCONSUMPTIONSENSOR.equals(getType());
312 * Returns true, if the {@link Capability} is of type GenerationMeterEnergySensor.
316 public boolean isTypeGenerationMeterEnergySensor() {
317 return TYPE_GENERATIONMETERENERGYSENSOR.equals(getType());
321 * Returns true, if the {@link Capability} is of type GenerationMeterPowerConsumptionSensor.
325 public boolean isTypeGenerationMeterPowerConsumptionSensor() {
326 return TYPE_GENERATIONMETERPOWERCONSUMPTIONSENSOR.equals(getType());
330 * Returns true, if the {@link Capability} is of type TwoWayMeterEnergyConsumptionSensor.
334 public boolean isTypeTwoWayMeterEnergyConsumptionSensor() {
335 return TYPE_TWOWAYMETERENERGYCONSUMPTIONSENSOR.equals(getType());
339 * Returns true, if the {@link Capability} is of type TwoWayMeterEnergyFeedSensor.
343 public boolean isTypeTwoWayMeterEnergyFeedSensor() {
344 return TYPE_TWOWAYMETERENERGYFEEDSENSOR.equals(getType());
348 * Returns true, if the {@link Capability} is of type TwoWayMeterPowerConsumptionSensor.
352 public boolean isTypeTwoWayMeterPowerConsumptionSensor() {
353 return TYPE_TWOWAYMETERPOWERCONSUMPTIONSENSOR.equals(getType());