|
| 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.argoclima.internal; |
| 14 | + |
| 15 | +import java.time.Duration; |
| 16 | + |
| 17 | +import org.eclipse.jdt.annotation.NonNullByDefault; |
| 18 | +import org.openhab.core.thing.ThingTypeUID; |
| 19 | + |
| 20 | +/** |
| 21 | + * The {@link ArgoClimaBindingConstants} class defines common constants, which are |
| 22 | + * used across the whole binding. |
| 23 | + * |
| 24 | + * @author Mateusz Bronk - Initial contribution |
| 25 | + */ |
| 26 | +@NonNullByDefault |
| 27 | +public class ArgoClimaBindingConstants { |
| 28 | + |
| 29 | + public static final String BINDING_ID = "argoclima"; |
| 30 | + |
| 31 | + ///////////// |
| 32 | + // List of all Thing Type UIDs |
| 33 | + ///////////// |
| 34 | + public static final ThingTypeUID THING_TYPE_ARGOCLIMA_LOCAL = new ThingTypeUID(BINDING_ID, "local"); |
| 35 | + public static final ThingTypeUID THING_TYPE_ARGOCLIMA_REMOTE = new ThingTypeUID(BINDING_ID, "remote"); |
| 36 | + |
| 37 | + ///////////// |
| 38 | + // Thing configuration parameters |
| 39 | + ///////////// |
| 40 | + public static final String PARAMETER_HOSTNAME = "hostname"; |
| 41 | + public static final String PARAMETER_LOCAL_DEVICE_IP = "localDeviceIP"; |
| 42 | + public static final String PARAMETER_HVAC_LISTEN_PORT = "hvacListenPort"; |
| 43 | + public static final String PARAMETER_DEVICE_CPU_ID = "deviceCpuId"; |
| 44 | + public static final String PARAMETER_CONNECTION_MODE = "connectionMode"; // LOCAL_CONNECTION | REMOTE_API_STUB | |
| 45 | + // REMOTE_API_PROXY |
| 46 | + public static final String PARAMETER_USE_LOCAL_CONNECTION = "useLocalConnection"; |
| 47 | + public static final String PARAMETER_REFRESH_INTERNAL = "refreshInterval"; |
| 48 | + public static final String PARAMETER_STUB_SERVER_PORT = "stubServerPort"; |
| 49 | + public static final String PARAMETER_STUB_SERVER_LISTEN_ADDRESSES = "stubServerListenAddresses"; |
| 50 | + public static final String PARAMETER_OEM_SERVER_PORT = "oemServerPort"; |
| 51 | + public static final String PARAMETER_OEM_SERVER_ADDRESS = "oemServerAddress"; |
| 52 | + public static final String PARAMETER_INCLUDE_DEVICE_SIDE_PASSWORDS_IN_PROPERTIES = "includeDeviceSidePasswordsInProperties"; |
| 53 | + public static final String PARAMETER_MATCH_ANY_INCOMING_DEVICE_IP = "matchAnyIncomingDeviceIp"; |
| 54 | + |
| 55 | + public static final String PARAMETER_USERNAME = "username"; |
| 56 | + public static final String PARAMETER_PASSWORD = "password"; |
| 57 | + |
| 58 | + public static final String PARAMETER_SCHEDULE_GROUP_NAME = "schedule%d"; // 1..3 |
| 59 | + public static final String PARAMETER_SCHEDULE_X_DAYS = PARAMETER_SCHEDULE_GROUP_NAME + "DayOfWeek"; |
| 60 | + public static final String PARAMETER_SCHEDULE_X_ON_TIME = PARAMETER_SCHEDULE_GROUP_NAME + "OnTime"; |
| 61 | + public static final String PARAMETER_SCHEDULE_X_OFF_TIME = PARAMETER_SCHEDULE_GROUP_NAME + "OffTime"; |
| 62 | + public static final String PARAMETER_ACTIONS_GROUP_NAME = "actions"; |
| 63 | + public static final String PARAMETER_RESET_TO_FACTORY_DEFAULTS = "resetToFactoryDefaults"; |
| 64 | + |
| 65 | + ///////////// |
| 66 | + // Thing configuration properties |
| 67 | + ///////////// |
| 68 | + public static final String PROPERTY_CPU_ID = "cpuId"; |
| 69 | + public static final String PROPERTY_LOCAL_IP_ADDRESS = "localIpAddress"; |
| 70 | + public static final String PROPERTY_UNIT_FW = "unitFirmwareVersion"; |
| 71 | + public static final String PROPERTY_WIFI_FW = "wifiFirmwareVersion"; |
| 72 | + public static final String PROPERTY_LAST_SEEN = "lastSeen"; |
| 73 | + public static final String PROPERTY_WEB_UI = "argoWebUI"; |
| 74 | + public static final String PROPERTY_WEB_UI_USERNAME = "argoWebUIUsername"; |
| 75 | + public static final String PROPERTY_WEB_UI_PASSWORD = "argoWebUIPassword"; |
| 76 | + public static final String PROPERTY_WIFI_SSID = "wifiSSID"; |
| 77 | + public static final String PROPERTY_WIFI_PASSWORD = "wifiPassword"; |
| 78 | + public static final String PROPERTY_LOCAL_TIME = "localTime"; |
| 79 | + |
| 80 | + ///////////// |
| 81 | + // List of all Channel IDs |
| 82 | + ///////////// |
| 83 | + public static final String CHANNEL_POWER = "ac-controls#power"; |
| 84 | + public static final String CHANNEL_MODE = "ac-controls#mode"; |
| 85 | + public static final String CHANNEL_SET_TEMPERATURE = "ac-controls#set-temperature"; |
| 86 | + public static final String CHANNEL_CURRENT_TEMPERATURE = "ac-controls#current-temperature"; |
| 87 | + public static final String CHANNEL_FAN_SPEED = "ac-controls#fan-speed"; |
| 88 | + public static final String CHANNEL_ECO_MODE = "modes#eco-mode"; |
| 89 | + public static final String CHANNEL_TURBO_MODE = "modes#turbo-mode"; |
| 90 | + public static final String CHANNEL_NIGHT_MODE = "modes#night-mode"; |
| 91 | + public static final String CHANNEL_ACTIVE_TIMER = "timers#active-timer"; |
| 92 | + public static final String CHANNEL_DELAY_TIMER = "timers#delay-timer"; |
| 93 | + // Note: schedule timers day of week/time setting not currently supported as channels (YAGNI), and moved to config |
| 94 | + public static final String CHANNEL_MODE_EX = "unsupported#mode-ex"; |
| 95 | + public static final String CHANNEL_SWING_MODE = "unsupported#swing-mode"; |
| 96 | + public static final String CHANNEL_FILTER_MODE = "unsupported#filter-mode"; |
| 97 | + |
| 98 | + public static final String CHANNEL_I_FEEL_ENABLED = "settings#ifeel-enabled"; |
| 99 | + public static final String CHANNEL_DEVICE_LIGHTS = "settings#device-lights"; |
| 100 | + |
| 101 | + public static final String CHANNEL_TEMPERATURE_DISPLAY_UNIT = "settings#temperature-display-unit"; |
| 102 | + public static final String CHANNEL_ECO_POWER_LIMIT = "settings#eco-power-limit"; |
| 103 | + |
| 104 | + ///////////// |
| 105 | + // Binding's hard-coded configuration (not parameterized) |
| 106 | + ///////////// |
| 107 | + /** Maximum number of failed status polls after which the device will be considered offline */ |
| 108 | + public static final int MAX_API_RETRIES = 3; |
| 109 | + |
| 110 | + /** |
| 111 | + * Time to wait between command issue and communicating with the device. Allows to include multiple commands in one |
| 112 | + * device communication session (preferred). |
| 113 | + * Time window chosen so that it is not (too) perceptible by an user, while still enough for rules/groups to be able |
| 114 | + * to fit |
| 115 | + */ |
| 116 | + public static final Duration SEND_COMMAND_DEBOUNCE_TIME = Duration.ofMillis(100); |
| 117 | + |
| 118 | + /** |
| 119 | + * The minimum resolution during which the command sending background thread does any meaningful action. This is |
| 120 | + * merely to avoid busy wait and doesn't mean the thread is doing anything of use on every cycle. There are separate |
| 121 | + * configurable "update" and "(re)send" frequencies governing that. This parameter only controls the lowest possible |
| 122 | + * resolution of those (a "tick") |
| 123 | + */ |
| 124 | + public static final Duration SEND_COMMAND_DUTY_CYCLE = Duration.ofSeconds(1); |
| 125 | + |
| 126 | + /** |
| 127 | + * The frequency to poll the device with, waiting for the command confirmation |
| 128 | + */ |
| 129 | + public static final Duration POLL_FREQUENCY_AFTER_COMMAND_SENT_LOCAL = Duration.ofSeconds(3); |
| 130 | + |
| 131 | + /** |
| 132 | + * The frequency to poll the Argo servers with, waiting for the command confirmation |
| 133 | + */ |
| 134 | + public static final Duration POLL_FREQUENCY_AFTER_COMMAND_SENT_REMOTE = Duration.ofSeconds(5); |
| 135 | + |
| 136 | + /** |
| 137 | + * The frequency to re-send the pending command to the device at (if it hadn't been confirmed yet). |
| 138 | + * Aka. the optimistic time when the device "should acknowledge. Should be greater than |
| 139 | + * {@link #POLL_FREQUENCY_AFTER_COMMAND_SENT_LOCAL} |
| 140 | + * |
| 141 | + * @see #SEND_COMMAND_MAX_WAIT_TIME_LOCAL_DIRECT |
| 142 | + * @see #SEND_COMMAND_MAX_WAIT_TIME_LOCAL_INDIRECT |
| 143 | + */ |
| 144 | + public static final Duration SEND_COMMAND_RETRY_FREQUENCY_LOCAL = Duration.ofSeconds(10); |
| 145 | + |
| 146 | + /** |
| 147 | + * The frequency to re-send the pending command to the remote Argo server at (if it hadn't been confirmed yet). |
| 148 | + * Aka. the optimistic time when the server "should acknowledge. Should be greater than |
| 149 | + * {@link #POLL_FREQUENCY_AFTER_COMMAND_SENT_REMOTE} |
| 150 | + * |
| 151 | + * @see #SEND_COMMAND_MAX_WAIT_TIME_REMOTE |
| 152 | + */ |
| 153 | + public static final Duration SEND_COMMAND_RETRY_FREQUENCY_REMOTE = Duration.ofSeconds(20); |
| 154 | + |
| 155 | + /** |
| 156 | + * Max time to wait for a pending command to be confirmed by the device in a local-direct mode (when we are issuing |
| 157 | + * communications to a device in local LAN). |
| 158 | + * <p> |
| 159 | + * During this time, the commands may get {@link #SEND_COMMAND_RETRY_FREQUENCY_LOCAL retried} and the device status |
| 160 | + * may be |
| 161 | + * {@link #POLL_FREQUENCY_AFTER_COMMAND_SENT_LOCAL re-fetched} |
| 162 | + */ |
| 163 | + public static final Duration SEND_COMMAND_MAX_WAIT_TIME_LOCAL_DIRECT = Duration.ofSeconds(20); // 60-remote |
| 164 | + |
| 165 | + /** |
| 166 | + * Max time to wait for a pending command to be confirmed in an *indirect* mode (where we're only |
| 167 | + * sniffing/intercepting communications) |
| 168 | + * <p> |
| 169 | + * A healthy device seems to be polling Argo servers every minute (and if the server returns a pending command |
| 170 | + * request, does a few more more frequent exchanges as well), so 2 minutes seem safe |
| 171 | + */ |
| 172 | + public static final Duration SEND_COMMAND_MAX_WAIT_TIME_LOCAL_INDIRECT = Duration.ofSeconds(120); |
| 173 | + |
| 174 | + /** |
| 175 | + * Max time to wait for a pending command to be confirmed in an *remote* mode (where we're talking to a remote Argo |
| 176 | + * server) |
| 177 | + * <p> |
| 178 | + * The server seems to confirm a bit faster than our intercepting proxy and we want to minimize traffic our binding |
| 179 | + * issues against remote side, hence a more conservative value |
| 180 | + */ |
| 181 | + public static final Duration SEND_COMMAND_MAX_WAIT_TIME_REMOTE = Duration.ofSeconds(60); |
| 182 | + |
| 183 | + /** |
| 184 | + * Time to wait for (confirmable) command to be reported back by the device (by changing its state to the requested |
| 185 | + * value). If this period elapses w/o the device confirming, the command is considered not handled and REJECTED |
| 186 | + * (would not be retried any more, and the reported device's state will be the actual one device sent, not the |
| 187 | + * "in-flight" desired one) |
| 188 | + * |
| 189 | + * @implNote This is just a final "give up" time (not affecting any send logic). Should be no shorter than max try |
| 190 | + * time |
| 191 | + */ |
| 192 | + public static final Duration PENDING_COMMAND_EXPIRE_TIME = SEND_COMMAND_MAX_WAIT_TIME_LOCAL_INDIRECT |
| 193 | + .plus(Duration.ofSeconds(1)); |
| 194 | + |
| 195 | + /** |
| 196 | + * Timeout for getting the HTTP response from Argo servers in pass-through(proxy) mode |
| 197 | + */ |
| 198 | + public static final Duration UPSTREAM_PROXY_HTTP_REQUEST_TIMEOUT = Duration.ofSeconds(30); |
| 199 | + |
| 200 | + ///////////// |
| 201 | + // R&D-only switches |
| 202 | + ///////////// |
| 203 | + /** |
| 204 | + * Whether the binding shall wait for the device confirming commands have been received (by flipping to the desired |
| 205 | + * state) or work in a fire and forget mode and stop tracking upon first send. |
| 206 | + * <p> |
| 207 | + * This applies only to confirmable commands (read-write) and is a default behavior of Argo's own web implementation |
| 208 | + * |
| 209 | + * @implNote This is a debug-only switch (makes little to no sense to disable it in real-world usage) |
| 210 | + */ |
| 211 | + public static final boolean AWAIT_DEVICE_CONFIRMATIONS_AFTER_COMMANDS = true; |
| 212 | +} |
0 commit comments