]> git.basschouten.com Git - openhab-addons.git/blob
d19693b37c65c5596c6dc1be98332e1579b6df79
[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.neohub.internal;
14
15 import java.util.regex.Pattern;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.core.thing.ThingTypeUID;
19
20 /**
21  * The {@link NeoHubBindingConstants} class defines common constants
22  *
23  * @author Sebastian Prehn - Initial contribution (NeoHub command codes)
24  * @author Andrew Fiddian-Green - Initial contribution (OpenHAB v2.x binding
25  *         code)
26  *
27  */
28 @NonNullByDefault
29 public class NeoHubBindingConstants {
30
31     /*
32      * binding id
33      */
34     public static final String BINDING_ID = "neohub";
35
36     /*
37      * device id's
38      */
39     public static final String DEVICE_ID_NEOHUB = "neohub";
40     public static final String DEVICE_ID_NEOSTAT = "neostat";
41     public static final String DEVICE_ID_NEOPLUG = "neoplug";
42     public static final String DEVICE_ID_NEOCONTACT = "neocontact";
43     public static final String DEVICE_ID_NEOTEMPERATURESENSOR = "neotemperaturesensor";
44
45     /*
46      * Thing Type UIDs
47      */
48     public static final ThingTypeUID THING_TYPE_NEOHUB = new ThingTypeUID(BINDING_ID, DEVICE_ID_NEOHUB);
49     public static final ThingTypeUID THING_TYPE_NEOSTAT = new ThingTypeUID(BINDING_ID, DEVICE_ID_NEOSTAT);
50     public static final ThingTypeUID THING_TYPE_NEOPLUG = new ThingTypeUID(BINDING_ID, DEVICE_ID_NEOPLUG);
51     public static final ThingTypeUID THING_TYPE_NEOCONTACT = new ThingTypeUID(BINDING_ID, DEVICE_ID_NEOCONTACT);
52     public static final ThingTypeUID THING_TYPE_NEOTEMPERATURESENSOR = new ThingTypeUID(BINDING_ID,
53             DEVICE_ID_NEOTEMPERATURESENSOR);
54
55     /*
56      * Channel IDs for NeoHub
57      */
58     public static final String CHAN_MESH_NETWORK_QOS = "meshNetworkQoS";
59
60     /*
61      * Channel IDs common for several device types
62      */
63     public static final String CHAN_BATTERY_LOW_ALARM = "batteryLowAlarm";
64
65     /*
66      * Channel IDs for NeoStat thermostats
67      */
68     public static final String CHAN_ROOM_TEMP = "roomTemperature";
69     public static final String CHAN_TARGET_TEMP = "targetTemperature";
70     public static final String CHAN_FLOOR_TEMP = "floorTemperature";
71     public static final String CHAN_OCC_MODE_PRESENT = "occupancyModePresent";
72     public static final String CHAN_STAT_OUTPUT_STATE = "thermostatOutputState";
73
74     /*
75      * Channel IDs for NeoPlug smart plugs
76      */
77     public static final String CHAN_PLUG_OUTPUT_STATE = "plugOutputState";
78     public static final String CHAN_PLUG_AUTO_MODE = "plugAutoMode";
79
80     /*
81      * Channel IDs for NeoContact (wireless) contact sensors
82      */
83     public static final String CHAN_CONTACT_STATE = "contactState";
84
85     /*
86      * Channel IDs for NeoTemperatureSensor (wireless) temperature sensors
87      */
88     public static final String CHAN_TEMPERATURE_SENSOR = "sensorTemperature";
89
90     /*
91      * Heatmiser Device Types
92      */
93     public static final int HEATMISER_DEVICE_TYPE_CONTACT = 5;
94     public static final int HEATMISER_DEVICE_TYPE_PLUG = 6;
95     public static final int HEATMISER_DEVICE_TYPE_REPEATER = 10;
96     public static final int HEATMISER_DEVICE_TYPE_TEMPERATURE_SENSOR = 14;
97
98     /*
99      * configuration parameters
100      */
101     public static final String PARAM_HOLD_ONLINE_STATE = "holdOnlineState";
102
103     /*
104      * regular expression pattern matchers
105      */
106     public static final Pattern MATCHER_HEATMISER_REPEATER = Pattern.compile("^repeaternode\\d+");
107     public static final Pattern MATCHER_IP_ADDRESS = Pattern
108             .compile("\\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4}\\b");
109
110     /*
111      * enumerator for results of method calls
112      */
113     public enum NeoHubReturnResult {
114         SUCCEEDED,
115         ERR_COMMUNICATION,
116         ERR_INITIALIZATION
117     }
118
119     /*
120      * the property IdD for the name of a thing in the NeoHub note: names may differ
121      * between the NeoHub and the OpenHAB framework
122      */
123     public static final String DEVICE_NAME = "deviceNameInHub";
124
125     /*
126      * setup parameters for de-bouncing of state changes (time in seconds) so state
127      * changes that occur within this time window are ignored
128      */
129     public static final long DEBOUNCE_DELAY = 15;
130
131     /*
132      * setup parameters for lazy polling
133      */
134     public static final int LAZY_POLL_INTERVAL = 60;
135
136     /*
137      * setup parameters for fast polling bursts a burst comprises FAST_POLL_CYCLES
138      * polling calls spaced at FAST_POLL_INTERVAL for example 5 polling calls made
139      * at 4 second intervals (e.g. 5 x 4 => 20 seconds)
140      */
141     public static final int FAST_POLL_CYCLES = 5;
142     public static final int FAST_POLL_INTERVAL = 4;
143
144     /*
145      * setup parameters for device discovery
146      */
147     public static final int DISCOVERY_TIMEOUT = 5;
148     public static final int DISCOVERY_START_DELAY = 30;
149     public static final int DISCOVERY_REFRESH_PERIOD = 600;
150
151     /*
152      * NeoHub JSON command codes strings: Thanks to Sebastian Prehn !!
153      */
154     public static final String CMD_CODE_INFO = "{\"INFO\":0}";
155     public static final String CMD_CODE_TEMP = "{\"SET_TEMP\":[%s, \"%s\"]}";
156     public static final String CMD_CODE_AWAY = "{\"FROST_%s\":\"%s\"}";
157     public static final String CMD_CODE_TIMER = "{\"TIMER_%s\":\"%s\"}";
158     public static final String CMD_CODE_MANUAL = "{\"MANUAL_%s\":\"%s\"}";
159     public static final String CMD_CODE_READ_DCB = "{\"READ_DCB\":100}";
160     public static final String CMD_CODE_FIRMWARE = "{\"FIRMWARE\":0}";
161
162     /*
163      * note: from NeoHub rev2.6 onwards the INFO command is "deprecated" and it
164      * should be replaced partly each by the new GET_LIVE_DATA and GET_ENGINEERS
165      * commands
166      */
167     public static final String CMD_CODE_GET_LIVE_DATA = "{\"GET_LIVE_DATA\":0}";
168     public static final String CMD_CODE_GET_ENGINEERS = "{\"GET_ENGINEERS\":0}";
169
170     /*
171      * note: from NeoHub rev2.6 onwards the READ_DCB command is "deprecated" and it
172      * should be replaced by the new GET_SYSTEM command
173      */
174     public static final String CMD_CODE_GET_SYSTEM = "{\"GET_SYSTEM\":0}";
175
176     /*
177      * openHAB status strings
178      */
179     public static final String VAL_OFF = "Off";
180     public static final String VAL_HEATING = "Heating";
181
182     /*
183      * logger message strings
184      */
185     public static final String PLEASE_REPORT_BUG = "Unexpected situation - please report a bug: ";
186     public static final String MSG_HUB_CONFIG = PLEASE_REPORT_BUG + "hub '{}' needs to be initialized!";
187     public static final String MSG_HUB_COMM = PLEASE_REPORT_BUG + "error communicating with hub '{}'!";
188     public static final String MSG_FMT_DEVICE_POLL_ERR = "hub '{}' device data polling error: {}";
189     public static final String MSG_FMT_SYSTEM_POLL_ERR = "hub '{}' system data polling error: {}";
190     public static final String MSG_FMT_ENGINEERS_POLL_ERR = "hub '{}' engineers data polling error: {}";
191     public static final String MSG_FMT_SET_VALUE_ERR = "hub '{}' {} set value error: {}";
192
193     /*
194      * hub property names
195      */
196     public static final String PROPERTY_FIRMWARE_VERSION = "Firmware version";
197     public static final String PROPERTY_API_VERSION = "API version";
198     public static final String PROPERTY_API_DEVICEINFO = "Devices [online/total]";
199
200     /*
201      * reserved ports on the hub
202      */
203     public static final int PORT_TCP = 4242;
204     public static final int PORT_WSS = 4243;
205
206     /*
207      * web socket communication constants
208      */
209     public static final String HM_GET_COMMAND_QUEUE = "hm_get_command_queue";
210     public static final String HM_SET_COMMAND_RESPONSE = "hm_set_command_response";
211 }