diff --git a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/InnogyBindingConstants.java b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/InnogyBindingConstants.java index 716c2e11b004f..cbd2aababbb4d 100644 --- a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/InnogyBindingConstants.java +++ b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/InnogyBindingConstants.java @@ -39,13 +39,7 @@ public class InnogyBindingConstants { public static final String CLIENT_SECRET_INNOGY_SMARTHOME = "no secret"; public static final String REDIRECT_URL_INNOGY_SMARTHOME = "https://www.openhab.org/oauth/innogy/innogy-smarthome.html"; - // Bridge config parameters - public static final String CONFIG_BRAND = "brand"; - public static final String CONFIG_AUTH_CODE = "authcode"; - public static final String CONFIG_ACCESS_TOKEN = "accesstoken"; - public static final String CONFIG_REFRESH_TOKEN = "refreshtoken"; - public static final String CONFIG_WEBSOCKET_IDLE_TIMEOUT = "websocketidletimeout"; public static final long REINITIALIZE_DELAY_SECONDS = 30; public static final long REINITIALIZE_RETRY_SECONDS = 60; @@ -75,7 +69,6 @@ public class InnogyBindingConstants { public static final String PROPERTY_BACKEND_CONNECTION_MONITORED = "Backend connection monitored"; public static final String PROPERTY_RFCOM_FAILURE_NOTIFICATION = "RFComm failure notification"; public static final String PROPERTY_DISPLAY_CURRENT_TEMPERATURE = "Display current temperature"; - public static final String PROPERTY_UNDERLYING_DEVICE_IDS = "Underlying device IDs (thermostats)"; public static final String PROPERTY_METER_ID = "Meter ID"; public static final String PROPERTY_METER_FIRMWARE_VERSION = "Meter firmware version"; @@ -113,6 +106,10 @@ public class InnogyBindingConstants { DEVICE_GENERATION_METER, DEVICE_SMART_METER, DEVICE_TWO_WAY_METER) .collect(Collectors.toSet())); + public static final Set BATTERY_POWERED_DEVICES = Collections + .unmodifiableSet(Stream.of(DEVICE_RST, DEVICE_RST2, DEVICE_WRT, DEVICE_WDS, DEVICE_WSD, DEVICE_WSD2, + DEVICE_WMD, DEVICE_WMDO, DEVICE_WSC2, DEVICE_BRC8).collect(Collectors.toSet())); + // List of all Thing Type UIDs public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "bridge"); public static final ThingTypeUID THING_TYPE_PSS = new ThingTypeUID(BINDING_ID, DEVICE_PSS); diff --git a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/Constants.java b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/Constants.java index 446121dd83dca..cc330d1164da9 100644 --- a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/Constants.java +++ b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/Constants.java @@ -12,11 +12,6 @@ */ package org.openhab.binding.innogysmarthome.internal.client; -import java.util.Collections; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - import org.eclipse.jdt.annotation.NonNullByDefault; /** @@ -28,10 +23,6 @@ @NonNullByDefault public final class Constants { - // devices - public static final Set BATTERY_POWERED_DEVICES = Collections.unmodifiableSet( - Stream.of("RST", "WRT", "WDS", "WSD", "WSD2", "WMD", "WMDO", "WSC2", "BRC8").collect(Collectors.toSet())); - // API URLs public static final String API_HOST = "api.services-smarthome.de"; public static final String AUTH_HOST = "auth.services-smarthome.de"; @@ -39,8 +30,6 @@ public final class Constants { public static final String API_URL_BASE = "https://" + API_HOST + "/API/" + API_VERSION; public static final String API_URL_TOKEN = "https://" + AUTH_HOST + "/AUTH/token"; - public static final String API_URL_CHECK_CONNECTION = API_URL_BASE + "/desc/device/SHC.RWE/1.0/event/StateChanged"; - public static final String API_URL_INITIALIZE = API_URL_BASE + "/initialize"; public static final String API_URL_STATUS = API_URL_BASE + "/status"; public static final String API_URL_DEVICE = API_URL_BASE + "/device"; @@ -56,12 +45,8 @@ public final class Constants { public static final String API_URL_MESSAGE = API_URL_BASE + "/message"; - public static final String API_URL_EVENTS = "wss://" + API_HOST + "/API/" + API_VERSION + "/events?token={token}"; public static final String API_URL_ACTION = API_URL_BASE + "/action"; - // others - public static final String FORMAT_DATETIME = "dd.MM.yyyy HH:mm:ss"; - private Constants() { // Constants class } diff --git a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/InnogyClient.java b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/InnogyClient.java index 2707832d8e7e7..dc7d7e8a938b7 100644 --- a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/InnogyClient.java +++ b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/InnogyClient.java @@ -12,6 +12,7 @@ */ package org.openhab.binding.innogysmarthome.internal.client; +import static org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants.*; import static org.openhab.binding.innogysmarthome.internal.client.Constants.*; import java.io.IOException; @@ -39,6 +40,7 @@ import org.eclipse.smarthome.core.auth.client.oauth2.OAuthClientService; import org.eclipse.smarthome.core.auth.client.oauth2.OAuthException; import org.eclipse.smarthome.core.auth.client.oauth2.OAuthResponseException; +import org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants; import org.openhab.binding.innogysmarthome.internal.client.entity.StatusResponse; import org.openhab.binding.innogysmarthome.internal.client.entity.action.Action; import org.openhab.binding.innogysmarthome.internal.client.entity.action.ShutterAction; @@ -462,7 +464,7 @@ public List getFullDevices() throws IOException, ApiException, Authentic // DEVICES final List deviceList = getDevices(); for (final Device d : deviceList) { - if (BATTERY_POWERED_DEVICES.contains(d.getType())) { + if (InnogyBindingConstants.BATTERY_POWERED_DEVICES.contains(d.getType())) { d.setIsBatteryPowered(true); } diff --git a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/device/Device.java b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/device/Device.java index 919ed1ead80f3..622fe318fad27 100644 --- a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/device/Device.java +++ b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/device/Device.java @@ -12,6 +12,8 @@ */ package org.openhab.binding.innogysmarthome.internal.client.entity.device; +import static org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants.*; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -29,30 +31,6 @@ */ public class Device { - public static final String DEVICE_TYPE_SHC = "SHC"; - public static final String DEVICE_TYPE_SHCA = "SHCA"; - public static final String DEVICE_TYPE_ANALOG_METER = "AnalogMeter"; - public static final String DEVICE_TYPE_BRC8 = "BRC8"; - public static final String DEVICE_TYPE_GENERATION_METER = "GenerationMeter"; - public static final String DEVICE_TYPE_ISC2 = "ISC2"; - public static final String DEVICE_TYPE_ISD2 = "ISD2"; - public static final String DEVICE_TYPE_ISR2 = "ISR2"; - public static final String DEVICE_TYPE_ISS2 = "ISS2"; - public static final String DEVICE_TYPE_PSD = "PSD"; - public static final String DEVICE_TYPE_PSS = "PSS"; - public static final String DEVICE_TYPE_PSSO = "PSSO"; - public static final String DEVICE_TYPE_RST = "RST"; - public static final String DEVICE_TYPE_SMARTMETER = "SmartMeter"; - public static final String DEVICE_TYPE_TWO_WAY_METER = "TwoWayMeter"; - public static final String DEVICE_TYPE_VARIABLE_ACTUATOR = "VariableActuator"; - public static final String DEVICE_TYPE_WDS = "WDS"; - public static final String DEVICE_TYPE_WMD = "WMD"; - public static final String DEVICE_TYPE_WMDO = "WMDO"; - public static final String DEVICE_TYPE_WRT = "WRT"; - public static final String DEVICE_TYPE_WSC2 = "WSC2"; - public static final String DEVICE_TYPE_WSD = "WSD"; - public static final String DEVICE_TYPE_WSD2 = "WSD2"; - public static final String DEVICE_MANUFACTURER_RWE = "RWE"; public static final String DEVICE_MANUFACTURER_INNOGY = "innogy"; @@ -474,7 +452,7 @@ public boolean hasMessages() { * @return */ public boolean isController() { - return DEVICE_TYPE_SHC.equals(type) || DEVICE_TYPE_SHCA.equals(type); + return DEVICE_SHC.equals(type) || DEVICE_SHCA.equals(type); } /** diff --git a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/message/Message.java b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/message/Message.java index b57dd639b9097..3b89615e1531b 100644 --- a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/message/Message.java +++ b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/entity/message/Message.java @@ -12,10 +12,10 @@ */ package org.openhab.binding.innogysmarthome.internal.client.entity.message; -import com.google.gson.annotations.SerializedName; - import java.util.List; +import com.google.gson.annotations.SerializedName; + /** * Defines the structure of a {@link Message}. Messages are part of the innogy system and besides other things are used * to raise battery warnings. diff --git a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyBridgeHandler.java b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyBridgeHandler.java index 76b6c498f6f31..5a3989a7107b9 100644 --- a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyBridgeHandler.java +++ b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyBridgeHandler.java @@ -479,7 +479,7 @@ public void onDeviceStateChanged(final Device device, final Event event) { logger.trace("DeviceId {} relevant for this handler.", device.getId()); - if (event.isLinkedtoDevice() && Device.DEVICE_TYPE_SHCA.equals(device.getType())) { + if (event.isLinkedtoDevice() && DEVICE_SHCA.equals(device.getType())) { device.getDeviceState().getState().getCpuUsage().setValue(event.getProperties().getCpuUsage()); device.getDeviceState().getState().getDiskUsage().setValue(event.getProperties().getDiskUsage()); device.getDeviceState().getState().getMemoryUsage().setValue(event.getProperties().getMemoryUsage()); diff --git a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyDeviceHandler.java b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyDeviceHandler.java index 91d4a76e8f15f..98631a9c0ef38 100644 --- a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyDeviceHandler.java +++ b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyDeviceHandler.java @@ -271,17 +271,16 @@ private boolean initializeProperties() { } // Thermostat - if (Device.DEVICE_TYPE_RST.equals(device.getType()) - || Device.DEVICE_TYPE_WRT.equals(device.getType())) { + if (DEVICE_RST.equals(device.getType()) || DEVICE_RST2.equals(device.getType()) + || DEVICE_WRT.equals(device.getType())) { properties.put(PROPERTY_DISPLAY_CURRENT_TEMPERATURE, device.getConfig().getDisplayCurrentTemperature()); } // Meter - if (Device.DEVICE_TYPE_ANALOG_METER.equals(device.getType()) - || Device.DEVICE_TYPE_GENERATION_METER.equals(device.getType()) - || Device.DEVICE_TYPE_SMARTMETER.equals(device.getType()) - || Device.DEVICE_TYPE_TWO_WAY_METER.equals(device.getType())) { + if (DEVICE_ANALOG_METER.equals(device.getType()) || DEVICE_GENERATION_METER.equals(device.getType()) + || DEVICE_SMART_METER.equals(device.getType()) + || DEVICE_TWO_WAY_METER.equals(device.getType())) { properties.put(PROPERTY_METER_ID, device.getConfig().getMeterId()); properties.put(PROPERTY_METER_FIRMWARE_VERSION, device.getConfig().getMeterFirmwareVersion()); } @@ -364,8 +363,7 @@ public void onDeviceStateChanged(final Device device) { if (reachable != null && !reachable) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Device not reachable."); return; - } else if ((reachable != null && reachable) - || Device.DEVICE_TYPE_VARIABLE_ACTUATOR.equals(device.getType())) { + } else if ((reachable != null && reachable) || DEVICE_VARIABLE_ACTUATOR.equals(device.getType())) { if (device.getDeviceState().deviceIsIncluded()) { updateStatus(ThingStatus.ONLINE); } else {