]> git.basschouten.com Git - openhab-addons.git/blob
159e1277fcb98c08ea23792a00c80881864c700d
[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.innogysmarthome.internal.client.entity.action;
14
15 import org.openhab.binding.innogysmarthome.internal.client.entity.link.Link;
16
17 /**
18  * Implements the Action structure needed to send JSON actions to the innogy backend. They are used to e.g. switch the
19  * state of a device.
20  *
21  * @author Oliver Kuhl - Initial contribution
22  */
23 public class Action {
24
25     public static final String ACTION_TYPE_SETSTATE = "SetState";
26     private static final String NAMESPACE_CORE_RWE = "core.RWE";
27
28     /**
29      * Specifies the type of the action.
30      */
31     private String type;
32
33     /**
34      * Link to the entity supposed to execute the action.
35      */
36     private String target;
37
38     /**
39      * The product (context) that should handle (execute) the action. Defaults to {@link Action#NAMESPACE_CORE_RWE}.
40      */
41     private String namespace = NAMESPACE_CORE_RWE;
42
43     /**
44      * Dictionary of functions required for the intended execution of the action.
45      */
46     private ActionParams params;
47
48     /**
49      * Default constructor, used by serialization.
50      */
51     public Action() {
52         // used by serialization
53     }
54
55     /**
56      * Sets the type of the action. Usual action type is {@link Action#ACTION_TYPE_SETSTATE}.
57      *
58      * @param type
59      */
60     public Action(String type) {
61         this.type = type;
62     }
63
64     /**
65      * @return the type
66      */
67     public String getType() {
68         return type;
69     }
70
71     /**
72      * @param type the type to set
73      */
74     public void setType(String type) {
75         this.type = type;
76     }
77
78     /**
79      * @return the link to the target capability
80      */
81     public String getTarget() {
82         return target;
83     }
84
85     /**
86      * @param target the link to the target capability to set
87      */
88     public void setTarget(String target) {
89         this.target = target;
90     }
91
92     /**
93      * @return the namespace
94      */
95     public String getNamespace() {
96         return namespace;
97     }
98
99     /**
100      * @param namespace the namespace to set
101      */
102     public void setNamespace(String namespace) {
103         this.namespace = namespace;
104     }
105
106     /**
107      * Sets the link target to the given capability id.
108      *
109      * @param capabilityId String with the 32 character long id
110      */
111     public void setTargetCapabilityById(String capabilityId) {
112         setTarget(Link.LINK_TYPE_CAPABILITY + capabilityId);
113     }
114
115     /**
116      * @return the params
117      */
118     public ActionParams getParams() {
119         return params;
120     }
121
122     /**
123      * @param params the params to set
124      */
125     public void setParams(ActionParams params) {
126         this.params = params;
127     }
128 }