Do States consume more battery than Events?

1,263 views
Skip to first unread message

Mickets

unread,
Aug 11, 2011, 6:35:57 PM8/11/11
to Tasker
Hello,

Following a situation I described on this thread:
https://groups.google.com/group/tasker/t/f3b214fcc146810d

I'm setting up profiles based on Locations, States and Events. Since
States and Events can happen at more than one Location.

States: %MYNEAR = near a cell antenna, %MYIN = in a Location (network
and/or GPS), %MYWIFI = near a known WiFi spot, %MYCONNECT = Connected
to a WiFi spot.


Obviously, if the phone is connected to WiFi (%MYCONNECT), then it
doesn't matter if for some reason it loses phone signal (%MYNEAR),
some Events or States have higher priority then others.

I did it more or less this way:

Near Cell Antenna: %MYNEAR = 1
In Location: %MYIN = 2
Near Wifi: %MYWIFI = 4
Connected: %MYCONNECT = 8

%MYPLACE = Sum of all above.

So if phone is still connected, even if it loses one or more of the
other lower States the value of %MYPLACE will always be higher than if
it were not connected. And the same applied to any other situation
(the higher priority states have higher values).


Start: %MYPLACE = 0, %MYNEAR = 0, %MYIN=0, %MYWIFI=0, %MYCONNECT=0



Profile 1:

Context: Near Office, %MYPLACE < 1
Enter Task: Set %MYNEAR = 1, Set %MYPLACE =%MYNEAR + %MYIN + %MYWIFI +
%MYCONNECT
Exit Task: Set %MYNEAR = 0

(and similar for various other profiles based on (Near Cell or
Location) + Variable States


Once I set up a number of similar profiles like this, I noticed that
Tasker was consuming up to ~18% of the battery. So then I imagined if
this could be because Tasker has to keep monitoring a number of
different variable states and locations.

I was wondering that if this is true, then instead of using Variable
States as the primary trigger for tasks, I should instead use Events,
that are instantaneous. Something like this:


Profile 1:
Context: Near Office Cell
Enter Task: Set %MYNEAR = 1, SET %MYLOCATION = 20 (20 = office)
Exit Task: Set %MYNEAR = 0

Profile 2:
Context: In Office Location (GPS and / or Net)
Enter Task: Set %MYIN = 2, SET %MYLOCATION = 20 (20 = office)
Exit Task: Set %MYIN = 0

Profile 3:
Context: Near Office WiFi
Enter Task: Set %MYWIFI = 4, SET %MYLOCATION = 20 (20 = office)
Exit Task: Set %MYWIFI = 0

Profile 4:
Context: Connected to WiFi Office
Enter Task: Set %MYCONN = 8, SET %MYLOCATION = 20 (20 = office)
Exit Task: Set %MYCONN = 0

etc. (same for Profiles near home, in home location, near home Wifi,
connected)

Profile Variable Event
Context: %MYNEAR is set
Enter Task: SET %MYPLACE = %MYNEAR + %MYIN + %MYWIFI + %MYCONNECT

Profile Variable Event
Context: %MYIN is set
Enter Task: SET %MYPLACE = %MYNEAR + %MYIN + %MYWIFI + %MYCONNECT

Profile Variable Event
Context: %MYWIFI is set
Enter Task: SET %MYPLACE = %MYNEAR + %MYIN + %MYWIFI + %MYCONNECT

Profile Variable Event
Context: %MYCONNECT is set
Enter Task: SET %MYPLACE = %MYNEAR + %MYIN + %MYWIFI + %MYCONNECT

Profile Variable Event
Context: %MYPLACE is set
Enter Task: Run Task MYTASKCHANGE

Task MYTASKCHANGE:

IF
IF %MYPLACE > 21
IF %MYPLACE > 29
RUN TASK: SET OFFICE MODE PARAMETRES
STOP
END IF
IF
IF %MYPLACE > 11
IF %MYPLACE < 19
RUN TASK: SET HOME MODE PARAMETRES
STOP
END IF


etc...


I may be going a long way round, but I need some advice.

Many thanks,

Mickets







Pent

unread,
Aug 12, 2011, 4:51:24 AM8/12/11
to Tasker
Power usage is virtually always based on the underlying sensors that
Tasker needs to enable to monitor the state/event/location/whatever.

The type of context is not directly relevant.

Have a look at the Power Usage section of the userguide.

In the profiles you described, the vast majority of power usage will
come from wifi near / gps location. You should do your best only to
enable those when necessary e.g. by adding a less power-hungy context.

Tasks that loop can also consume a lot of power, but I guess you don't
have any of those.

Pent

Mickets

unread,
Aug 12, 2011, 9:04:20 AM8/12/11
to Tasker
Hmmm... OK. I set level 1 to locate via cell antenna, 2 via network or
GPS, 3 Wi-Fi, and 4 Wi-Fi connected. Once the level is above 2, APN is
turned off. But 3 and 4 are always looking at the Wi-Fi, so maybe
these could be the culprits.

I re-made all the tasks and profiles, and set it up as above. But now
battery usage by Tasker is ~30%. Battery going down fast.

WHen I'm at home or in an office I leave Wi-Fi on anyway, and never
noticed the battery go down so fast. I guess I'll have to find a way
to make Tasker not check the Wi-Fi Near / Connected status so often.

Mickets

Dave Fisher

unread,
Aug 12, 2011, 9:14:07 AM8/12/11
to tas...@googlegroups.com
For what its worth, I use Cell Near to determine when I am close to a location, which then enables WiFi. I just let the phone connect to the WiFi of its own accord once I reach my actual destination (work, home, hotel, friends, parents etc), then use WiFi Connected to trigger whatever profile for that location that I need.

I turn off WiFi when I leave the Cell, unless I am connected to the WiFi, then I leave it on.

I can't say I have ever seen Tasker in the battery usage results on my phone (which currently shows Phone Idle at the bottom at 5%)!


Pent if you read this, I haven't had a chance to do the debugging yet, don't worry i haven't forgotten though!


Mickets <ml...@gmx.com> wrote :

Pent

unread,
Aug 12, 2011, 9:33:09 AM8/12/11
to Tasker
> I re-made all the tasks and profiles, and set it up as above. But now
> battery usage by Tasker is ~30%. Battery going down fast.
>
> WHen I'm at home or in an office I leave Wi-Fi on anyway, and never
> noticed the battery go down so fast. I guess I'll have to find a way
> to make Tasker not check the Wi-Fi Near / Connected status so often.

Wifi connected has near-zero battery implications, it's just a signal
sent by Android when the connection status changes.

The WifiNear/Location poll time is configurable, see the Power Usage
doc. It's also possible your continually re-running a particular task
because your profile conditions are circular. Try putting a debugging
notification in at the top of the tasks, or do a Write File to keep a
log of what's running, what the variable values are etc.

Pent

Mickets

unread,
Aug 12, 2011, 11:09:22 AM8/12/11
to Tasker
Pent and Dave Fisher,

I posted a topic with a flowchart of my setup here:
https://groups.google.com/group/tasker/t/ac26f0ef243b5795

Many thanks,

Michael

Pent

unread,
Aug 12, 2011, 2:22:06 PM8/12/11
to Tasker
> I posted a topic with a flowchart of my setup here:https://groups.google.com/group/tasker/t/ac26f0ef243b5795

Did you try logging the task running and variable values ?

Pent

Mickets

unread,
Aug 12, 2011, 2:53:01 PM8/12/11
to Tasker
Yes, I did. But it's thousands of lines long and hard to read on the
phone, so I'll take a closer look later on, on a bigger screen...

Thanks,

Michael

Pent

unread,
Aug 13, 2011, 3:44:02 AM8/13/11
to Tasker
> Yes, I did. But it's thousands of lines long and hard to read on the
> phone, so I'll take a closer look later on, on a bigger screen...

If it's thousands of line long that's probably a bad sign.

Pent

Mickets

unread,
Aug 16, 2011, 10:38:47 AM8/16/11
to Tasker
Well, it was thousands of lines long. But then I noticed I had
wordwrap enabled on my phone's text editor.

But I'm still concerned now because I logged again for less than 10
minutes, and the log still has 4800 lines, which falls within the
"thousands", so there must be something wrong, I suspect.

About the last issue, I tweaked some things, and eliminated the %MYIN
status (in location - as it would often be inaccurate).

I think I may have solved the battery usage issue. I'm not sure how,
but it's much lower now. Maybe it was just me fiddling around with
Tasker that was causing the battery usage, although I don't really
think so.

I logged a couple of files again, to try and tackle another problem: I
setup two profiles:

a) if %MYSTATUS > 2 then Enable WiFi
b) if Near Office WiFi, then SET %MYWIFI = 4

Once a) has happened, WiFi is turned on. It finds the WiFi connection,
%MYWIFI is set to 4. But soon after, WiFi is turned off.

I can't figure out why yet, even looking at the log.

I'll try and figure it out.

Michael

Pent

unread,
Aug 16, 2011, 10:59:49 AM8/16/11
to Tasker
> But I'm still concerned now because I logged again for less than 10
> minutes, and the log still has 4800 lines, which falls within the
> "thousands", so there must be something wrong, I suspect.

What's causing all the logging ?

Pent

Mickets

unread,
Aug 16, 2011, 5:34:15 PM8/16/11
to Tasker
OK, I transfered the file to my laptop and opened it with a proper
text editor. It seems that not all events are logged by tasker.

For instance, in the lines below, I believe only the two first ones
are from Tasker, and the rest from the Android system:

16-08-2011 Tasker: 12.01.56#Tasker: onresume done
16-08-2011 Tasker: 12.02.03#Tasker: enabled: true running: true
needrestart: true
16-08-2011 WakeLockManager: 12.02.03#WakeLockManager: acquired lock
for M autorelease: true warn: true
16-08-2011 M: 12.02.03#M: pi: time since last process end: 94858,
reset qcpt
16-08-2011 M: 12.02.03#M: process inbox, size 0 startID: 108
16-08-2011 M: 12.02.03#M: extra: eventType: 9995
16-08-2011 M: 12.02.03#M: -------RESTART --------
16-08-2011 M: 12.02.03#M: tidyup
16-08-2011 M: 12.02.06#M: rewrite rec
16-08-2011 M: 12.02.06#M: stop monitors
16-08-2011 M: 12.02.06#M: PSTATE: monitor stop
16-08-2011 M: 12.02.06#M: unreg receivers
16-08-2011 M: 12.02.06#M: destroy cals
16-08-2011 M: 12.02.06#M: tidy up done
16-08-2011 M: 12.02.06#M: set initial wifi timeout to 20000ms (max)
16-08-2011 M: 12.02.08#M: struct
16-08-2011 M: 12.02.08#M: scan data
16-08-2011 M: 12.02.08#M: done cals
16-08-2011 M: 12.02.08#M: rescan vars
16-08-2011 M: 12.02.08#M: rescan monitor vars
16-08-2011 M: 12.02.08#M: rescan done
16-08-2011 M: 12.02.08#M: needed monitor vars:
16-08-2011 M: 12.02.08#M: recalc action set
16-08-2011 M: 12.02.08#M: receivers
16-08-2011 M: 12.02.08#M: register receiver action:
android.intent.action.BATTERY_CHANGED
16-08-2011 M: 12.02.08#M: register receiver action:
android.net.conn.CONNECTIVITY_CHANGE
16-08-2011 M: 12.02.08#M: register receiver action:
android.intent.action.PHONE_STATE
(...)

It's a lot of messages per second, so I was concerned that it was all
caused by Tasker, but maybe I was wrong all along.

About the battery usage increasing, over the weekend I did some tests
and:

- Once the battery usage was high, I disabled each profile in a
binary way (disable one half, observe, disable half of the remainder,
etc) to track if one certain profile was causing the problem. I
expected the battery usage to decrease once all profiles had been
disabled. But it never did - it still remained high.
- Since disabling the profiles didn't result in battery usage
decreasing, I made sure the polling values were the default ones, as
maybe the polling was too intense for some reason. But the values were
already default, and nothing changed.
- Battery usage ceased once I turned Tasker off, as expected.
- With Tasker on again, and profiles enabled, usage started to
increase.

I think that the high usage has been sorted out now, as currently it's
at 7.8% (much lower than I reported initially). But I did find it
strange that the usage didn't decrease as I disabled the profiles.

Thanks again for your attention, and apologies for the inconvenience.

Michael

Pent

unread,
Aug 17, 2011, 3:06:42 AM8/17/11
to Tasker
> For instance, in the lines below, I believe only the two first ones
> are from Tasker, and the rest from the Android system:

No, it's all different parts of Tasker.

> It's a lot of messages per second, so I was concerned that it was all
> caused by Tasker, but maybe I was wrong all along.

If it's like that constantly you should send me a bigger section of
log so I can have a look.

Pent

Mickets

unread,
Aug 17, 2011, 9:14:11 AM8/17/11
to Tasker
Yes, it's constantly like that. I'll e-mail you a section later on.

Michael

Pent

unread,
Aug 19, 2011, 11:59:15 AM8/19/11
to Tasker
> Yes, it's constantly like that. I'll e-mail you a section later on.

Ah, it's because you've got a few power and cell states, it all looks
normal.

Probably the logging is taking a good chunk of power :-)

Pent

p.s. I recommend upgrading Tasker too

BossMan

unread,
Aug 19, 2011, 12:09:03 PM8/19/11
to tas...@googlegroups.com

> Probably the logging is taking a good chunk of power :-)

BTW, Pent - did you consider adding some kind of control to the logging mechanism? Tasker outputs a huge amount of logging info (and it's getting larger with every release), but usually we're interested in only some parts. Could you consider adding maybe a control of the logging on the functional level (e.g. particular monitors/task execution or something like that), or at least - a usual error/warning/debug/info etc. levels? :)

BR,
A.

Mickets

unread,
Aug 19, 2011, 12:21:35 PM8/19/11
to Tasker
Glad to know it's OK.

Once I trimmed and reviewed my setting, and let it run (without me
constantly looking at it), the power usage seems OK most times (3% to
7%). At this moment it's up to 13% maybe because of a Task I just
added and didn't finish configuring yet.

Yes, I'll update. Right now in fact.

Thanks a lot,

Michael

Pent

unread,
Aug 19, 2011, 12:25:07 PM8/19/11
to Tasker
> BTW, Pent - did you consider adding some kind of control to the logging
> mechanism? Tasker outputs a huge amount of logging info (and it's getting
> larger with every release), but usually we're interested in only some parts.
> Could you consider adding maybe a control of the logging on the functional
> level (e.g. particular monitors/task execution or something like that), or
> at least - a usual error/warning/debug/info etc. levels? :)

I want to add individual context activation changes and task start/
ends to the 'profile activation log'.

I'm going to take the other diagnostic logging out of the stable
releases sometime soon to save (lots of) space. The warning/errors
will remain.

Pent

Mickets

unread,
Aug 19, 2011, 1:00:40 PM8/19/11
to Tasker
Just for interest, with CatLog and with Tasker logging to the system
log, one can filter by keyword "Tasker" and watch the log in real time
in nice colors. Maybe no news for you folks, but for me it's much
easier than browsing through a long plain text file.

ML
Reply all
Reply to author
Forward
0 new messages