/**
* Special {@link Action} needed to control shutters.
*
- * @author Marco Mans
+ * @author Marco Mans - Initial contribution
*/
public class ShutterAction extends Action {
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.apache.commons.lang3.exception.ExceptionUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
import org.openhab.binding.innogysmarthome.internal.listener.EventListener;
import org.openhab.binding.innogysmarthome.internal.manager.DeviceStructureManager;
import org.openhab.binding.innogysmarthome.internal.manager.FullDeviceManager;
+import org.openhab.binding.innogysmarthome.internal.util.ExceptionUtils;
import org.openhab.core.auth.client.oauth2.AccessTokenRefreshListener;
import org.openhab.core.auth.client.oauth2.AccessTokenResponse;
import org.openhab.core.auth.client.oauth2.OAuthClientService;
isReinitialize = false;
Thread.currentThread().interrupt();
} else if (e instanceof ExecutionException) {
- logger.debug("ExecutionException: {}", ExceptionUtils.getRootCauseMessage(e));
+ logger.debug("ExecutionException: {}", ExceptionUtils.getRootThrowable(e).getMessage());
updateStatus(ThingStatus.OFFLINE);
} else {
logger.debug("Unknown exception", e);
* states. Calling this may take a while...
*/
public List<Device> getFullDevices() throws IOException, ApiException, AuthenticationException {
-
final Map<String, Location> locationMap = createLocationMap(client);
final Map<String, Capability> capabilityMap = createCapabilityMap(client);
final Map<String, DeviceState> deviceStateMap = createDeviceStateMap(client);
private void initializeDevice(Device device, @Nullable DeviceState deviceState, Map<String, Location> locationMap,
Map<String, Capability> capabilityMap, List<Message> messageList) {
-
device.setDeviceState(deviceState);
if (isBatteryPowered(device)) {
private static Map<String, Capability> createCapabilityMap(InnogyClient client)
throws IOException, ApiException, AuthenticationException {
-
final Map<String, CapabilityState> capabilityStateMap = createCapabilityStateMap(client);
final List<Capability> capabilityList = client.getCapabilities();
private static Map<String, Capability> createCapabilityMap(String deviceId, InnogyClient client)
throws IOException, ApiException, AuthenticationException {
-
final Map<String, CapabilityState> capabilityStateMap = createCapabilityStateMap(client);
final List<Capability> capabilityList = client.getCapabilitiesForDevice(deviceId);
private static Map<String, Capability> createDeviceCapabilityMap(Device device,
Map<String, Capability> capabilityMap) {
-
final HashMap<String, Capability> deviceCapabilityMap = new HashMap<>();
for (final String capabilityValue : device.getCapabilities()) {
final Capability capability = capabilityMap.get(Link.getId(capabilityValue));
--- /dev/null
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.innogysmarthome.internal.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
+/**
+ * The {@link ExceptionUtils} class defines static Exception related methods
+ *
+ * @author Leo Siepel - Initial contribution
+ */
+@NonNullByDefault
+public class ExceptionUtils {
+
+ public static Throwable getRootThrowable(Throwable throwable) {
+ List<Throwable> list = new ArrayList<>();
+ while (!list.contains(throwable)) {
+ list.add(throwable);
+ Throwable throwableLocal = throwable.getCause();
+ if (throwableLocal != null) {
+ throwable = throwableLocal;
+ }
+ }
+ return throwable;
+ }
+}
import org.openhab.core.config.core.Configuration;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ThingUID;
+import org.openhab.core.thing.binding.BaseThingHandler;
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
/**
* @author Sven Strohschein - Initial contribution
@BeforeEach
public void before() throws Exception {
+ final Logger loggerBridge = (Logger) LoggerFactory.getLogger(InnogyBridgeHandler.class);
+ loggerBridge.setLevel(Level.OFF);
+
+ final Logger logerBaseHandler = (Logger) LoggerFactory.getLogger(BaseThingHandler.class);
+ logerBaseHandler.setLevel(Level.OFF);
+
bridgeMock = mock(Bridge.class);
when(bridgeMock.getUID()).thenReturn(new ThingUID("innogysmarthome", "bridge"));