I’m having trouble passing a variable from LL to Tasker.

I’m having trouble passing a variable from LL to Tasker. I’m calling a task using the form: “LL.sendTaskerIntent(new TaskerIntent(“MyTask”), false);” as specified. But when I add a second line to the script to pass Tasker a variable as in: “i.addVariable( “%name”, “value” );” I keep getting an error from LL stating that the variable “i” is not defined. Would greatly appreciate it if someone could point out what I’m doing wrong.

18 Commentsto I’m having trouble passing a variable from LL to Tasker.

  1. I couldn’t find a doc using addVariable. From which doc did you get that?

    Anyways, i isn’t defined because you didn’t define it. This is how to use it:

    var i = new TaskerIntent(“task”);

    //add args here

    LL.sendTaskerIntent(i);

  2. Jesse Roche says:

    addVariable can be found at: http://tasker.dinglisch.net/invoketasks.html. I did try to use the variable as you specified but I think the problem is with addVariable. I’m trying to pass a variable with a certain value to Tasker. The task that I’m calling contains a Music Play action, which contains the variable name instead of a file path. The file path is the value of the variable I’m trying to pass to Tasker. Would this be easier to do by requesting Tasker to execute a task on the fly as you outlined in http://www.pierrox.net/android/applications/lightning_launcher/wiki/doku.php?id=working_with_tasker? If so, would you mind outlining how I would accomplish?

  3. The version of TaskerIntent bundled with Lightning does not support addVariable.

    Pierre Hébert​ please update this if possible.

  4. var i = new TaskerIntent(“task”);

    i.addAction(ActionCodes.SET_VARIABLE);

    i.addArg(“%Variable”);

    i.addArg(“value”);

    i.addArg(false);

    i.addArg(false);

    //optional args here

    LL.sendTaskerIntent(i,false);

  5. Jesse Roche says:

    Thanks. I tried implementing the code for addAction you provided, but Tasker does not seem to be picking up the variable. It’s running the task but isn’t passing the variable.

  6. You have to run this before your task (with another task name) and a global Variable name.

  7. Jesse Roche says:

    Yes, I did that. I’m using this to trigger the task, which it is doing without any problem. But the trouble is Tasker isn’t getting the variable that I’m trying to pass using this method. Let me just confirm, for the second line, I entered “i.addAction(ActionCodes.SET_VARIABLE);” as specified above.

  8. You first have to trigger a task which gets the variable as specified above (this doesn’t require anything on taskers side)

    Then you can trigger a task which can use the variable.

    Also check if external access is on in tasker.

  9. Jesse Roche says:

    If I understand correctly, I should set up two tasks: one to receive the variable and another to perform an action using the variable. What kind of action would I set up in the first task to receive the variable? I don’t see an action in Tasker that would correspond to that. Should I use the Variable Set action to set the global var to another var name? I’m also assuming that I would use the first task that receives the var to trigger (via Tasker’s Perform Task action) the second action.

  10. I read the docs more closely. This is actually the easiest solution:

    var i = new TaskerIntent(“Test”);

    i.addParameter(“test”);

    LL.sendTaskerIntent(i,false);

    you can access the paramter in your task with %par1

  11. Jesse Roche says:

    where “Test” = task name and “test” = variable’s value?

  12. Jesse Roche says:

    Ok, got this working. Since Tasker’s Music Play action doesn’t have a parameters value, I used the original method you outlined specifying task A, which exists just to receive the variable into Tasker. The only action I put in this task is just a simple Flash action (this is more or less just a placeholder for the task to exist, since Tasker won’t actually run any actions in this task). Then I set up an event profile for set variable, which runs the second task, which contains the Music Play action. Works nicely. Thanks for your help. Please let me know if you add the addVariable functionality. Appreciate it.

  13. The version of TaskerIntent bundled in Lightning is 1.3.3 as found at http://tasker.dinglisch.net/code/TaskerIntent.java. Although addVariable is mentioned for 1.2 in the doc at http://tasker.dinglisch.net/invoketasks.html, it is not in the newest TaskerIntent version. It might have been deprecated or renamed.

  14. While the comment states that it is version 1.3.3, the used intent version is 1.1 (INTENT_VERSION_NUMBER).

    I wasn’t able to find anything else though.

  15. After looking through the code I noticed it is in fact there, but is called addLocalVariable

  16. Jesse Roche says:

    Thanks for following up on this. So, I should use “addLocalVariable” instead of “addVariable”?

Leave a Reply

Your email address will not be published. Required fields are marked *