I've noticed longer usb cables provide lower voltage and would like to make a task that warns me when it's too low to charge my phone properly.
An app called "Android battery dog" can show me this information but I can't seem to get it in tasker.
Please help :)
The output looks like this:
Nr;TimeMillis;level;scale;voltage;temperature;plugged;status;health;present;technology;icon-small
1;1375483781718;40;100;4011;171;1;2;2;true;Li-ion;17302813
2;1375483829835;40;100;3995;183;1;2;2;true;Li-ion;17302813
3;1375483882914;41;100;4002;195;1;2;2;true;Li-ion;17302813
4;1375483918897;42;100;3999;197;1;2;2;true;Li-ion;17302813
5;1375483925923;42;100;3889;194;0;4;2;true;Li-ion;17302799
6;1375483932252;42;100;3868;192;1;2;2;true;Li-ion;17302813
7;1375483934761;42;100;3920;192;1;2;2;true;Li-ion;17302813
8;1375483993962;41;100;3894;187;1;2;2;true;Li-ion;17302813
9;1375484054039;41;100;3892;183;1;2;2;true;Li-ion;17302813
10;1375484114219;42;100;3885;181;1;2;2;true;Li-ion;17302813
11;1375484174354;42;100;3876;180;1;2;2;true;Li-ion;17302813
12;1375484234521;42;100;3895;178;1;2;2;true;Li-ion;17302813
13;1375484247770;42;100;3859;178;1;2;2;true;Li-ion;17302813
14;1375484277265;42;100;3835;179;0;4;2;true;Li-ion;17302799
16;1375484337470;42;100;3818;177;0;4;2;true;Li-ion;17302799
17;1375484360041;42;100;3817;175;1;2;2;true;Li-ion;17302813
18;1375484419998;43;100;4025;180;1;2;2;true;Li-ion;17302813
19;1375484480132;43;100;4044;180;1;2;2;true;Li-ion;17302813
20;1375484540306;44;100;4049;180;1;2;2;true;Li-ion;17302813
21;1375484600479;45;100;4056;180;1;2;2;true;Li-ion;17302813
22;1375484660610;45;100;4062;180;1;2;2;true;Li-ion;17302813
23;1375484720792;46;100;4066;180;1;2;2;true;Li-ion;17302813
24;1375484780954;47;100;4073;180;1;2;2;true;Li-ion;17302813
25;1375484841107;48;100;4074;180;1;2;2;true;Li-ion;17302813
26;1375484901243;48;100;4079;180;1;2;2;true;Li-ion;17302813
27;1375484961424;49;100;4083;180;1;2;2;true;Li-ion;17302813
28;1375485021589;50;100;4088;180;1;2;2;true;Li-ion;17302813
29;1375485081723;50;100;4091;180;1;2;2;true;Li-ion;17302813
30;1375485141910;51;100;4094;180;1;2;2;true;Li-ion;17302813
31;1375485202064;52;100;4100;180;1;2;2;true;Li-ion;17302813
32;1375485262224;53;100;4102;179;1;2;2;true;Li-ion;17302813
33;1375485382548;54;100;4113;179;1;2;2;true;Li-ion;17302813
34;1375485442857;55;100;4113;179;1;2;2;true;Li-ion;17302813
35;1375485502854;55;100;4115;178;1;2;2;true;Li-ion;17302813
36;1375485563031;56;100;4120;178;1;2;2;true;Li-ion;17302813
1;1375485605302;56;100;4120;178;1;2;2;true;Li-ion;17302813
2;1375485623156;57;100;4117;178;1;2;2;true;Li-ion;17302813
3;1375485643877;57;100;4091;178;1;2;2;true;Li-ion;17302813
3;1375485659028;57;100;4091;178;1;2;2;true;Li-ion;17302813
It seems the voltage is the fifth colon separated value on each line.
New question:
How can I extract just the most recent recorded voltage?
> Is it possible to have tasker monitor the incoming voltage and warn me if it's below 4 volts while charging my phone? (HTC one PN07140)
Have you tried to look in the shell dumpsys info. You will most likely need root but it might be in there..
Are you rooted?
So far I've managed to trim the .csv into a variable using this task, it's probably not the best method, but it seems to be working.
<TaskerData sr="" dvi="1" tv="4.1u3m">
<Task sr="task25">
<cdate>1375485881824</cdate>
<edate>1375495978443</edate>
<id>25</id>
<nme>Voltage Check</nme>
<pri>10</pri>
<Action sr="act0" ve="3">
<code>30</code>
<Int sr="arg0" val="0"/>
<Int sr="arg1" val="10"/>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
<Int sr="arg4" val="0"/>
</Action>
<Action sr="act1" ve="3">
<code>417</code>
<Str sr="arg0" ve="3">BatteryDog/battery.csv</Str>
<Str sr="arg1" ve="3">%VOLT</Str>
</Action>
<Action sr="act2" ve="3">
<code>115</code>
<Int sr="arg0" val="11"/>
<Str sr="arg1" ve="3">%VOLT</Str>
<Str sr="arg2" ve="3">%VOLTLENGTH</Str>
</Action>
<Action sr="act3" ve="3">
<code>547</code>
<Str sr="arg0" ve="3">%VOLTLENGTHTRIM</Str>
<Str sr="arg1" ve="3">%VOLTLENGTH - 35</Str>
<Int sr="arg2" val="1"/>
<Int sr="arg3" val="0"/>
</Action>
<Action sr="act4" ve="3">
<code>597</code>
<Str sr="arg0" ve="3">%VOLT</Str>
<Int sr="arg1">
<var>%VOLTLENGTHTRIM</var>
</Int>
<Int sr="arg2">
<var>25</var>
</Int>
<Int sr="arg3" val="1"/>
<Str sr="arg4" ve="3">%VOLT</Str>
</Action>
<Action sr="act5" ve="3">
<code>597</code>
<Str sr="arg0" ve="3">%VOLT</Str>
<Int sr="arg1" val="1"/>
<Int sr="arg2" val="4"/>
<Int sr="arg3" val="1"/>
<Str sr="arg4" ve="3"/>
</Action>
<Action sr="act6" ve="3">
<code>548</code>
<Str sr="arg0" ve="3">%VOLT</Str>
<Int sr="arg1" val="0"/>
</Action>
<Action sr="act7" ve="3">
<code>523</code>
<lhs>%VOLT</lhs>
<op>3</op>
<rhs>3950</rhs>
<Str sr="arg0" ve="3">Connect to a different power source</Str>
<Str sr="arg1" ve="3">Voltage: %VOLT</Str>
<Img sr="arg2" ve="2"/>
<Int sr="arg3" val="0"/>
<Int sr="arg4" val="0"/>
<Int sr="arg5" val="3"/>
</Action>
</Task>
</TaskerData>
> So far I've managed to trim the .csv into a variable using this task, it's probably not the best method, but it seems to be working.
To export your task select "Copy description to clip board" Not "XML"
Voltage Check (25)
A1: Wait [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ]
A2: Read File [ File:BatteryDog/battery.csv To Var:%VOLT ]
A3: Test [ Type:Variable Length Data:%VOLT Store Result In:%VOLTLENGTH ]
A4: Variable Set [ Name:%VOLTLENGTHTRIM To:%VOLTLENGTH - 35 Do Maths:On Append:Off ]
A5: Variable Section [ Name:%VOLT From:%VOLTLENGTHTRIM Length:25 Adapt To Fit:On Store Result In:%VOLT ]
A6: Variable Section [ Name:%VOLT From:1 Length:4 Adapt To Fit:On Store Result In: ]
A7: Flash [ Text:%VOLT Long:Off ]
A8: Notify Sound [ Title:Connect to a better power source Text:Voltage: %VOLT Icon:null Number:0 Sound File:Ringtones/hangouts_message.ogg Priority:3 ] If [ %VOLT < 3950 ]
A9: If [ %VOLT < 3950 ]
A10: Wait [ MS:0 Seconds:30 Minutes:0 Hours:0 Days:0 ]
A11: Goto [ Type:Action Number Number:1 Label: ]
That's not bad, what do you mean by sort of works? The other way you can do it is this
1. Read file to %volt
2. Variable split %volt splitter ;
3 variable set %index to %volt(#)-8
4. Variable set %voltsin to %volt(%index)
That should work as well
How long is that file?
I would suggest using all local variables, it will be faster and much more memory friendly..
Rich..
> 3 variable set %index to %volt(#)-8
For this action make sure you check 'do maths' in the variable set action
You can check out array functions in the variables section of the user guide. :)
This could be a Good argument for a feature request to pent to give us a "read last line" option in the "Read line" action. Or perhaps a "# of lines" in the test / file action.
> This could be a Good argument for a feature request to pent to give us a "read last line" option in the "Read line" action. Or perhaps a "# of lines" in the test / file action.
OR... a shell command could some how appear..... Thanks Tom..
This will make the array much smaller, Tom's shell command will get the last line of your file, so now it would be ..
1: Run Shell ; Command:tail -n 1 yourfile Store Output In:%volt
2. Variable split %volt splitter ;
3 variable set %index to %volt(#)-8
4. Variable set %voltsin to %volt(%index)
Wala .... there ya go...
Rich..
>
> So close Rich, missed it by that (-) much...
>
> Should be:
> Run Shell ; Command:tail -n-1 yourfile Store Output In:%volt
Hmmmm, what is the - before the 1 do? I tested with and without it and they both work...
The battery.csv log file is getting longer and longer. So I'm going to add a step to clean it before getting the voltage value.
Currently script "sort of works" because it doesn't know when the last voltage value was stored, it could read old data and set off the low voltage alert.
Unfortunately the shell command "tail -n-1 /sdcard/batterydog/battery.csv" returns the error
/system/bin/sh: tail: not found
Probably because I'm not rooted yet.
> The battery.csv log file is getting longer and longer. So I'm going to add a step to clean it before getting the voltage value.
How are you going to clean it? By just deleting it?
>
> Currently script "sort of works" because it doesn't know when the last voltage value was stored, it could read old data and set off the low voltage alert.
Will the app update the file when it is launched?
There is a misc / test / file modified action that should be able to tell you if there is current info in the file..
I would contact the developer and find out exactly how and when the file gets updated. You can also suggest to them making a tasker plug in. I was looking for the same info before I rooted and could not find it any where, I have not checked in a while but I think it would be the first app that would offer such data to the non rooted crowd. And if they check the sales of tasker I would think it would be a easy decision ..
If you do figure it out please post back for others..
>
> Unfortunately the shell command "tail -n-1 /sdcard/batterydog/battery.csv" returns the error
>
It does work without root but you might be missing something that comes with busy box. However if you are cleaning the file then it should not be necessary. I would just use the array approach I mentioned with local variables..
Rich..
--
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.
> for voltage battery i'm using shell command: cat /sys/class/power_supply/battery/device/power_supply/battery/voltage_now
> use root \/
> store outputn in %VOLTAGES
Cool... That works for me without the use root checked..
Thanks Konstantin.......
--
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.
This script works but it keeps complaining about low voltage until a minute after you've connected to a better power source.
Voltage Check (25)
A1: Wait [ MS:0 Seconds:20 Minutes:0 Hours:0 Days:0 ]
A2: Test [ Type:File Modified Data:/sdcard/BatteryDog/battery.csv Store Result In:%BATTDOGDATE ]
A3: If [ %TIMES-60 < %BATTDOGDATE ]
A4: Read File [ File:/sdcard/BatteryDog/battery.csv To Var:%VOLT ]
A5: Test [ Type:Variable Length Data:%VOLT Store Result In:%VOLTLENGTH ]
A6: Variable Set [ Name:%VOLTLENGTHTRIM To:%VOLTLENGTH - 35 Do Maths:On Append:Off ]
A7: Variable Section [ Name:%VOLT From:% Length:1 Adapt To Fit:Off Store Result In: ]
A8: Variable Section [ Name:%VOLT From:1 Length:4 Adapt To Fit:Off Store Result In: ]
A9: Flash [ Text:%VOLT Long:Off ]
A10: If [ %VOLT < 3950 ]
A11: Notify Sound [ Title:Connect to a better power source Text:Voltage: %VOLT Icon:null Number:0 Sound File:Ringtones/hangouts_message.ogg Priority:3 ] If [ %VOLT < 3950 ]
A12: Wait [ MS:0 Seconds:30 Minutes:0 Hours:0 Days:0 ]
A13: Goto [ Type:Action Number Number:1 Label: ]
A14: Variable Section [ Name:%VOLT From:%VOLTLENGTHTRIM Length:25 Adapt To Fit:On Store Result In:%VOLT ]
I tried using variable split but I ended up with over 10,000 variables because I wanted to continue using battery dog (it's got nice graphs)
My final solution will probably be to root
>
> My final solution will probably be to root
Never say die...... :)
I just tried this and it worked on my device.. just use the tasker "Read File" action with this file path..
/sys/class/power_supply/battery/device/power_supply/battery/voltage_now
Rich...
But test > date modified does not, so I can't be sure if it's up to date without splitting a timestamp out of the %VOLT variable.
On a battery related note, my battery drains about 13% in 45 minutes just by using tasker and chrome.
> Read file works on /sys/class/power_supply/battery/device/power_supply/battery/voltage_now
Great
>
> But test > date modified does not, so I can't be sure if it's up to date
I believe the value in that file is always the most up to date. I also believe it is where the app gets its data.
>
> On a battery related note, my battery drains about 13% in 45 minutes just by using tasker and chrome.
>
Do you think it is tasker or chrome. ? Does tasker show up in your android battery usage?
Check your tasker run log for repeating tasks. Sounds like there may be a better way to run what you're looking to do with tasker.
As proof, I've included a screenshot link showing my battery usage with chrome and tasker. You can see my phone idle, and even Bluetooth use consume more battery... and I have several profiles that interact with chrome.
--
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.