[kodi] Add channel for KODI JSON-RPC call Input.ButtonEvent (#11181)
Signed-off-by: Thomas Schumm <thomas.schumm@yahoo.de>
This commit is contained in:
@@ -60,6 +60,7 @@ public class KodiBindingConstants {
|
||||
public static final String CHANNEL_INPUT = "input";
|
||||
public static final String CHANNEL_INPUTTEXT = "inputtext";
|
||||
public static final String CHANNEL_INPUTACTION = "inputaction";
|
||||
public static final String CHANNEL_INPUTBUTTONEVENT = "inputbuttonevent";
|
||||
|
||||
public static final String CHANNEL_SYSTEMCOMMAND = "systemcommand";
|
||||
|
||||
|
||||
@@ -262,6 +262,15 @@ public class KodiHandler extends BaseThingHandler implements KodiEventListener {
|
||||
updateState(CHANNEL_INPUTACTION, UnDefType.UNDEF);
|
||||
}
|
||||
break;
|
||||
case CHANNEL_INPUTBUTTONEVENT:
|
||||
logger.debug("handleCommand CHANNEL_INPUTBUTTONEVENT {}.", command);
|
||||
if (command instanceof StringType) {
|
||||
connection.inputButtonEvent(command.toString());
|
||||
updateState(CHANNEL_INPUTBUTTONEVENT, UnDefType.UNDEF);
|
||||
} else if (RefreshType.REFRESH == command) {
|
||||
updateState(CHANNEL_INPUTBUTTONEVENT, UnDefType.UNDEF);
|
||||
}
|
||||
break;
|
||||
case CHANNEL_SYSTEMCOMMAND:
|
||||
if (command instanceof StringType) {
|
||||
handleSystemCommand(command.toString());
|
||||
|
||||
@@ -1327,6 +1327,46 @@ public class KodiConnection implements KodiClientSocketEventListener {
|
||||
socket.callMethod("Input.ExecuteAction", params);
|
||||
}
|
||||
|
||||
public void inputButtonEvent(String buttonEvent) {
|
||||
logger.debug("inputButtonEvent {}.", buttonEvent);
|
||||
|
||||
String button = buttonEvent;
|
||||
String keymap = "KB";
|
||||
Integer holdtime = null;
|
||||
|
||||
if (buttonEvent.contains(";")) {
|
||||
String[] params = buttonEvent.split(";");
|
||||
switch (params.length) {
|
||||
case 2:
|
||||
button = params[0];
|
||||
keymap = params[1];
|
||||
break;
|
||||
case 3:
|
||||
button = params[0];
|
||||
keymap = params[1];
|
||||
try {
|
||||
holdtime = Integer.parseInt(params[2]);
|
||||
} catch (NumberFormatException nfe) {
|
||||
holdtime = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.inputButtonEvent(button, keymap, holdtime);
|
||||
}
|
||||
|
||||
private void inputButtonEvent(String button, String keymap, Integer holdtime) {
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty("button", button);
|
||||
params.addProperty("keymap", keymap);
|
||||
if (holdtime != null) {
|
||||
params.addProperty("holdtime", holdtime.intValue());
|
||||
}
|
||||
JsonElement result = socket.callMethod("Input.ButtonEvent", params);
|
||||
logger.debug("inputButtonEvent result {}.", result);
|
||||
}
|
||||
|
||||
public void getSystemProperties() {
|
||||
KodiSystemProperties systemProperties = null;
|
||||
if (socket.isConnected()) {
|
||||
|
||||
@@ -68,6 +68,8 @@ channel-type.kodi.inputtext.label = Texteingabe
|
||||
channel-type.kodi.inputtext.description = Ermöglicht das Senden eines Eingabetextes (Unicode) an das Kodi Media Center.
|
||||
channel-type.kodi.inputaction.label = Aktion
|
||||
channel-type.kodi.inputaction.description = Ermöglicht das Senden einer vordefinierten Aktion an das Kodi Media Center.
|
||||
channel-type.kodi.inputbuttonevent.label = Button
|
||||
channel-type.kodi.inputbuttonevent.description = Ermöglicht das Senden einer Buttonevents an das Kodi Media Center.
|
||||
channel-type.kodi.systemcommand.label = Systembefehl
|
||||
channel-type.kodi.systemcommand.description = Ermöglicht das Senden eines Systembefehls um das Kodi Media Center neu zu starten, in den Ruhezustand oder Stromsparmodus zu versetzen oder herunterzufahren.
|
||||
channel-type.kodi.systemcommand.command.option.Shutdown = Herunterfahren
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<channel id="input" typeId="input"/>
|
||||
<channel id="inputtext" typeId="inputtext"/>
|
||||
<channel id="inputaction" typeId="inputaction"/>
|
||||
<channel id="inputbuttonevent" typeId="inputbuttonevent"/>
|
||||
<channel id="systemcommand" typeId="systemcommand"/>
|
||||
<channel id="title" typeId="system.media-title"/>
|
||||
<channel id="originaltitle" typeId="system.media-title"/>
|
||||
@@ -395,6 +396,11 @@
|
||||
</options>
|
||||
</state>
|
||||
</channel-type>
|
||||
<channel-type id="inputbuttonevent" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Sends a button press event as Input</label>
|
||||
<description>Sends a generic button press event to Kodi</description>
|
||||
</channel-type>
|
||||
<channel-type id="systemcommand" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Send System Command</label>
|
||||
|
||||
Reference in New Issue
Block a user