From f91b7298b6ed66ccd65205db0c8eaf2e7b4150b0 Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Tue, 3 Dec 2024 10:19:21 -0700 Subject: [PATCH] address review comments mostly adjusting error handling, especially wrt not being able to find openHAB's IP address or MAC address Signed-off-by: Cody Cutrer --- bundles/org.openhab.binding.wiz/README.md | 36 +++++---- .../wiz/internal/WizHandlerFactory.java | 3 +- .../discovery/WizDiscoveryService.java | 6 +- .../wiz/internal/handler/WizHandler.java | 32 +++++--- .../wiz/internal/handler/WizMediator.java | 2 +- .../wiz/internal/handler/WizMediatorImpl.java | 44 ++++------- .../runnable/WizUpdateReceiverRunnable.java | 2 +- .../wiz/internal/utils/NetworkUtils.java | 28 ++++--- .../wiz/internal/utils/ValidationUtils.java | 10 --- .../wiz/internal/utils/WizColorConverter.java | 73 +++---------------- .../internal/utils/WizPacketConverter.java | 3 +- .../utils/WizResponseDeserializer.java | 6 +- .../main/resources/OH-INF/i18n/wiz.properties | 7 +- 13 files changed, 100 insertions(+), 152 deletions(-) diff --git a/bundles/org.openhab.binding.wiz/README.md b/bundles/org.openhab.binding.wiz/README.md index a12e2f56a4f2c..55d2816f61d3d 100644 --- a/bundles/org.openhab.binding.wiz/README.md +++ b/bundles/org.openhab.binding.wiz/README.md @@ -24,7 +24,7 @@ Local control must also be enabled with-in the WiZ app in the app settings. - WiZ Smart Plugs - Smart fans (with or without a dimmable light) -_Note_ This binding was created for and tested on the full color with tunable white bulbs, however, users have reported success with other bulb types and plugs. +**NOTE:** This binding was created for and tested on the full color with tunable white bulbs, however, users have reported success with other bulb types and plugs. ## Discovery @@ -72,19 +72,25 @@ Thing wiz:bulb:lamp "My Lamp" @ "Living Room" [ macAddress="accf23343cxx", ipAdd ## Channels -The binding supports the following channels: - -| Channel ID | Item Type | Description | Access | -|-----------------|--------------------|-------------------------------------------------------|--------| -| color | Color | State, intensity, and color of the LEDs | R/W | -| temperature | Dimmer | Color temperature of the bulb | R/W | -| temperature-abs | Number:Temperature | Color temperature of the bulb in Kelvin | R/W | -| brightness | Dimmer | The brightness of the bulb | R/W | -| state | Switch | Whether the bulb is on or off | R/W | -| light-mode | Number | Preset light mode name to run | R/W | -| speed | Dimmer | Speed of the color changes in dynamic light modes | R/W | -| signal-strength | Number | Quality of the bulb's WiFi connection | R | -| last-update | Time | The last time an an update was received from the bulb | R | +The binding supports the following channels. If a device is only a light or only a fan, the channels will +not be in a group. + +| Channel ID | Item Type | Description | Access | +|------------------------|----------------------|-------------------------------------------------------|--------| +| light#color | Color | State, intensity, and color of the LEDs | R/W | +| light#temperature | Dimmer | Color temperature of the bulb | R/W | +| light#temperature-abs | Number:Temperature | Color temperature of the bulb in Kelvin | R/W | +| light#brightness | Dimmer | The brightness of the bulb | R/W | +| light#state | Switch | Whether the bulb is on or off | R/W | +| light#light-mode | Number | Preset light mode name to run | R/W | +| light#speed | Dimmer | Speed of the color changes in dynamic light modes | R/W | +| fan#state | Switch | Whether the fan is on or off | R/W | +| fan#speed | Number | Speed of the fan, in arbitrary steps | R/W | +| fan#reverse | Switch | Whether the fan direction is reversed | R/W | +| fan#mode | Number | Special fan modes (Breeze) | R/W | +| device#last-update | Time | The last time an an update was received from the bulb | R | +| device#signal-strength | Number | Quality of the bulb's WiFi connection | R | +| device#rssi | Number:Dimensionless | WiFi Received Signal Strength Indicator (in dB) | R | ## Light Modes @@ -137,7 +143,7 @@ Sending a command on the color channel or the temperature channel will cause the - Fade in/out times are configured in the app. - Sending too many commands to the bulbs too quickly can cause them to stop responding for a period of time. -## Example item linked to a channel +## Example Item Linked To a Channel ```java Color LivingRoom_Light_Color "Living Room Lamp" (gLivingroom) {channel="wiz:color-bulb:accf23343cxx:color"} diff --git a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/WizHandlerFactory.java b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/WizHandlerFactory.java index 79fa4e67c7806..d15abedfb0075 100644 --- a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/WizHandlerFactory.java +++ b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/WizHandlerFactory.java @@ -66,8 +66,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) { if (supportsThingType(thing.getThingTypeUID())) { WizHandler handler; - handler = new WizHandler(thing, this.mediator.getRegistrationParams(), stateDescriptionProvider, - timeZoneProvider); + handler = new WizHandler(thing, mediator, stateDescriptionProvider, timeZoneProvider); mediator.registerThingAndWizBulbHandler(thing, handler); return handler; diff --git a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/discovery/WizDiscoveryService.java b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/discovery/WizDiscoveryService.java index 4ce1ef82b1f85..6f980523be433 100644 --- a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/discovery/WizDiscoveryService.java +++ b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/discovery/WizDiscoveryService.java @@ -27,6 +27,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.wiz.internal.entities.RegistrationRequestParam; import org.openhab.binding.wiz.internal.entities.SystemConfigResult; import org.openhab.binding.wiz.internal.entities.WizRequest; import org.openhab.binding.wiz.internal.entities.WizResponse; @@ -116,7 +117,8 @@ protected void startScan() { String broadcastIp = this.mediator.getNetworkAddressService().getConfiguredBroadcastAddress(); if (broadcastIp != null) { InetAddress address = InetAddress.getByName(broadcastIp); - WizRequest request = new WizRequest(WizMethodType.Registration, this.mediator.getRegistrationParams()); + RegistrationRequestParam registrationRequestParam = mediator.getRegistrationParams(); + WizRequest request = new WizRequest(WizMethodType.Registration, registrationRequestParam); request.setId(0); byte[] message = this.converter.transformToByteMessage(request); @@ -133,6 +135,8 @@ protected void startScan() { } else { logger.warn("No broadcast address was configured or discovered! No broadcast sent."); } + } catch (IllegalStateException e) { + logger.debug("Unable to start background scan: {}", e.getMessage()); } catch (IOException exception) { logger.debug("Something wrong happened when broadcasting the packet to port {}... msg: {}", DEFAULT_UDP_PORT, exception.getMessage()); diff --git a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizHandler.java b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizHandler.java index 567096c491787..6befaea444d06 100644 --- a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizHandler.java +++ b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizHandler.java @@ -93,7 +93,7 @@ public class WizHandler extends BaseThingHandler { private final Logger logger = LoggerFactory.getLogger(WizHandler.class); private @NonNullByDefault({}) WizDeviceConfiguration config; - private RegistrationRequestParam registrationInfo; + private @Nullable RegistrationRequestParam registrationRequestParam; private int homeId; private WizSyncState mostRecentState; @@ -120,10 +120,14 @@ public class WizHandler extends BaseThingHandler { * @param thing the thing of the handler. * @param stateDescriptionProvider A state description provider */ - public WizHandler(final Thing thing, final RegistrationRequestParam registrationPacket, + public WizHandler(final Thing thing, final WizMediator mediator, WizStateDescriptionProvider stateDescriptionProvider, TimeZoneProvider timeZoneProvider) { super(thing); - this.registrationInfo = registrationPacket; + try { + registrationRequestParam = mediator.getRegistrationParams(); + } catch (IllegalStateException e) { + registrationRequestParam = null; + } this.stateDescriptionProvider = stateDescriptionProvider; this.timeZoneProvider = timeZoneProvider; this.mostRecentState = new WizSyncState(); @@ -334,7 +338,7 @@ private void handleFanModeCommand(DecimalType mode) { private void handleIncreaseDecreaseCommand(boolean isIncrease) { int oldDimming = mostRecentState.dimming; - int newDimming = 50; + int newDimming; if (isIncrease) { newDimming = Math.min(100, oldDimming + 5); } else { @@ -351,7 +355,7 @@ private void handleTemperatureCommand(int temperature) { private void handleIncreaseDecreaseTemperatureCommand(boolean isIncrease) { float oldTempPct = colorTempToPercent(mostRecentState.getTemperature()).floatValue(); - float newTempPct = 50; + float newTempPct; if (isIncrease) { newTempPct = Math.min(100, oldTempPct + 5); } else { @@ -370,7 +374,7 @@ private void handleSpeedCommand(PercentType speed) { private void handleIncreaseDecreaseSpeedCommand(boolean isIncrease) { int oldSpeed = mostRecentState.speed; - int newSpeed = 50; + int newSpeed; if (isIncrease) { newSpeed = Math.min(100, oldSpeed + 5); } else { @@ -452,11 +456,18 @@ public void initialize() { fullyInitialized = false; disposed = false; - // set the thing status to UNKNOWN temporarily - updateStatus(ThingStatus.UNKNOWN); - if (ValidationUtils.isMacNotValid(config.macAddress)) { + if (registrationRequestParam == null) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, + "Unable to determine openHAB's IP or MAC address"); + return; + } + if (!ValidationUtils.isMacValid(config.macAddress)) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "MAC address is not valid"); + return; } + + // set the thing status to UNKNOWN temporarily + updateStatus(ThingStatus.UNKNOWN); updateDeviceProperties(); initGetStatusAndKeepAliveThread(); fullyInitialized = true; @@ -792,7 +803,8 @@ private synchronized void updateDeviceProperties() { * heart-beats the registration must be re-sent after 30s. */ private synchronized void registerWithDevice() { - WizResponse registrationResponse = sendRequestPacket(WizMethodType.Registration, this.registrationInfo); + WizResponse registrationResponse = sendRequestPacket(WizMethodType.Registration, + Objects.requireNonNull(registrationRequestParam)); if (registrationResponse != null) { if (registrationResponse.getResultSuccess()) { updateTimestamps(); diff --git a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizMediator.java b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizMediator.java index bc9ed8169f510..29ee6ff6fc774 100644 --- a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizMediator.java +++ b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizMediator.java @@ -45,7 +45,7 @@ public interface WizMediator { * connection. * */ - RegistrationRequestParam getRegistrationParams(); + RegistrationRequestParam getRegistrationParams() throws IllegalStateException; /** * Registers a new {@link Thing} and the corresponding diff --git a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizMediatorImpl.java b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizMediatorImpl.java index 2f84c67664a27..c354df448f779 100644 --- a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizMediatorImpl.java +++ b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizMediatorImpl.java @@ -21,6 +21,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.wiz.internal.WizBindingConstants; import org.openhab.binding.wiz.internal.discovery.WizDiscoveryService; import org.openhab.binding.wiz.internal.entities.RegistrationRequestParam; import org.openhab.binding.wiz.internal.entities.WizResponse; @@ -175,10 +176,10 @@ private void initMediatorWizBulbUpdateReceiverRunnable() { try { logger.trace("Receiver thread is either null, interrupted, or dead."); WizUpdateReceiverRunnable newReceiver = new WizUpdateReceiverRunnable(this, DEFAULT_LISTENER_UDP_PORT); - Thread newThread = new Thread(newReceiver); + Thread newThread = new Thread(newReceiver, + "OH-binding-" + WizBindingConstants.BINDING_ID + "-ReceiverThread"); newThread.setDaemon(true); newThread.start(); - newThread.setName("wizReceiverThread"); this.receiver = newReceiver; this.receiverThread = newThread; } catch (SocketException e) { @@ -197,37 +198,22 @@ public Set getAllThingsRegistered() { return this.handlersRegisteredByThing.keySet(); } - private String getMyIpAddress() { - String myIpAddress = networkAddressService.getPrimaryIpv4HostAddress(); - if (myIpAddress == null) { - logger.warn("Network interface did not return an IP address!"); - return "OHIPAddress"; - } - return myIpAddress; - } - - private String getMyMacAddress() { - String myMacAddress; - try { - myMacAddress = NetworkUtils.getMyMacAddress(getMyIpAddress()); - if (myMacAddress == null) { - logger.warn("No network interface could be found. MAC of openHAB device is unknown."); - return "OHMACAddress"; - } - } catch (Exception e) { - logger.warn("MAC Address of openHAB device is invalid."); - return "OHMACAddress"; - } - return myMacAddress; - } - /** * Returns a {@link RegistrationRequestParam} based on the current openHAB * connection. - * + * + * @throws IllegalStateException */ - public RegistrationRequestParam getRegistrationParams() { - return new RegistrationRequestParam(getMyIpAddress(), true, 0, getMyMacAddress()); + public RegistrationRequestParam getRegistrationParams() throws IllegalStateException { + String ipAddress = networkAddressService.getPrimaryIpv4HostAddress(); + String macAddress = null; + if (ipAddress != null) { + macAddress = NetworkUtils.getMacAddress(ipAddress); + } + if (ipAddress == null || macAddress == null) { + throw new IllegalStateException("Unable to determine openHAB's IP and/or MAC address"); + } + return new RegistrationRequestParam(ipAddress, true, 0, macAddress); } @Override diff --git a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/runnable/WizUpdateReceiverRunnable.java b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/runnable/WizUpdateReceiverRunnable.java index ca7ac095b277e..0946a5168b392 100644 --- a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/runnable/WizUpdateReceiverRunnable.java +++ b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/runnable/WizUpdateReceiverRunnable.java @@ -125,7 +125,7 @@ private void datagramSocketHealthRoutine() { this.datagramSocket = dsocket; logger.trace("Datagram Socket reconnected."); } catch (SocketException exception) { - logger.warn("Problem creating one new socket on port {}. Error: {}", listeningPort, + logger.debug("Problem creating one new socket on port {}. Error: {}", listeningPort, exception.getLocalizedMessage()); } } diff --git a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/NetworkUtils.java b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/NetworkUtils.java index a1ec9c5e77f55..1987c5c24eecc 100644 --- a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/NetworkUtils.java +++ b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/NetworkUtils.java @@ -15,7 +15,6 @@ import java.net.InterfaceAddress; import java.net.NetworkInterface; import java.net.SocketException; -import java.rmi.UnknownHostException; import java.util.Enumeration; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -34,25 +33,24 @@ public final class NetworkUtils { * Returns the MAC address of the openHAB first network device. * * @return The MAC address of the openHAB network device. - * @throws UnknownHostException - * @throws SocketException */ - public static @Nullable String getMyMacAddress(String matchIP) throws UnknownHostException, SocketException { - String macAddress = null; - Enumeration networks = NetworkInterface.getNetworkInterfaces(); - while (networks.hasMoreElements()) { - NetworkInterface network = networks.nextElement(); + public static @Nullable String getMacAddress(String matchIP) { + try { + Enumeration networks = NetworkInterface.getNetworkInterfaces(); + while (networks.hasMoreElements()) { + NetworkInterface network = networks.nextElement(); - if (networkMatchesIP(network, matchIP)) { - byte[] hardwareAddress = network.getHardwareAddress(); - if (hardwareAddress == null) { - continue; + if (networkMatchesIP(network, matchIP)) { + byte[] hardwareAddress = network.getHardwareAddress(); + if (hardwareAddress == null) { + continue; + } + return convertBytesToMACString(hardwareAddress); } - macAddress = convertBytesToMACString(hardwareAddress); - break; // Short circuit if we found it } + } catch (SocketException e) { } - return macAddress; + return null; } private static boolean networkMatchesIP(NetworkInterface network, String ip) { diff --git a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/ValidationUtils.java b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/ValidationUtils.java index f40f2cc20415a..5ae40af4d3183 100644 --- a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/ValidationUtils.java +++ b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/ValidationUtils.java @@ -43,14 +43,4 @@ public static boolean isMacValid(final String mac) { Matcher matcher = VALID_PATTERN.matcher(mac); return matcher.matches(); } - - /** - * Validates if one Mac address is not valid. - * - * @param mac the mac, with or without : - * @return true if is not valid. - */ - public static boolean isMacNotValid(final String macAddress) { - return !isMacValid(macAddress); - } } diff --git a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/WizColorConverter.java b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/WizColorConverter.java index 7c0d499a89808..75423fad37e3f 100644 --- a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/WizColorConverter.java +++ b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/WizColorConverter.java @@ -16,11 +16,10 @@ import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.HSBType; import org.openhab.core.library.types.PercentType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openhab.core.util.ColorUtil; /** - * Utilities for converting colors and color temperures + * Utilities for converting colors and color temperatures * * The full color WiZ bulbs can produce colors and various temperatures of * "whites" by mixing any of the available LEDs: RGBWwarm = RGBWWCwarm = Red, @@ -35,9 +34,6 @@ */ @NonNullByDefault public class WizColorConverter { - - private final Logger logger = LoggerFactory.getLogger(WizColorConverter.class); - /** * Converts an {@link DecimalType} hue and a {@link PercentType} saturation to * red, green, blue, and white (RGBW) components. Because the WiZ bulbs keep @@ -52,65 +48,20 @@ public class WizColorConverter { * @return an interger array of the color components */ public int[] hsbToRgbw(HSBType hsb) { - double redD = 255.; - double greenD = 255.; - double blueD = 255.; - int red = 255; - int green = 255; - int blue = 255; - int white = 255; - // Since we're going to use the white lights to control saturation, recalculate what // the HSBvalue would be if the color was at full brightness and saturation - Double hue = hsb.getHue().doubleValue(); - Double sat255 = ((hsb.getSaturation().doubleValue()) / 100) * 255; - - if (sat255 > 0) { - int i = (int) (hue / 60); // color quadrant 0..2555 - double f = hue % 60; // 0..59 - double q = 255 - ((f / 60) * sat255); - - double p = 0; - double t = 255 - (((60 - f) / 60) * 255); - - switch (i) { - case 0: - // redD = 255; - greenD = t; - blueD = p; - break; - case 1: - redD = q; - // greenD = 255; - blueD = p; - break; - case 2: - redD = p; - // greenD = 255; - blueD = t; - break; - case 3: - redD = p; - greenD = q; - // blueD = 255; - break; - case 4: - redD = t; - greenD = p; - // blueD = 255; - break; - default: - // redD = 255; - greenD = p; - blueD = q; - break; - } - } + HSBType hsbFullBrightness = new HSBType(hsb.getHue(), hsb.getSaturation(), PercentType.HUNDRED); + PercentType[] rgbPercent = ColorUtil.hsbToRgbPercent(hsbFullBrightness); + double redD = rgbPercent[0].doubleValue(); + double greenD = rgbPercent[1].doubleValue(); + double blueD = rgbPercent[2].doubleValue(); - logger.debug("Colors from hue, assuming full brightness R: {} G: {} B: {}", redD, greenD, blueD); + double saturationPercent = hsb.getSaturation().doubleValue() / 100; - // Convert the "PercentType" to a percent - double saturationPercent = (hsb.getSaturation().doubleValue() / 100); + int red; + int green; + int blue; + int white; // Calculate the white intensity from saturation and adjust down the other colors // This is approximately what the WiZ app does. Personally, I think it undersaturates everything diff --git a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/WizPacketConverter.java b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/WizPacketConverter.java index 414f2e3c45a2b..400745dd43b9b 100644 --- a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/WizPacketConverter.java +++ b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/WizPacketConverter.java @@ -47,7 +47,6 @@ public WizPacketConverter() { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(WizResponse.class, new WizResponseDeserializer()); gsonBuilder.excludeFieldsWithoutExposeAnnotation(); - // gsonBuilder.setLenient(); Gson gson = gsonBuilder.create(); this.wizGsonBuilder = gson; } @@ -85,7 +84,7 @@ public byte[] transformToByteMessage(final WizRequest requestPacket) { response = this.wizGsonBuilder.fromJson(responseJson, WizResponse.class); response.setWizResponseIpAddress(packet.getAddress().getHostAddress()); } catch (JsonParseException e) { - logger.error("Error parsing json! {}", e.getMessage()); + logger.debug("Error parsing json! {}", e.getMessage()); } return response; } diff --git a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/WizResponseDeserializer.java b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/WizResponseDeserializer.java index 468fd5f3a6ebe..6cfc24ad85d34 100644 --- a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/WizResponseDeserializer.java +++ b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/utils/WizResponseDeserializer.java @@ -73,10 +73,10 @@ public WizResponse deserialize(@Nullable JsonElement json, @Nullable Type typeOf ErrorResponseResult.class); deserializedResponse.setError(error); if (jobject.has("method")) { - logger.warn("Bulb returned an error on method {}: {}, {}", jobject.get("method"), error.code, + logger.debug("Bulb returned an error on method {}: {}, {}", jobject.get("method"), error.code, error.message); } else { - logger.warn("Bulb returned an error: {}", error.code); + logger.debug("Bulb returned an error: {}", error.code); } return deserializedResponse; } @@ -91,7 +91,7 @@ public WizResponse deserialize(@Nullable JsonElement json, @Nullable Type typeOf method = WizMethodType.valueOf(properCaseMethod); deserializedResponse.setMethod(method); } catch (IllegalArgumentException e) { - logger.warn("Bulb returned an invalid method: {}", jobject.get("method")); + logger.debug("Bulb returned an invalid method: {}", jobject.get("method")); return deserializedResponse; } } else { diff --git a/bundles/org.openhab.binding.wiz/src/main/resources/OH-INF/i18n/wiz.properties b/bundles/org.openhab.binding.wiz/src/main/resources/OH-INF/i18n/wiz.properties index 95c3deeaca950..620005071a551 100644 --- a/bundles/org.openhab.binding.wiz/src/main/resources/OH-INF/i18n/wiz.properties +++ b/bundles/org.openhab.binding.wiz/src/main/resources/OH-INF/i18n/wiz.properties @@ -40,12 +40,13 @@ channel-group-type.wiz.fan-group.label = Fan # channel types channel-type.wiz.fan-mode.label = Mode -channel-type.wiz.fan-mode.state.option.OFF = Normal -channel-type.wiz.fan-mode.state.option.ON = Breeze +channel-type.wiz.fan-mode.state.option.1 = Normal +channel-type.wiz.fan-mode.state.option.2 = Breeze channel-type.wiz.fan-reverse.label = Reverse channel-type.wiz.fan-reverse.state.option.OFF = Forward channel-type.wiz.fan-reverse.state.option.ON = Reverse channel-type.wiz.fan-speed.label = Fan Speed +channel-type.wiz.fan-speed.description = Speed of the fan, in arbitrary steps channel-type.wiz.last-update.label = Last Update channel-type.wiz.last-update.description = Timestamp of last status update channel-type.wiz.light-mode-speed.label = Dynamic Light Mode Speed @@ -83,6 +84,8 @@ channel-type.wiz.light-mode.state.option.29 = Candlelight channel-type.wiz.light-mode.state.option.30 = Golden White channel-type.wiz.light-mode.state.option.31 = Pulse channel-type.wiz.light-mode.state.option.32 = Steampunk +channel-type.wiz.rssi.label = RSSI +channel-type.wiz.rssi.description = WiFi Received Signal Strength Indicator # thing types config