diff --git a/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/OmnilinkBindingConstants.java b/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/OmnilinkBindingConstants.java index bc1d9aa65c08a..d9ba8913d7a5c 100644 --- a/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/OmnilinkBindingConstants.java +++ b/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/OmnilinkBindingConstants.java @@ -53,7 +53,7 @@ public class OmnilinkBindingConstants { public final static String CHANNEL_ROOM_SCENEB = "sceneb"; public final static String CHANNEL_ROOM_SCENEC = "scenec"; public final static String CHANNEL_ROOM_SCENED = "scened"; - public final static String CHANNEL_ROOM_STATE = "state"; + public final static String CHANNEL_ROOM_STATE = "room_state"; public final static String CHANNEL_FLAGSWITCH = "switch"; public final static String CHANNEL_BUTTON_PRESS = "press"; diff --git a/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/ButtonHandler.java b/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/ButtonHandler.java index 5a4e3ab1b54a9..5866ea6b1ae59 100644 --- a/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/ButtonHandler.java +++ b/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/ButtonHandler.java @@ -3,7 +3,6 @@ import org.eclipse.smarthome.core.library.types.OnOffType; import org.eclipse.smarthome.core.thing.ChannelUID; import org.eclipse.smarthome.core.thing.Thing; -import org.eclipse.smarthome.core.thing.UID; import org.eclipse.smarthome.core.types.Command; import org.eclipse.smarthome.core.types.RefreshType; import org.openhab.binding.omnilink.OmnilinkBindingConstants; @@ -23,12 +22,11 @@ public ButtonHandler(Thing thing) { @Override public void handleCommand(ChannelUID channelUID, Command command) { - String[] channelParts = channelUID.getAsString().split(UID.SEPARATOR); logger.debug("must handle command for button. channel: {}, command: {}", channelUID, command); if (!(command instanceof RefreshType)) { try { - getOmnilinkBridgeHander().sendOmnilinkCommand(CommandMessage.CMD_BUTTON, 0, - Integer.parseInt(channelParts[channelParts.length - 2])); + int buttonNumber = getThingID(); + getOmnilinkBridgeHander().sendOmnilinkCommand(CommandMessage.CMD_BUTTON, 0, buttonNumber); } catch (NumberFormatException | OmniInvalidResponseException | OmniUnknownMessageTypeException | BridgeOfflineException e) { logger.debug("Could not send command to omnilink: {}", e); diff --git a/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/FlagHandler.java b/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/FlagHandler.java index 2fa2815d5942b..6204360acc49d 100644 --- a/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/FlagHandler.java +++ b/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/FlagHandler.java @@ -32,7 +32,7 @@ public void handleUpdate(ChannelUID channelUID, State newState) { @Override public void handleCommand(ChannelUID channelUID, Command command) { logger.debug("handleCommand called for channel:{}, command:{}", channelUID, command); - // final String[] channelParts = channelUID.getAsString().split(UID.SEPARATOR); + int flagID = getThingID(); if (command instanceof DecimalType) { logger.debug("updating omnilink flag change: {}, command: {}", channelUID, command); diff --git a/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/RoomHandler.java b/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/RoomHandler.java index 2c9069ed454b6..ec8023a76646f 100644 --- a/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/RoomHandler.java +++ b/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/RoomHandler.java @@ -4,7 +4,6 @@ import org.eclipse.smarthome.core.library.types.OnOffType; import org.eclipse.smarthome.core.thing.ChannelUID; import org.eclipse.smarthome.core.thing.Thing; -import org.eclipse.smarthome.core.thing.UID; import org.eclipse.smarthome.core.types.Command; import org.openhab.binding.omnilink.OmnilinkBindingConstants; import org.slf4j.Logger; @@ -27,15 +26,16 @@ public RoomHandler(Thing thing) { @Override public void handleCommand(ChannelUID channelUID, Command command) { logger.debug("handleCommand, channel id: {}, command: {}", channelUID, command); - String[] channelParts = channelUID.getAsString().split(UID.SEPARATOR); + + String channelID = channelUID.getId(); int unitNum = getThingID(); - if (channelParts[3].startsWith("scene") && OnOffType.ON.equals(command)) { + if (channelID.startsWith("scene") && OnOffType.ON.equals(command)) { int param1 = 0; int linkNum = -1; - switch (channelParts[3]) { + switch (channelID) { case "scenea": linkNum = 0; break; @@ -61,7 +61,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { logger.debug("Could not send command to omnilink: {}", e); } } - } else if (OmnilinkBindingConstants.CHANNEL_ROOM_SWITCH.equals(channelParts[3])) { + } else if (OmnilinkBindingConstants.CHANNEL_ROOM_SWITCH.equals(channelID)) { int cmd; if (OnOffType.ON.equals(command)) { cmd = OmniLinkCmd.CMD_UNIT_ON.getNumber(); @@ -73,20 +73,20 @@ public void handleCommand(ChannelUID channelUID, Command command) { } catch (OmniInvalidResponseException | OmniUnknownMessageTypeException | BridgeOfflineException e) { logger.debug("Could not send command to omnilink: {}", e); } - } else if (OmnilinkBindingConstants.CHANNEL_ROOM_ON.equals(channelParts[3]) && OnOffType.ON.equals(command)) { + } else if (OmnilinkBindingConstants.CHANNEL_ROOM_ON.equals(channelID) && OnOffType.ON.equals(command)) { int cmd = OmniLinkCmd.CMD_UNIT_ON.getNumber(); try { getOmnilinkBridgeHander().sendOmnilinkCommand(cmd, 0, unitNum); } catch (OmniInvalidResponseException | OmniUnknownMessageTypeException | BridgeOfflineException e) { logger.debug("Could not send command to omnilink: {}", e); } - } else if (OmnilinkBindingConstants.CHANNEL_ROOM_OFF.equals(channelParts[3]) && OnOffType.ON.equals(command)) { + } else if (OmnilinkBindingConstants.CHANNEL_ROOM_OFF.equals(channelID) && OnOffType.ON.equals(command)) { try { getOmnilinkBridgeHander().sendOmnilinkCommand(OmniLinkCmd.CMD_UNIT_OFF.getNumber(), 0, unitNum); } catch (OmniInvalidResponseException | OmniUnknownMessageTypeException | BridgeOfflineException e) { logger.debug("Could not send command to omnilink: {}", e); } - } else if (OmnilinkBindingConstants.CHANNEL_ROOM_STATE.equals(channelParts[3])) { + } else if (OmnilinkBindingConstants.CHANNEL_ROOM_STATE.equals(channelID)) { int cmd = -1; int param2 = -1; if (command instanceof DecimalType) { diff --git a/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/ThermostatHandler.java b/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/ThermostatHandler.java index b8face8f14554..616cf2b958a56 100644 --- a/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/ThermostatHandler.java +++ b/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/ThermostatHandler.java @@ -6,7 +6,6 @@ import org.eclipse.smarthome.core.library.types.OpenClosedType; import org.eclipse.smarthome.core.thing.ChannelUID; import org.eclipse.smarthome.core.thing.Thing; -import org.eclipse.smarthome.core.thing.UID; import org.eclipse.smarthome.core.types.Command; import org.eclipse.smarthome.core.types.State; import org.openhab.binding.omnilink.OmnilinkBindingConstants; @@ -44,10 +43,9 @@ public ThermostatHandler(Thing thing) { @Override public void handleCommand(ChannelUID channelUID, Command command) { - String[] channelParts = channelUID.getAsString().split(UID.SEPARATOR); - logger.debug("Channel Parts {}", (Object[]) channelParts); + int thermostatID = getThingID(); - String channelID = channelParts[3]; + String channelID = channelUID.getId(); try { switch (channelID) { diff --git a/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/UpbUnitHandler.java b/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/UpbUnitHandler.java index 57f31976610de..f4ddda9f6b237 100644 --- a/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/UpbUnitHandler.java +++ b/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/UpbUnitHandler.java @@ -8,7 +8,6 @@ import org.eclipse.smarthome.core.library.types.PercentType; import org.eclipse.smarthome.core.thing.ChannelUID; import org.eclipse.smarthome.core.thing.Thing; -import org.eclipse.smarthome.core.thing.UID; import org.eclipse.smarthome.core.types.Command; import org.eclipse.smarthome.core.types.State; import org.eclipse.smarthome.core.types.Type; @@ -42,10 +41,9 @@ public UpbUnitHandler(Thing thing) { @Override public void handleCommand(ChannelUID channelUID, Command command) { - String[] channelParts = channelUID.getAsString().split(UID.SEPARATOR); logger.debug("handleCommand called"); OmniLinkCmd omniCmd; - int unitId = Integer.parseInt(channelParts[channelParts.length - 2]); + int unitId = getThingID(); if (command instanceof PercentType) { int lightLevel = ((PercentType) command).intValue();