diff --git a/src/main/java/com/bigboxer23/switch_bot/SwitchBotApi.java b/src/main/java/com/bigboxer23/switch_bot/SwitchBotApi.java index e6c8235..0d8769c 100644 --- a/src/main/java/com/bigboxer23/switch_bot/SwitchBotApi.java +++ b/src/main/java/com/bigboxer23/switch_bot/SwitchBotApi.java @@ -11,14 +11,13 @@ import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import okhttp3.Response; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** */ +@Slf4j @Getter public class SwitchBotApi { - private static final Logger logger = LoggerFactory.getLogger(SwitchBotApi.class); protected static final String baseUrl = "https://api.switch-bot.com/"; private static SwitchBotApi instance; @@ -38,7 +37,7 @@ private SwitchBotApi(String token, String secret) { public static SwitchBotApi getInstance(String token, String secret) { if (token == null || secret == null) { - logger.error("need to define token and secret values."); + log.error("need to define token and secret values."); throw new RuntimeException("need to define token and secret values."); } return Optional.ofNullable(instance).orElseGet(() -> { @@ -67,7 +66,7 @@ protected RequestBuilderCallback addAuth() { .addHeader("nonce", nonce) .addHeader("t", time); } catch (NoSuchAlgorithmException | InvalidKeyException e) { - logger.warn("exception with auth: ", e); + log.warn("exception with auth: ", e); } return builder; }; @@ -83,13 +82,13 @@ protected boolean checkForError(Response response, Optional apiRes return apiResponse .map(api -> { if (api.getStatusCode() != 100) { - logger.error("error code: " + api.getStatusCode() + " : " + api.getMessage()); + log.error("error code: " + api.getStatusCode() + " : " + api.getMessage()); return false; } return true; }) .orElseGet(() -> { - logger.error("Error calling switchbot api: " + response.code() + " " + response.message()); + log.error("Error calling switchbot api: " + response.code() + " " + response.message()); return false; }); } diff --git a/src/main/java/com/bigboxer23/switch_bot/SwitchBotDeviceApi.java b/src/main/java/com/bigboxer23/switch_bot/SwitchBotDeviceApi.java index 971e506..a11d098 100644 --- a/src/main/java/com/bigboxer23/switch_bot/SwitchBotDeviceApi.java +++ b/src/main/java/com/bigboxer23/switch_bot/SwitchBotDeviceApi.java @@ -11,14 +11,13 @@ import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; import okhttp3.RequestBody; import okhttp3.Response; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** */ +@Slf4j public class SwitchBotDeviceApi { - private static final Logger logger = LoggerFactory.getLogger(SwitchBotDeviceApi.class); private final SwitchBotApi provider; private Map deviceIdToNames; @@ -42,12 +41,12 @@ private synchronized void refreshDeviceNameMap() { return; } try { - logger.info("Refreshing device id/name map..."); + log.info("Refreshing device id/name map..."); deviceIdToNames = Collections.unmodifiableMap( getDevices().stream().collect(Collectors.toMap(Device::getDeviceId, Device::getDeviceName))); deviceIdToNamesCacheTime = System.currentTimeMillis(); } catch (IOException e) { - logger.error("Failed to refresh device names.", e); + log.error("Failed to refresh device names.", e); deviceIdToNames = null; deviceIdToNamesCacheTime = -1; } @@ -72,7 +71,7 @@ public List getDevices() throws IOException { */ public Device getDeviceStatus(String deviceId) throws IOException { if (deviceId == null) { - logger.error("Need valid device id"); + log.error("Need valid device id"); return null; } try (Response response = OkHttpUtil.getSynchronous( diff --git a/src/main/java/com/bigboxer23/switch_bot/data/Device.java b/src/main/java/com/bigboxer23/switch_bot/data/Device.java index e97f4df..adc40fc 100644 --- a/src/main/java/com/bigboxer23/switch_bot/data/Device.java +++ b/src/main/java/com/bigboxer23/switch_bot/data/Device.java @@ -41,7 +41,6 @@ public class Device { private float electricCurrent; // amps / 10 - private int waterDetectorStatus; @Json(name = "CO2")