Log:
02:45:30.712 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:33.173 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:36.210 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:38.018 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 20
02:45:40.440 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:40.749 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:41.035 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:41.310 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:41.575 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:41.581 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command
02:45:41.834 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:42.107 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:42.369 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:43.742 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:44.460 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:45.020 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:45.441 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:45.705 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:45.987 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:46.236 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:46.469 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:46.722 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:47.006 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:47.243 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:47.515 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:47.772 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:48.044 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:48.327 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:48.611 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
02:45:50.672 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 20
02:45:52.761 [ome.event.ItemCommandEvent] - Item ‘ADB_KEY_Args’ received command 66
If you have a look at the log, command “66” is sent to the Android TV correctly. Any subsequent “66” command is not sent. The blank received command is part of the rule I was attempting to reset the variable (i will include below) but it does not work. Reading down log you will see command “20”. This is basically sending another key press and works correctly. After sending the “20” command, “66” will function correctly once, then the log just repeats. It is not just the “66” command btw. You can swap the two, or use different commands and the same result happens. It will not resend the command until a different command is sent.
Thing:
//Android ADB KeyEvent
//Sends android ADB a keyevent number
Thing exec:command:ADB_KEY [ command="/home/openhab/platform-tools/adb shell input keyevent %2$s", interval=0, autorun=true, timeout=01, autoUpdate=false ]
This is the Thing I have been using. The timeout and autoUpdate were added as an attempt to get things working correctly. Removing/adding them has no impact.
Items:
Switch ADBKey
Number ADBKeyNumber
//is running or finished
Switch ADB_KEY {channel="exec:command:ADB_KEY:run"[profile="rawbutton-toggle-switch"]}
//Arguments to be passed to '%2$s' in command
String ADB_KEY_Args {channel="exec:command:ADB_KEY:input", autoupdate="false"}
This is the item. There was an exit string but it did nothing to help or hurt with or without it. The autoUpdate=false was added to stop the “predicted to become” log. It has no impact with or without. The rawbutton-toggle-switch was added to troubleshoot as well. If you take the default exec item binding and use that the end result is the same.
Rule:
var Number i = 0
rule "ADBKeyEventRule"
when
Item ADB_KEY_Args received command
then
while ((i=i+1) == 10)
{
ADB_KEY_Args.sendCommand("")
}
end
This is the closest I have been able to get with a rule to achieve the desired function. It results in the log above. If you were to use the example rule for the exec binding, the log and effect are the same, except the log will show an item state change. Interesting tidbit, if you were to remove the “var Number i = 0” and remove the “while ((i=i+1) ==10)” bits, the end result is correct. The commands are issued as soon as they are given. However, the log runs continuously, as in, non-stop with many updates a second. It will show the “received command 66” line then run away with “received command (space)” until another command is sent. I hope this information is a little more helpful, but if not just let me know what I can do to help. Thanks again.