1. Introducing Channels - a new way to chat with other Android users!
    Dismiss Notice

Using Tasker to subtract times (large numbers)


Last Updated:

  1. kernelRiot

    kernelRiot New Member This Topic's Starter

    Joined:
    Aug 8, 2010
    Messages:
    4
    Likes Received:
    0
    I'm trying to set up a Profile that will flash "Charging..." when I plug in the phone and flash "Charged for XXX seconds" when I unplug it.

    My profile looks like this:
    [Context] Power; Source=Any
    [Task]
    [Enter] Flash; Text="Charging"
    Variable Set; Name %CHARGESTART To %TIMES
    [Exit] Variable Set; Name %CHARGEEND To %TIMES
    Variable Subtract; Name %CHARGEEND Value %CHARGESTART
    Flash; Text="Charged for %CHARGEEND seconds"

    Unfortunately when I use this, I don't see "Charged for %CHARGEEND seconds", but rather "Variable %CHARGESTART: value XXX out of range 1:60" where XXX is the last value %CHARGESTART was set to by the enter task.

    Seems like Tasker can only subtract a value from another if that value to subtract is between 1 and 60. This seems very limiting.

    I tried to make a workaround where there's a loop that subtracts 60 each iteration while %CHARGESTART is > 60, but this takes forever when the number is as large as it is for %TIMES.

    Is there something I'm missing here? Perhaps there is an easier way I just don't know of? I would have to think this would be possible.

    If nothing else, perhaps writing to a file, calling some application which does the subtraction and writes to the file again, then using those file contents as the number?
     

    Advertisement
  2. UncleMike

    UncleMike Well-Known Member

    Joined:
    Nov 15, 2009
    Messages:
    2,319
    Likes Received:
    482
    I just tested this and got the same error as you. I kind of look at the Variable Add and Variable Subtract actions as simplified/limited versions of Variable Set. With that in mind, here's a workaround:

    Variable Set [Name: %CHARGE] [Value: %CHARGEEND - %CHARGESTART] [Do Maths: Yes]
    Flash [Text: Charged for %CHARGE seconds]

    I'll report the issue to the developer.
     
    kernelRiot likes this.
  3. kernelRiot

    kernelRiot New Member This Topic's Starter

    Joined:
    Aug 8, 2010
    Messages:
    4
    Likes Received:
    0
    I actually had tried that before, and again just now but ran Into another problem. If you do "%CHARGEEND-%CHARGESTART" instead of "%CHARGEEND - %CHARGESTART", the do maths fails. I guess without the spaces in there, it doesn't parse the expression correctly. Doesn't seem like it should be like that, since variable names can't have happens. Can you also pass that Information along to the developer?

    Once I used the spaces, things worked no problems. Thanks a lot for your help!
     
  4. Rushey

    Rushey Well-Known Member

    Joined:
    Jul 10, 2010
    Messages:
    153
    Likes Received:
    15
    Wouldn't minutes be a more useful display than seconds? I wouldn't have a clue how many minutes were in say 9,480 seconds just from looking, I'd need to work it out.

    Rob
     
  5. kernelRiot

    kernelRiot New Member This Topic's Starter

    Joined:
    Aug 8, 2010
    Messages:
    4
    Likes Received:
    0
    Using seconds was just to see if I could get the idea working. I significantly expanded the profile so that it will give the time in hours, minutes or seconds if it makes sense to. If someone's interested, I could write out the profile.

    Also, I plan on expanding the functionality to also show how much battery % was gained over the course of the charge.
     
  6. kernelRiot

    kernelRiot New Member This Topic's Starter

    Joined:
    Aug 8, 2010
    Messages:
    4
    Likes Received:
    0
    For that case, my program would actually show "2.633 hours" because 9,480 seconds is both greater than 60 seconds and greater than 60 minutes. I suppose I could add in something if you charged for longer than 24 hours, but I don't think that's a normal case.
     
  7. jackattack

    jackattack Well-Known Member

    Joined:
    Oct 28, 2009
    Messages:
    51
    Likes Received:
    6
    I'd be interested in seeing this profile written out. Sounds like a cool idea!
     
  8. jshugart

    jshugart New Member

    Joined:
    Feb 8, 2011
    Messages:
    2
    Likes Received:
    0

Share This Page

Loading...