2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.neohub.internal;
15 import java.util.regex.Pattern;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.core.thing.ThingTypeUID;
21 * The {@link NeoHubBindingConstants} class defines common constants
23 * @author Sebastian Prehn - Initial contribution (NeoHub command codes)
24 * @author Andrew Fiddian-Green - Initial contribution (OpenHAB v2.x binding
29 public class NeoHubBindingConstants {
34 public static final String BINDING_ID = "neohub";
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";
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);
56 * Channel IDs for NeoHub
58 public static final String CHAN_MESH_NETWORK_QOS = "meshNetworkQoS";
61 * Channel IDs common for several device types
63 public static final String CHAN_BATTERY_LOW_ALARM = "batteryLowAlarm";
66 * Channel IDs for NeoStat thermostats
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";
75 * Channel IDs for NeoPlug smart plugs
77 public static final String CHAN_PLUG_OUTPUT_STATE = "plugOutputState";
78 public static final String CHAN_PLUG_AUTO_MODE = "plugAutoMode";
81 * Channel IDs for NeoContact (wireless) contact sensors
83 public static final String CHAN_CONTACT_STATE = "contactState";
86 * Channel IDs for NeoTemperatureSensor (wireless) temperature sensors
88 public static final String CHAN_TEMPERATURE_SENSOR = "sensorTemperature";
91 * Heatmiser Device Types
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;
99 * configuration parameters
101 public static final String PARAM_HOLD_ONLINE_STATE = "holdOnlineState";
104 * regular expression pattern matchers
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");
111 * enumerator for results of method calls
113 public enum NeoHubReturnResult {
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
123 public static final String DEVICE_NAME = "deviceNameInHub";
126 * setup parameters for de-bouncing of state changes (time in seconds) so state
127 * changes that occur within this time window are ignored
129 public static final long DEBOUNCE_DELAY = 15;
132 * setup parameters for lazy polling
134 public static final int LAZY_POLL_INTERVAL = 60;
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)
141 public static final int FAST_POLL_CYCLES = 5;
142 public static final int FAST_POLL_INTERVAL = 4;
145 * setup parameters for device discovery
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;
152 * NeoHub JSON command codes strings: Thanks to Sebastian Prehn !!
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}";
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
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}";
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
174 public static final String CMD_CODE_GET_SYSTEM = "{\"GET_SYSTEM\":0}";
177 * openHAB status strings
179 public static final String VAL_OFF = "Off";
180 public static final String VAL_HEATING = "Heating";
183 * logger message strings
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: {}";
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]";
201 * reserved ports on the hub
203 public static final int PORT_TCP = 4242;
204 public static final int PORT_WSS = 4243;
207 * web socket communication constants
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";