nVidia Shield help - SendKey and Variables

Post your questions and help other users.

Moderator: Martin

Post Reply
Stik
Posts: 3
Joined: 29 Oct 2019 17:45

nVidia Shield help - SendKey and Variables

Post by Stik » 29 Oct 2019 21:50

I am just getting start with Automagic. As many others, I am trying to use it to achieve IP control of a nVidia Shield TV.

The TV is rooted and I was initially successful at achieving IP control utilizing Root Command to send Keycodes. The advantage was that it was easy to program with a single action and a variable sent through the HTTP request to utilize as the Keycode used in the Root Command. Unfortunately, the lag associated with the excessive time to complete each command makes this technique unusable.

I have seen some other users have had success with a faster (and reportedly acceptable) response by changing the default keyboard and using the UI Command sendKey. I have gotten this to work using fixed arguments, but it doesn't appear sendKey will accept a variable as an argument, for example: sendKey({param_action}). This seems to mean programming it will be quite the chore. So a few questions...

1. Am I correct in the assessment that sendKey() will not accept a variable for an argument?
2. If so, is there any workaround to this other than having a separate condition and action for each IP control? For instance, could the entire funtion (i.e. "sendKey(20)" for instance) be sent as a text string in the HTTP request and then executed that way?
3. Has anybody figured out some other fast way to use IP commands to control a rooted nVidia Shield?

Thanks for the help as I try to wrap my head around how to properly use Automagic.

Stik
Posts: 3
Joined: 29 Oct 2019 17:45

Re: nVidia Shield help - SendKey and Variables

Post by Stik » 30 Oct 2019 17:48

As a follow up to my own post...

After reviewing the log with several different attempts at how to format the sendKey() action, it appears that sendKey({variable}) is the correct formatting and should work, but possibly isn't being parsed correctly by Automagic. When I use this format with variable=20, the relevant error says:

Keycode 20 is not valid (Expression: sendKey({variable})[line 0], Cause: No field KEYCODE_20 in class Landroid/view/KeyEvent;

However, if I take the variable out and just use sendKey(20), the action functions correctly. I am hoping a moderator or experienced user can comment on why this isn't working.

Thanks!

Stik
Posts: 3
Joined: 29 Oct 2019 17:45

Re: nVidia Shield help - SendKey and Variables

Post by Stik » 31 Oct 2019 12:02

For any other newbs, I figured out why the sendKey was not being parsed correctly - It was looking at the variable as text. Utilizing toNumber fixes this and the function will then work correctly with the variable. So the final function is:

sendKey(toNumber({param_variable}))

Post Reply