|
| 1 | +/** |
| 2 | + * Copyright (c) 2010-2024 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.myuplink.internal; |
| 14 | + |
| 15 | +import java.time.Instant; |
| 16 | +import java.util.Set; |
| 17 | + |
| 18 | +import org.eclipse.jdt.annotation.NonNullByDefault; |
| 19 | +import org.openhab.core.thing.ThingTypeUID; |
| 20 | + |
| 21 | +/** |
| 22 | + * The {@link MyUplinkBindingConstants} class defines common constants, which are |
| 23 | + * used across the whole binding. |
| 24 | + * |
| 25 | + * @author Alexander Friese - Initial contribution |
| 26 | + */ |
| 27 | +@NonNullByDefault |
| 28 | +public class MyUplinkBindingConstants { |
| 29 | + |
| 30 | + public static final String BINDING_ID = "myuplink"; |
| 31 | + |
| 32 | + // List of main device types |
| 33 | + public static final String DEVICE_ACCOUNT = "account"; |
| 34 | + public static final String DEVICE_GENERIC_DEVICE = "generic-device"; |
| 35 | + |
| 36 | + // List of all Thing Type UIDs |
| 37 | + public static final ThingTypeUID THING_TYPE_ACCOUNT = new ThingTypeUID(BINDING_ID, DEVICE_ACCOUNT); |
| 38 | + public static final ThingTypeUID THING_TYPE_GENERIC_DEVICE = new ThingTypeUID(BINDING_ID, DEVICE_GENERIC_DEVICE); |
| 39 | + |
| 40 | + public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_ACCOUNT, |
| 41 | + THING_TYPE_GENERIC_DEVICE); |
| 42 | + |
| 43 | + // Channel types |
| 44 | + public static final String CHANNEL_TYPE_UNIT_NONE = "NO_UNIT"; |
| 45 | + public static final String CHANNEL_TYPE_PREFIX_RW = "rw"; |
| 46 | + public static final String CHANNEL_TYPE_ENUM_PRFIX = "type-enum-"; |
| 47 | + public static final String CHANNEL_TYPE_NUMERIC_PRFIX = "type-numeric-"; |
| 48 | + public static final String CHANNEL_TYPE_DEFAULT_DATATYPE = "Number"; |
| 49 | + |
| 50 | + public static final String CHANNEL_TYPE_ENERGY = "type-energy"; |
| 51 | + public static final String CHANNEL_TYPE_ENERGY_UNIT = "kWh"; |
| 52 | + public static final String CHANNEL_TYPE_PRESSURE = "type-pressure"; |
| 53 | + public static final String CHANNEL_TYPE_PRESSURE_UNIT = "bar"; |
| 54 | + public static final String CHANNEL_TYPE_PERCENT = "type-percent"; |
| 55 | + public static final String CHANNEL_TYPE_PERCENT_UNIT = "%"; |
| 56 | + public static final String CHANNEL_TYPE_TEMPERATURE = "type-temperature"; |
| 57 | + public static final String CHANNEL_TYPE_TEMPERATURE_UNIT = "°C"; |
| 58 | + public static final String CHANNEL_TYPE_FREQUENCY = "type-frequency"; |
| 59 | + public static final String CHANNEL_TYPE_FREQUENCY_UNIT = "Hz"; |
| 60 | + public static final String CHANNEL_TYPE_FLOW = "type-flow"; |
| 61 | + public static final String CHANNEL_TYPE_FLOW_UNIT = "l/m"; |
| 62 | + public static final String CHANNEL_TYPE_ELECTRIC_CURRENT = "type-electric-current"; |
| 63 | + public static final String CHANNEL_TYPE_ELECTRIC_CURRENT_UNIT = "A"; |
| 64 | + public static final String CHANNEL_TYPE_TIME = "type-time"; |
| 65 | + public static final String CHANNEL_TYPE_TIME_UNIT = "h"; |
| 66 | + public static final String CHANNEL_TYPE_INTEGER = "type-number-integer"; |
| 67 | + public static final String CHANNEL_TYPE_DOUBLE = "type-number-double"; |
| 68 | + public static final String CHANNEL_TYPE_ON_OFF = "type-on-off"; |
| 69 | + public static final String CHANNEL_TYPE_RW_SWITCH = "rwtype-switch"; |
| 70 | + public static final String CHANNEL_TYPE_RW_COMMAND = "rwtype-command"; |
| 71 | + public static final String CHANNEL_TYPE_RW_MODE = "rwtype-mode"; |
| 72 | + |
| 73 | + public static final String CHANNEL_ID_COMMAND = "command"; |
| 74 | + public static final String CHANNEL_ID_SMART_HOME_MODE = "smart-home-mode"; |
| 75 | + |
| 76 | + // JSON Keys |
| 77 | + public static final String JSON_KEY_ROOT_DATA = "data"; |
| 78 | + public static final String JSON_KEY_CHANNEL_STR_VAL = "strVal"; |
| 79 | + public static final String JSON_KEY_CHANNEL_VALUE = "value"; |
| 80 | + public static final String JSON_KEY_CHANNEL_WRITABLE = "writable"; |
| 81 | + public static final String JSON_KEY_CHANNEL_ENUM_VALUES = "enumValues"; |
| 82 | + public static final String JSON_KEY_CHANNEL_ID = "parameterId"; |
| 83 | + public static final String JSON_KEY_CHANNEL_LABEL = "parameterName"; |
| 84 | + public static final String JSON_KEY_CHANNEL_UNIT = "parameterUnit"; |
| 85 | + public static final String JSON_KEY_CHANNEL_SCALE = "scaleValue"; |
| 86 | + public static final String JSON_KEY_CHANNEL_MIN = "minValue"; |
| 87 | + public static final String JSON_KEY_CHANNEL_MAX = "maxValue"; |
| 88 | + public static final String JSON_KEY_CHANNEL_STEP = "stepValue"; |
| 89 | + public static final String JSON_KEY_SYSTEMS = "systems"; |
| 90 | + public static final String JSON_KEY_SYSTEM_ID = "systemId"; |
| 91 | + public static final String JSON_KEY_DEVICES = "devices"; |
| 92 | + public static final String JSON_KEY_GENERIC_ID = "id"; |
| 93 | + public static final String JSON_KEY_PRODUCT = "product"; |
| 94 | + public static final String JSON_KEY_SERIAL = "serialNumber"; |
| 95 | + public static final String JSON_KEY_NAME = "name"; |
| 96 | + public static final String JSON_KEY_CURRENT_FW_VERSION = "currentFwVersion"; |
| 97 | + public static final String JSON_KEY_CONNECTION_STATE = "connectionState"; |
| 98 | + public static final String JSON_KEY_ERROR = "error"; |
| 99 | + public static final String JSON_KEY_SMART_HOME_MODE = "smartHomeMode"; |
| 100 | + |
| 101 | + public static final String JSON_KEY_AUTH_ACCESS_TOKEN = "access_token"; |
| 102 | + public static final String JSON_KEY_AUTH_EXPIRES_IN = "expires_in"; |
| 103 | + |
| 104 | + public static final String JSON_ENUM_KEY_TEXT = "text"; |
| 105 | + public static final String JSON_ENUM_ORD_0 = "0"; |
| 106 | + public static final String JSON_ENUM_ORD_1 = "1"; |
| 107 | + public static final String JSON_ENUM_ORD_4 = "4"; |
| 108 | + public static final String JSON_ENUM_ORD_6 = "6"; |
| 109 | + public static final String JSON_ENUM_ORD_10 = "10"; |
| 110 | + public static final String JSON_ENUM_ORD_20 = "20"; |
| 111 | + public static final String JSON_ENUM_ORD_30 = "30"; |
| 112 | + public static final String JSON_ENUM_ORD_40 = "40"; |
| 113 | + public static final String JSON_ENUM_ORD_60 = "60"; |
| 114 | + public static final String JSON_ENUM_ORD_100 = "100"; |
| 115 | + public static final String JSON_ENUM_VAL_OFF = "off"; |
| 116 | + public static final String JSON_ENUM_VAL_ON = "on"; |
| 117 | + public static final String JSON_ENUM_VAL_HOT_WATER = "hot water"; |
| 118 | + public static final String JSON_ENUM_VAL_HEATING = "heating"; |
| 119 | + public static final String JSON_ENUM_VAL_POOL = "pool"; |
| 120 | + public static final String JSON_ENUM_VAL_STARTS = "starts"; |
| 121 | + public static final String JSON_ENUM_VAL_RUNS = "runs"; |
| 122 | + public static final String JSON_ENUM_VAL_ALARM = "alarm"; |
| 123 | + public static final String JSON_ENUM_VAL_BLOCKED = "blocked"; |
| 124 | + public static final String JSON_ENUM_VAL_ACTIVE = "active"; |
| 125 | + |
| 126 | + public static final String JSON_VAL_CONNECTION_CONNECTED = "Connected"; |
| 127 | + public static final String JSON_VAL_DECIMAL_SEPARATOR = "."; |
| 128 | + |
| 129 | + // web request constants |
| 130 | + public static final long WEB_REQUEST_INITIAL_DELAY = 10; |
| 131 | + public static final long WEB_REQUEST_INTERVAL = 5; |
| 132 | + public static final int WEB_REQUEST_QUEUE_MAX_SIZE = 20; |
| 133 | + public static final int WEB_REQUEST_TOKEN_EXPIRY_BUFFER_MINUTES = 5; |
| 134 | + public static final int WEB_REQUEST_TOKEN_MAX_AGE_MINUTES = 45; |
| 135 | + public static final String WEB_REQUEST_PARAM_PAGE_KEY = "page"; |
| 136 | + public static final String WEB_REQUEST_PARAM_PAGE_SIZE_KEY = "itemsPerPage"; |
| 137 | + public static final String WEB_REQUEST_PATCH_CONTENT_TYPE = "application/json-patch+json"; |
| 138 | + public static final int WEB_REQUEST_PARAM_PAGE_SIZE_VALUE = 100; |
| 139 | + public static final String WEB_REQUEST_BEARER_TOKEN_PREFIX = "Bearer "; |
| 140 | + public static final String LOGIN_BASIC_AUTH_PREFIX = "Basic "; |
| 141 | + public static final String LOGIN_FIELD_SCOPE_KEY = "scope"; |
| 142 | + public static final String LOGIN_FIELD_SCOPE_VALUE = "READSYSTEM WRITESYSTEM"; |
| 143 | + public static final String LOGIN_FIELD_GRANT_TYPE_KEY = "grant_type"; |
| 144 | + public static final String LOGIN_FIELD_GRANT_TYPE_VALUE = "client_credentials"; |
| 145 | + |
| 146 | + // URLs |
| 147 | + private static final String API_BASE_URL = "https://api.myuplink.com"; |
| 148 | + public static final String LOGIN_URL = API_BASE_URL + "/oauth/token"; |
| 149 | + public static final String GET_SYSTEMS_URL = API_BASE_URL + "/v2/systems/me"; |
| 150 | + public static final String GET_SMART_HOME_MODE_URL = API_BASE_URL + "/v2/systems/{systemId}/smart-home-mode"; |
| 151 | + public static final String SET_SMART_HOME_MODE_URL = GET_SMART_HOME_MODE_URL; |
| 152 | + public static final String GET_DEVICE_POINTS = API_BASE_URL + "/v2/devices/{deviceId}/points"; |
| 153 | + public static final String SET_DEVICE_POINTS = GET_DEVICE_POINTS; |
| 154 | + |
| 155 | + // Status Keys |
| 156 | + public static final String STATUS_TOKEN_VALIDATED = "@text/status.token.validated"; |
| 157 | + public static final String STATUS_WAITING_FOR_BRIDGE = "@text/status.waiting.for.bridge"; |
| 158 | + public static final String STATUS_WAITING_FOR_LOGIN = "@text/status.waiting.for.login"; |
| 159 | + public static final String STATUS_NO_VALID_DATA = "@text/status.no.valid.data"; |
| 160 | + public static final String STATUS_NO_CONNECTION = "@text/status.no.connection"; |
| 161 | + public static final String STATUS_DEVICE_NOT_FOUND = "@text/status.device.not.found"; |
| 162 | + public static final String STATUS_CONFIG_ERROR_NO_CLIENT_ID = "@text/status.config.error.no.client.id"; |
| 163 | + public static final String STATUS_CONFIG_ERROR_NO_CLIENT_SECRET = "@text/status.config.error.no.client.secret"; |
| 164 | + |
| 165 | + // other |
| 166 | + public static final long POLLING_INITIAL_DELAY = 5; |
| 167 | + |
| 168 | + public static final String GENERIC_NO_VAL = "---"; |
| 169 | + public static final String EMPTY = ""; |
| 170 | + |
| 171 | + public static final String THING_CONFIG_ID = "deviceId"; |
| 172 | + public static final String THING_CONFIG_SYSTEM_ID = "systemId"; |
| 173 | + public static final String THING_CONFIG_SERIAL = "serial"; |
| 174 | + public static final String THING_CONFIG_CURRENT_FW_VERSION = "currentFwVersion"; |
| 175 | + |
| 176 | + public static final Instant OUTDATED_DATE = Instant.EPOCH; |
| 177 | + |
| 178 | + public static final String PARAMETER_NAME_WRITE_COMMAND = "writeCommand"; |
| 179 | + public static final String PARAMETER_NAME_VALIDATION_REGEXP = "validationExpression"; |
| 180 | + public static final String DEFAULT_VALIDATION_EXPRESSION = "[0-9]+"; |
| 181 | +} |
0 commit comments