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