]> git.basschouten.com Git - openhab-addons.git/blob
733c7835e998478ce769a152366b2261e47d8ce4
[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.livisismarthome.internal.client.api.entity.action;
14
15 /**
16  * Special {@link ActionDTO} needed to control shutters.
17  *
18  * @author Marco Mans - Initial contribution
19  */
20 public class ShutterActionDTO extends ActionDTO {
21
22     private static final String TYPE_STOP_RAMP = "StopRamp";
23     private static final String TYPE_START_RAMP = "StartRamp";
24     private static final String DIRECTION_RAMP_UP = "RampUp";
25     private static final String DIRECTION_RAMP_DOWN = "RampDown";
26     private static final String CONSTANT = "Constant";
27     private static final String NAMESPACE_COSIP = "CosipDevices.RWE";
28
29     /**
30      * Describes a Shutteraction
31      *
32      * @param capabilityId String of the 32 character capability id
33      * @param action Which action to perform (UP, DOWN, STOP)
34      */
35     public ShutterActionDTO(String capabilityId, ShutterActionType action) {
36         setTargetCapabilityById(capabilityId);
37         setNamespace(NAMESPACE_COSIP);
38         final ActionParamsDTO params = new ActionParamsDTO();
39
40         if (ShutterActionType.STOP.equals(action)) {
41             setType(TYPE_STOP_RAMP);
42         } else if (ShutterActionType.UP.equals(action)) {
43             setType(TYPE_START_RAMP);
44             params.setRampDirection(new StringActionParamDTO(CONSTANT, DIRECTION_RAMP_UP));
45         } else if (ShutterActionType.DOWN.equals(action)) {
46             setType(TYPE_START_RAMP);
47             params.setRampDirection(new StringActionParamDTO(CONSTANT, DIRECTION_RAMP_DOWN));
48         }
49         setParams(params);
50     }
51 }