### Remote Control Buttons
-The rcButton channel has only been tested on an LGUJ657A TV. and this is a list of button codes that are known to work with this device.
-This list has been compiled mostly through trial and error. Your mileage may vary.
+This is a list of button codes that are known to work with several LG WebOS TV models.
+This list has been compiled mostly through trial and error, but the codes applicable to your model may vary.
| Code String | Description |
|-------------|----------------------------------------------------------|
Parameters:
-| Name | Description |
-|---------|------------------------------------------------------------------------|
-| button | Can be one of UP, DOWN, LEFT, RIGHT, BACK, DELETE, ENTER, HOME, or OK |
+| Name | Description |
+|---------|------------------------------------------------------------------------------------------------|
+| button | Can be one of UP, DOWN, LEFT, RIGHT, BACK, EXIT, ENTER, HOME, OK or any other supported value. |
Example:
```
-actions.sendButton("OK")
+actions.sendButton("HOME")
+```
+
+### sendKeyboard(key)
+
+Sends a keyboard input to the WebOS on-screen keyboard.
+
+Parameters:
+
+| Name | Description |
+|---------|--------------------------------|
+| key | Can be either DELETE or ENTER. |
+
+DELETE will delete the last character when on-screen keyboard is displayed with focus in the text field.
+ENTER will remove the keyboard when on-screen keyboard is displayed with focus in the text field.
+
+Example:
+
+```
+actions.sendKeyboard("ENTER")
```
### increaseChannel()
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.lgwebos.internal.handler.LGWebOSHandler;
-import org.openhab.binding.lgwebos.internal.handler.LGWebOSTVMouseSocket.ButtonType;
import org.openhab.binding.lgwebos.internal.handler.LGWebOSTVSocket;
import org.openhab.binding.lgwebos.internal.handler.LGWebOSTVSocket.State;
import org.openhab.binding.lgwebos.internal.handler.command.ServiceSubscription;
return lgWebOSHandler;
}
- private enum Button {
- UP,
- DOWN,
- LEFT,
- RIGHT,
- BACK,
+ private enum Key {
DELETE,
- ENTER,
- HOME,
- OK
+ ENTER
}
@RuleAction(label = "@text/actionShowToastLabel", description = "@text/actionShowToastDesc")
@RuleAction(label = "@text/actionSendButtonLabel", description = "@text/actionSendButtonDesc")
public void sendButton(
- @ActionInput(name = "text", label = "@text/actionSendButtonInputButtonLabel", description = "@text/actionSendButtonInputButtonDesc") String button) {
+ @ActionInput(name = "button", label = "@text/actionSendButtonInputButtonLabel", description = "@text/actionSendButtonInputButtonDesc") String button) {
+ if ("OK".equals(button)) {
+ getConnectedSocket().ifPresent(control -> control.executeMouse(s -> s.click()));
+ } else {
+ getConnectedSocket().ifPresent(control -> control.executeMouse(s -> s.button(button)));
+ }
+ }
+
+ @RuleAction(label = "@text/actionSendKeyboardLabel", description = "@text/actionSendKeyboardDesc")
+ public void sendKeyboard(
+ @ActionInput(name = "key", label = "@text/actionSendKeyboardInputKeyLabel", description = "@text/actionSendKeyboardInputKeyDesc") String key) {
try {
- switch (Button.valueOf(button)) {
- case UP:
- getConnectedSocket().ifPresent(control -> control.executeMouse(s -> s.button(ButtonType.UP)));
- break;
- case DOWN:
- getConnectedSocket().ifPresent(control -> control.executeMouse(s -> s.button(ButtonType.DOWN)));
- break;
- case LEFT:
- getConnectedSocket().ifPresent(control -> control.executeMouse(s -> s.button(ButtonType.LEFT)));
- break;
- case RIGHT:
- getConnectedSocket().ifPresent(control -> control.executeMouse(s -> s.button(ButtonType.RIGHT)));
- break;
- case BACK:
- getConnectedSocket().ifPresent(control -> control.executeMouse(s -> s.button(ButtonType.BACK)));
- break;
+ switch (Key.valueOf(key)) {
case DELETE:
getConnectedSocket().ifPresent(control -> control.sendDelete());
break;
case ENTER:
getConnectedSocket().ifPresent(control -> control.sendEnter());
break;
- case HOME:
- getConnectedSocket().ifPresent(control -> control.executeMouse(s -> s.button("HOME")));
- break;
- case OK:
- getConnectedSocket().ifPresent(control -> control.executeMouse(s -> s.click()));
- break;
}
} catch (IllegalArgumentException ex) {
- logger.warn("{} is not a valid value for button - available are: {}", button,
- Stream.of(Button.values()).map(b -> b.name()).collect(Collectors.joining(", ")));
+ logger.warn("{} is not a valid value for key - available are: {}", key,
+ Stream.of(Key.values()).map(b -> b.name()).collect(Collectors.joining(", ")));
}
}
getConnectedSocket().ifPresent(control -> control.channelDown(createResponseListener()));
}
- @RuleAction(label = "@text/actionSendRCButtonLabel", description = "@text/actionSendRCButtonDesc")
- public void sendRCButton(
- @ActionInput(name = "text", label = "@text/actionSendRCButtonInputTextLabel", description = "@text/actionSendRCButtonInputTextDesc") String rcButton) {
- getConnectedSocket().ifPresent(control -> control.executeMouse(s -> s.button(rcButton)));
- }
-
private Optional<LGWebOSTVSocket> getConnectedSocket() {
LGWebOSHandler lgWebOSHandler = getLGWebOSHandler();
final LGWebOSTVSocket socket = lgWebOSHandler.getSocket();
((LGWebOSActions) actions).sendButton(button);
}
+ public static void sendKeyboard(ThingActions actions, String key) {
+ ((LGWebOSActions) actions).sendKeyboard(key);
+ }
+
public static void increaseChannel(ThingActions actions) {
((LGWebOSActions) actions).increaseChannel();
}
public static void decreaseChannel(ThingActions actions) {
((LGWebOSActions) actions).decreaseChannel();
}
-
- public static void sendRCButton(ThingActions actions, String rcButton) {
- ((LGWebOSActions) actions).sendRCButton(rcButton);
- }
}
actionSendButtonLabel = send a button press
actionSendButtonDesc = Sends a button press event to a WebOS device.
actionSendButtonInputButtonLabel = Button
-actionSendButtonInputButtonDesc = Can be one of UP, DOWN, LEFT, RIGHT, BACK, DELETE, ENTER, HOME, or OK
-actionSendRCButtonLabel = simulate remote control button press
-actionSendRCButtonDesc = Simulates pressing of a Remote Control Button.
-actionSendRCButtonInputTextLabel = Remote Control button name
-actionSendRCButtonInputTextDesc = The Remote Control button name to send to the WebOS device.
+actionSendButtonInputButtonDesc = Can be one of UP, DOWN, LEFT, RIGHT, BACK, EXIT, ENTER, HOME, OK or any other supported value.
+actionSendKeyboardLabel = send a keyboard input
+actionSendKeyboardDesc = Sends a keyboard input to the WebOS on-screen keyboard.
+actionSendKeyboardInputKeyLabel = Key
+actionSendKeyboardInputKeyDesc = Can be either DELETE or ENTER.
actionSendTextLabel = send a text input
actionSendTextDesc = Sends a text input to a WebOS device.
actionSendTextInputTextLabel = Text