From 18b91ec3260ede81484c7b847707010a97c96531 Mon Sep 17 00:00:00 2001 From: Massimo Valla Date: Mon, 16 Oct 2023 22:23:28 +0200 Subject: [PATCH] [openwebnet] code style check Signed-off-by: Massimo Valla --- .../handler/OpenWebNetBridgeHandler.java | 6 ++-- .../handler/OpenWebNetLightingHandler.java | 28 ++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetBridgeHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetBridgeHandler.java index d77bd0d2254d2..dda42f37dc917 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetBridgeHandler.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetBridgeHandler.java @@ -391,7 +391,7 @@ private void discoverByActivation(BaseOpenMessage baseMsg) { /** * Register a device ThingHandler to this BridgHandler * - * @param ownId the device OpenWebNet id + * @param ownId the device OpenWebNet id * @param thingHandler the thing handler to be registered */ protected void registerDevice(String ownId, OpenWebNetThingHandler thingHandler) { @@ -695,7 +695,7 @@ public void onReconnected() { /** * Return a ownId string (=WHO.WHERE) from the device Where address and handler * - * @param where the Where address (to be normalized) + * @param where the Where address (to be normalized) * @param handler the device handler * @return the ownId String */ @@ -706,7 +706,7 @@ protected String ownIdFromDeviceWhere(Where where, OpenWebNetThingHandler handle /** * Returns a ownId string (=WHO.WHERE) from a Who and Where address * - * @param who the Who + * @param who the Who * @param where the Where address (to be normalized) * @return the ownId String */ diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetLightingHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetLightingHandler.java index 0029c82b71149..f29bafd4b1a0d 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetLightingHandler.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetLightingHandler.java @@ -78,9 +78,8 @@ protected void add(int area, OpenWebNetThingHandler h) { oneHandler = h; } logger.warn("/////////////////////// Added handler {} to Area {}", oId, area); - logger.warn(this.toString()); + logger.warn("Map: {}", this.toString()); } - } protected void remove(int area, OpenWebNetThingHandler h) { @@ -88,11 +87,11 @@ protected void remove(int area, OpenWebNetThingHandler h) { Map areaHndlrs = hndlrsMap.get(Integer.valueOf(area)); if (areaHndlrs != null) { boolean removed = areaHndlrs.remove(h.ownId, h); - if (removed && oneHandler == h) { + if (removed && oneHandler.equals(h)) { oneHandler = getFirst(); } logger.warn("/////////////////////// ^^^^^^^^^^^^ Removed handler {} from Area {}", h.ownId, area); - logger.warn(this.toString()); + logger.warn("Map: {}", this.toString()); } } } @@ -191,7 +190,6 @@ public String toString() { public OpenWebNetLightingHandler(Thing thing) { super(thing); - } @Override @@ -355,8 +353,7 @@ private void dimLightTo(int percent, Command command) { lastBrightnessChangeSentTS = System.currentTimeMillis(); send(Lighting.requestDimTo(w.value(), newBrightnessWhat)); } catch (OWNException e) { - logger.warn("Exception while sending dimTo request for command {}: {}", command, - e.getMessage()); + logger.warn("Exception while sending dimTo request for command {}: {}", command, e.getMessage()); } } } else { @@ -381,7 +378,15 @@ protected void handleMultipleMessage(Lighting msg) { if (w.isGeneral()) { l = map.getAllHandlers(); } else if (w.getArea() > 0) { - l = map.getAreaHandlers(w.getArea()); + // l = map.getAreaHandlers(w.getArea()); + + try { + send(Lighting.requestStatus(w.getArea() + "")); + } catch (OWNException e) { + // Auto-generated catch block + // e.printStackTrace(); + } + } if (l != null) { for (OpenWebNetThingHandler hndlr : l) { @@ -457,8 +462,7 @@ private synchronized void updateBrightness(Lighting msg) { } brightness = newBrightness; } else { - logger.warn("updateBrightness() Cannot handle message {} for thing {}", msg, - getThing().getUID()); + logger.warn("updateBrightness() Cannot handle message {} for thing {}", msg, getThing().getUID()); return; } } @@ -520,8 +524,7 @@ private void updateOnOffState(Lighting msg) { } updateState(channelId, OnOffType.from(msg.isOn())); } else { - logger.debug("updateOnOffState() Ignoring unsupported WHAT for thing {}. Frame={}", - getThing().getUID(), + logger.debug("updateOnOffState() Ignoring unsupported WHAT for thing {}. Frame={}", getThing().getUID(), msg.getFrameValue()); return; } @@ -566,5 +569,4 @@ public void dispose() { } super.dispose(); } - }