]> git.basschouten.com Git - openhab-addons.git/blob
ce07389b6ed43e0bca0ad5e1d58e24a39835c6b7
[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.siemensrds.internal;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.core.thing.ThingTypeUID;
17
18 /**
19  * The {@link RdsBindingConstants} contains the constants used by the binding
20  *
21  * @author Andrew Fiddian-Green - Initial contribution
22  */
23 @NonNullByDefault
24 public class RdsBindingConstants {
25
26     /*
27      * binding id
28      */
29     public static final String BINDING_ID = "siemensrds";
30
31     /*
32      * device id's
33      */
34     public static final String DEVICE_ID_CLOUD = "climatixic";
35     public static final String DEVICE_ID_STAT = "rds";
36
37     /*
38      * Thing Type UIDs
39      */
40     public static final ThingTypeUID THING_TYPE_CLOUD = new ThingTypeUID(BINDING_ID, DEVICE_ID_CLOUD);
41
42     public static final ThingTypeUID THING_TYPE_RDS = new ThingTypeUID(BINDING_ID, DEVICE_ID_STAT);
43
44     // ========================== URLs and HTTP stuff =========================
45
46     private static final String API = "https://api.climatixic.com/";
47
48     private static final String ARG_RDS = "?filterId=[" + "{\"asn\":\"RDS110\"}," + "{\"asn\":\"RDS120\"},"
49             + "{\"asn\":\"RDS110.R\"}," + "{\"asn\":\"RDS120.B\"}" + "]";
50
51     private static final String ARG_PARENT = "?parentId=[\"%s\"]&take=100";
52     private static final String ARG_POINT = "?filterId=[%s]";
53
54     public static final String URL_TOKEN = API + "Token";
55     public static final String URL_PLANTS = API + "Plants" + ARG_RDS;
56     public static final String URL_POINTS = API + "DataPoints" + ARG_PARENT;
57     public static final String URL_SETVAL = API + "DataPoints/%s";
58     public static final String URL_VALUES = API + "DataPoints/Values" + ARG_POINT;
59
60     public static final String HTTP_POST = "POST";
61     public static final String HTTP_GET = "GET";
62     public static final String HTTP_PUT = "PUT";
63
64     public static final String USER_AGENT = "User-Agent";
65     public static final String ACCEPT = "Accept";
66     public static final String CONTENT_TYPE = "Content-Type";
67
68     public static final String MOZILLA = "Mozilla/5.0";
69     public static final String APPLICATION_JSON = "application/json;charset=UTF-8";
70     public static final String TEXT_PLAIN = "text/plain;charset=UTF-8";
71     public static final String SUBSCRIPTION_KEY = "Ocp-Apim-Subscription-Key";
72     public static final String AUTHORIZATION = "Authorization";
73     public static final String BEARER = "Bearer %s";
74
75     public static final String TOKEN_REQUEST = "grant_type=password&username=%s&password=%s&expire_minutes=20160";
76
77     /*
78      * setup parameters for de-bouncing of state changes (time in seconds) so state
79      * changes that occur within this time window are ignored
80      */
81     public static final long DEBOUNCE_DELAY = 15;
82
83     /*
84      * setup parameters for lazy polling
85      */
86     public static final int LAZY_POLL_INTERVAL = 60;
87
88     /*
89      * setup parameters for fast polling bursts a burst comprises FAST_POLL_CYCLES
90      * polling calls spaced at FAST_POLL_INTERVAL for example 5 polling calls made
91      * at 4 second intervals (e.g. 6 x 4 => 24 seconds)
92      */
93     public static final int FAST_POLL_CYCLES = 6;
94     public static final int FAST_POLL_INTERVAL = 8;
95
96     /*
97      * setup parameters for device discovery
98      */
99     public static final int DISCOVERY_TIMEOUT = 5;
100     public static final int DISCOVERY_START_DELAY = 30;
101     public static final int DISCOVERY_REFRESH_PERIOD = 600;
102
103     public static final String PROP_PLANT_ID = "plantId";
104
105     /*
106      * ==================== USED DATA POINTS ==========================
107      * 
108      * where: HIE_xxx = the point class suffix part of the hierarchy name in the
109      * ClimatixIc server, and CHA_xxx = the Channel ID in the OpenHAB binding
110      * 
111      */
112     // device name
113     public static final String HIE_DESCRIPTION = "'Description";
114
115     // online state
116     public static final String HIE_ONLINE = "#Online";
117
118     // room (actual) temperature (read-only)
119     protected static final String CHA_ROOM_TEMP = "roomTemperature";
120     public static final String HIE_ROOM_TEMP = "'RTemp";
121
122     // room relative humidity (read-only)
123     protected static final String CHA_ROOM_HUMIDITY = "roomHumidity";
124     public static final String HIE_ROOM_HUMIDITY = "'RHuRel";
125
126     // room air quality (low/med/high) (read-only)
127     protected static final String CHA_ROOM_AIR_QUALITY = "roomAirQuality";
128     public static final String HIE_ROOM_AIR_QUALITY = "'RAQualInd";
129
130     // energy savings level (green leaf) (poor..excellent) (read-write)
131     // note: writing the value "5" forces the device to green leaf mode
132     protected static final String CHA_ENERGY_SAVINGS_LEVEL = "energySavingsLevel";
133     public static final String HIE_ENERGY_SAVINGS_LEVEL = "'REei";
134
135     // outside air temperature (read-only)
136     protected static final String CHA_OUTSIDE_TEMP = "outsideTemperature";
137     public static final String HIE_OUTSIDE_TEMP = "'TOa";
138
139     // set-point override (read-write)
140     protected static final String CHA_TARGET_TEMP = "targetTemperature";
141     public static final String HIE_TARGET_TEMP = "'SpTR";
142
143     // heating/cooling state (read-only)
144     protected static final String CHA_OUTPUT_STATE = "thermostatOutputState";
145     public static final String HIE_OUTPUT_STATE = "'HCSta";
146
147     /*
148      * thermostat occupancy state (absent, present) (read-write) NOTE: uses
149      * different parameters as follows.. OccMod = 2, 3 to read, and command to, the
150      * absent, present states
151      */
152     protected static final String CHA_STAT_OCC_MODE_PRESENT = "occupancyModePresent";
153     public static final String HIE_STAT_OCC_MODE_PRESENT = "'OccMod";
154
155     /*
156      * thermostat program mode (read-write) NOTE: uses different parameters as
157      * follows.. PrOpModRsn presentPriority < / > 13 combined with OccMod = 2 to
158      * read the manual, auto mode CmfBtn = 1 to command to the manual mode REei = 5
159      * to command to the auto mode
160      */
161     protected static final String CHA_STAT_AUTO_MODE = "thermostatAutoMode";
162     public static final String HIE_PR_OP_MOD_RSN = "'PrOpModRsn";
163     public static final String HIE_STAT_CMF_BTN = "'CmfBtn";
164
165     /*
166      * domestic hot water state (off, on) (read-write) NOTE: uses different
167      * parameters as follows.. DhwMod = 1, 2 to read, and command to, the off, on
168      * states
169      */
170     protected static final String CHA_DHW_OUTPUT_STATE = "hotWaterOutputState";
171     public static final String HIE_DHW_OUTPUT_STATE = "'DhwMod";
172
173     /*
174      * domestic hot water program mode (manual, auto) (read-write) NOTE: uses
175      * different parameters as follows.. DhwMod presentPriority < / > 13 to read the
176      * manual, auto mode DhwMod = 0 to command to the auto mode DhwMod = its current
177      * value to command it's resp. manual states
178      */
179     protected static final String CHA_DHW_AUTO_MODE = "hotWaterAutoMode";
180
181     /*
182      * openHAB status strings
183      */
184     protected static final String STATE_NEITHER = "Neither";
185     protected static final String STATE_OFF = "Off";
186
187     public static final ChannelMap[] CHAN_MAP = { new ChannelMap(CHA_ROOM_TEMP, HIE_ROOM_TEMP),
188             new ChannelMap(CHA_ROOM_HUMIDITY, HIE_ROOM_HUMIDITY), new ChannelMap(CHA_OUTSIDE_TEMP, HIE_OUTSIDE_TEMP),
189             new ChannelMap(CHA_TARGET_TEMP, HIE_TARGET_TEMP),
190             new ChannelMap(CHA_ROOM_AIR_QUALITY, HIE_ROOM_AIR_QUALITY),
191             new ChannelMap(CHA_ENERGY_SAVINGS_LEVEL, HIE_ENERGY_SAVINGS_LEVEL),
192             new ChannelMap(CHA_OUTPUT_STATE, HIE_OUTPUT_STATE),
193             new ChannelMap(CHA_STAT_OCC_MODE_PRESENT, HIE_STAT_OCC_MODE_PRESENT),
194             new ChannelMap(CHA_STAT_AUTO_MODE, HIE_PR_OP_MOD_RSN),
195             new ChannelMap(CHA_DHW_OUTPUT_STATE, HIE_DHW_OUTPUT_STATE),
196             new ChannelMap(CHA_DHW_AUTO_MODE, HIE_DHW_OUTPUT_STATE) };
197
198     /*
199      * ==================== UNUSED DATA POINTS ======================
200      * 
201      * room air quality (numeric value)
202      * 
203      * private static final String HIE_ROOM_AIR_QUALITY_VAL = "RAQual";
204      * 
205      * other set-points for phases of the time program mode
206      * 
207      * private static final String HIE_CMF_SETPOINT = "SpHCmf";
208      * 
209      * private static final String HIE_PCF_SETPOINT = "SpHPcf";
210      * 
211      * private static final String HIE_ECO_SETPOINT = "SpHEco";
212      * 
213      * private static final String HIE_PRT_SETPOINT = "SpHPrt";
214      * 
215      * enable heating control
216      * 
217      * private static final String HIE_ENABLE_HEATING = "EnHCtl";
218      * 
219      * comfort button
220      * 
221      * private static final String HIE_COMFORT_BUTTON = "CmfBtn";
222      * 
223      */
224
225     /*
226      * logger strings
227      */
228     public static final String LOG_HTTP_COMMAND = "{} for url {} characters long";
229     public static final String LOG_CONTENT_LENGTH = "{} {} characters..";
230     public static final String LOG_PAYLOAD_FMT = "{} {}";
231
232     public static final String LOG_HTTP_COMMAND_ABR = "{} for url {} characters long (set log level to TRACE to see full url)..";
233     public static final String LOG_CONTENT_LENGTH_ABR = "{} {} characters (set log level to TRACE to see full string)..";
234     public static final String LOG_PAYLOAD_FMT_ABR = "{} {} ...";
235
236     public static final String LOG_RECEIVED_MSG = "received";
237     public static final String LOG_RECEIVED_MARK = "<<";
238
239     public static final String LOG_SENDING_MSG = "sending";
240     public static final String LOG_SENDING_MARK = ">>";
241
242     public static final String LOG_SYSTEM_EXCEPTION = "system exception in {}, type={}, message=\"{}\"";
243     public static final String LOG_RUNTIME_EXCEPTION = "runtime exception in {}, type={}, message=\"{}\"";
244 }
245
246 /**
247  * @author Andrew Fiddian-Green - Initial contribution
248  */
249 @NonNullByDefault
250 class ChannelMap {
251     public String id;
252     public String clazz;
253
254     public ChannelMap(String channelId, String pointClass) {
255         this.id = channelId;
256         this.clazz = pointClass;
257     }
258 }