Tasker can't distinguish between power ac and usb

541 views
Skip to first unread message

Vala

unread,
Dec 27, 2017, 5:30:56 PM12/27/17
to Tasker
On my pixel 2 (8.1), tasker activates the profile with power source > USB condition even if I connect the phone to the AC adapter that charges rapidly. In fact, it doesn't even detect power ac.

Rich D

unread,
Dec 27, 2017, 9:23:57 PM12/27/17
to Tasker Google Groups Post

On my pixel 2 (8.1), tasker activates the profile with power source > USB condition even if I connect the phone to the AC adapter that charges rapidly. In fact, it doesn't even detect power ac.

The power AC context works on my pixel 2 even with the rapid charge charger. I am still  on 8.0 (still scared to update :) ) 

Hopefully someone else with 8.1 can confirm this issue. 

Vala

unread,
Dec 28, 2017, 2:00:57 AM12/28/17
to Tasker
Does usb also activate if you plug into ac?

Rich D

unread,
Dec 28, 2017, 8:21:54 AM12/28/17
to Tasker Google Groups Post

Does usb also activate if you plug into ac?


Yes it does. This happens on my pixel c tablet  as well. I believe the way it is detected varies by manufacturer. 

If you can get the charging amps you could filter this within the task. 

It appears the battery info is available through a Java function with (BatteryManager) but I have little to no Java knowledge.  I will try to figure this one out and post back here if I get it. Or If a Java savvy passer-by happens to see this and posts a solution that might save a few days/weeks... :)

Rich D

unread,
Dec 28, 2017, 2:12:39 PM12/28/17
to Tasker Google Groups Post
Well, seems I am getting better at this.

Here is a Java function task that will give you the amps from or too the battery.  So you should be able to test within the task if the amps are from ac charging or USB charging. 

Get Amps Java (677)
A1: Java Function [ Return:mybatt Class Or Object:BatteryManager Function:new
{BatteryManager} () Param: Param: Param: Param: Param: Param: Param: ] 
A2: Java Function [ Return:%myamps Class Or Object:mybatt Function:getIntProperty
{int} (int) Param:2 Param: Param: Param: Param: Param: Param: ] 
A3: Flash [ Text:%myamps Long:Off ] 

Get_Amps_Java.tsk.xml

Vala

unread,
Dec 28, 2017, 10:16:42 PM12/28/17
to Tasker
Thank you so much. This really helps. Interestingly, the returned value when connected to ac is negative which according to here is:
"negative values indicate net current discharging from the battery." but the battery is charging obviously. when connected to usb the value is positive.

Rich D

unread,
Dec 28, 2017, 10:25:15 PM12/28/17
to Tasker Google Groups Post

Thank you so much. This really helps. Interestingly, the returned value when connected to ac is negative which according to here is:
"negative values indicate net current discharging from the battery." but the battery is charging obviously. when connected to usb the value is positive.

--

Yea, it seems device specific. I get negative on the discharge on my pixel c  and positive on the discharge on my Piven 2 xl. 

francwalter

unread,
Jan 5, 2018, 4:20:08 PM1/5/18
to Tasker
This just shows 0 when charging on my Cubot Note Plus with Android 7.0
But I scrutinized a bit in the battery folders and found this file:
/sys/devices/platform/battery/power_supply/battery/BatteryAverageCurrent
and here I found values which could be the real actual charging current.
Values like e.g. 951 or 923 etc.

I am looking for any tool simply showing me the actual charging current because I have often problems with cheap chargers or cables.
Any app on the Google Play Market will show only 0 as this java Task here too.


Jonathon Amsbaugh

unread,
May 28, 2024, 11:31:07 AMMay 28
to Tasker
This just shows 0 when charging on my Cubot Note Plus with Android 7.0
But I scrutinized a bit in the battery folders and found this file:
/sys/devices/platform/battery/power_supply/battery/BatteryAverageCurrent
and here I found values which could be the real actual charging current.
Values like e.g. 951 or 923 etc.

I am looking for any tool simply showing me the actual charging current because I have often problems with cheap chargers or cables.
Any app on the Google Play Market will show only 0 as this java Task here too.

Reply all
Reply to author
Forward
0 new messages