Say battery percentage every 10 percent

947 views
Skip to first unread message

lear peleg

unread,
Aug 2, 2013, 12:45:35 PM8/2/13
to tas...@googlegroups.com
I want to. Make a profile that uses say function to say the battery percentage while charging but only one the second number is 0..I thought about dividing it by 10 and when theres no remainder to say.. But I couldn't quiet figure out how to..
Help anyone?

Rob Rogers

unread,
Aug 2, 2013, 12:51:50 PM8/2/13
to tas...@googlegroups.com

What you want is the modulus, which you can get with the % symbol.

It's as simple as setting a variable to %BATT % 10 and checking if that variable is 0.

On Aug 2, 2013 9:45 AM, "lear peleg" <lear....@gmail.com> wrote:
I want to. Make a profile that uses say function to say the battery percentage while charging but only one the second number is 0..I thought about dividing it by 10 and when theres no remainder to say.. But I couldn't quiet figure out how to..
Help anyone?

--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/groups/opt_out.


lear peleg

unread,
Aug 2, 2013, 1:47:31 PM8/2/13
to tas...@googlegroups.com
Profile: Battery Level x0, x0 (73)
State: Power [ Source:Any ]
Enter: Battery Percentage (74)
A1: Say [ Text:Battery label is %BATT percent Engine:Voice:default:default Stream:3 Pitch:5 Speed:5 Continue Task Immediately:Off ] If [ %BATT % 10 ~ 0 ]


Here.. That's what I did.. It didn't work..

Rob Rogers

unread,
Aug 2, 2013, 2:07:07 PM8/2/13
to tas...@googlegroups.com

The task looks good, but once a state becomes active it will run the task once. In other words, this will only speak once, and only if your battery level ends in 0 as soon as you plug it in.

You want to add an event context of Variable Set: %BATT so it will run again every time the battery level changes.

Bob Hansen

unread,
Aug 2, 2013, 2:14:44 PM8/2/13
to tas...@googlegroups.com
This doesn't work because there is nothing to periodically periodically check the battery level.

Try the following: 
note: the profile name change; 
        addition of code to keep it from repeatedly saying the level if the battery level stays at a level evenly divisible by 10 - like when fully charged (100%)

Profile: Say Battery Level x0, x0 (73)

        State: Power [ Source:Any ]
Enter: Battery Percentage (74)
        A1: Variable Set %lastcheck To: %BATT
        A2: If %lastcheck != %BATT 
        A3: Say [ Text:Battery label is %BATT percent Engine:Voice:default:default Stream:3 Pitch:5 Speed:5 Continue Task Immediately:Off ] If [ %BATT % 10 ~ 0 ]
        A4: End If
        A2: Wait 1 minute
        A3: Goto 2  If %PACTIVE ~ *,Say Battery Level x0,*

Mike L

unread,
Aug 2, 2013, 2:44:50 PM8/2/13
to tas...@googlegroups.com
I didn't know you could do math in an 'if' statement. Never tried to, but good to know.
This should work:

<Start>
A1: Anchor 
A2: Wait Until [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ] If [ %BATT % 10 = 0 ]
A3: Say [ Text:Whatever Engine:Voice:default:default Stream:3 Pitch:5 Speed:5 Continue Task Immediately:Off ] 
A4: Variable Set [ Name:%set To:%BATT Do Maths:Off Append:Off ] 
A5: Wait Until [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ] If [ %set != %BATT ]
A6: Goto [ Type:Action Label Number:1 Label:Start ] 

Wes Stacey

unread,
Aug 2, 2013, 2:47:51 PM8/2/13
to tas...@googlegroups.com
Honestly guys, your making it more difficult than it needs to be.

Tasker is a computer program...so while it's tempting to get it all into a single profile you waste SO much computer time running the task over and over again.


In all honestly the simplest thing for a computer is to run 1 command as soon as the battery reaches a certian level.

So while it looks more complex to us humans it will be MUCH easier to tasker to run if you just ahve 10 serarate profiles each triggered by 1 batery percentage. just make 10 profiles like the following just change the context and have them all run the same task.

Profile: 90% (244)
State: Battery Level [ From:89 To:90 ]
State: Power [ Source:Any ]
Enter: Battery Percentage (74)
        A1: Say [ Text:Battery label is %BATT percent Engine:Voice:default:default Stream:3 Pitch:5 Speed:5 Continue Task Immediately:Off ] If [ %BATT % 10 ~ 0 ]

And that's it. simple to create simple to understand and most of all simple for tasker which will be much better for your battery life

NOTE: for 100% just have 1-99 and invert it (so only 100% remains)

Bob Hansen

unread,
Aug 2, 2013, 3:09:16 PM8/2/13
to tas...@googlegroups.com
Never thought of doing it that way. Thanks Wes!

lear peleg

unread,
Aug 2, 2013, 3:15:17 PM8/2/13
to tas...@googlegroups.com
Actually that was the first version of this.. but I started organizing my profiles per project, and 10 different profiles for "speak" project sems a bit excessive..
I'll try it out and let you guys know if that works

בתאריך יום שישי, 2 באוגוסט 2013 21:47:51 UTC+3, מאת Wes Stacey:

lear peleg

unread,
Aug 2, 2013, 6:52:29 PM8/2/13
to tas...@googlegroups.com
Profile: Battery Level x0, x0 (73)
State: Power [ Source:Any ]
Enter: Battery Percentage (74)
A1: Variable Set [ Name:%LastBATT To:0 Do Maths:Off Append:Off ]
A2: If [ %PACTIVE ~R Battery Level x0, x0 ]
A3: Variable Set [ Name:%LastCheck To:%BATT % 10 Do Maths:On Append:Off ]
A4: If [ %LastCheck ~ 0 ]
A5: Say [ Text:%BATT percent Engine:Voice:default:default Stream:3 Pitch:5 Speed:5 Continue Task Immediately:Off ] If [ %LastBATT !~ %BATT ]
A6: Variable Set [ Name:%LastBATT To:%BATT Do Maths:Off Append:Off ]
A7: End If
A8: Wait [ MS:0 Seconds:30 Minutes:0 Hours:0 Days:0 ]
A9: Goto [ Type:Action Number Number:2 Label: ]
A10: End If
orks! But sometimes it wont realize the profile is off and tells the battery anyway.. But a reboot seems to do the trick

Anyhow.. This is the profile I made that works:

Bob Hansen

unread,
Aug 2, 2013, 7:08:51 PM8/2/13
to tas...@googlegroups.com
Add this action between A4 and A5 to stop it from talking after the contexxt is no longer valid (no power connected).
     Stop  If [ %PACTIVE !~R Battery Level x0, x0 ]  <== doesn't match regex

lear peleg

unread,
Aug 2, 2013, 7:15:27 PM8/2/13
to tas...@googlegroups.com
But A2 does just that, and the goto goes to A2 so why do I need to add another one?

Bob Hansen

unread,
Aug 2, 2013, 7:35:58 PM8/2/13
to tas...@googlegroups.com
A2 does the opposite of that. A2 confirms that the profile IS still active. The addition I am suggesting checks to see if the profile IS NOT active (that's why I said !~R which means 'not match regex') in which case you want to stop the task.
Message has been deleted

Rich D

unread,
Aug 2, 2013, 9:43:12 PM8/2/13
to tas...@googlegroups.com

> Simply use %BATT ~10 /20 /30..... upto 90 in profile STATE -  VARIABLE -  VARIABLE VALUE.

%BATT is not usable in a context...

sunil kolambkar

unread,
Aug 2, 2013, 10:02:26 PM8/2/13
to tas...@googlegroups.com
Use context power and time 24 hrs. Then get it repeat every 1 min. Or whatever you want.

In Say task check out the IF for %BATT ~10 /20 /30......upto /90.

So context will execute every min. But Say will happen only if battery % is 10 or 20 or....

Try this.

Sunil.

Brandon Horwath

unread,
Aug 2, 2013, 11:28:14 PM8/2/13
to tas...@googlegroups.com
Sunil,

I believe Wes's suggestion in combination with Rob's context, is the simplest, most minimal, and LEAST battery/computing intensive.

You have a good suggestion :-) and that should work.

but I think the objective now is to minimize tasker checks and activities with regards to this specific profile.

adam P

unread,
Jul 7, 2018, 8:22:47 AM7/7/18
to Tasker
Can someone please provide the final working setup (step by step if possible) for Say battery percentage every 10%.
Nothing working for me. Don't understand Enter: Battery Percentage (74) --- where I can find this?
Any help appreciate.

Marta Hintz

unread,
Jul 7, 2018, 10:00:43 AM7/7/18
to Tasker
In tasker --> task edit--> click on the plus sign. Notice a filter is at the bottom of the screen. In the you can search for stuff. Put in batt and battery info should appear. On my phone it is red, which means for my phone I don't have that capability.

Robert Ryan

unread,
Jul 7, 2018, 10:32:28 AM7/7/18
to tas...@googlegroups.com
You want to use the Battery Changed event context, whiich fires every time the battery level changes. In your task, use the modulus function %BATT % 10 so that the Say action only executes when %BATT is evenly divisible by 10.

    Profile: Say Battery (114)
        Event: Battery Changed
        
    Enter: Anon (115)
    A1: Say 
        Text: %BATT 
        Engine: Voice:default:default 
        Stream: 3 
        Pitch: 5 
        Speed: 5 
        Respect Audio Focus: On 
        Network: Off 
        Continue Task Immediately: Off
        If %BATT % 10 = 0


--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

Dale Smith

unread,
Jul 8, 2018, 5:17:13 AM7/8/18
to Tasker
All the way through the thread I kept saying to myself no use the battery changed context and one condition say action. It's gratifying to me that I'm starting to think like you Tasker wise Robert. Nice call.
Reply all
Reply to author
Forward
0 new messages