• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Using tasker to monitor battery

Here it is, with a list of changes that I could think of. I haven't had time to test the project separately from the rest of my stuff but hopefully I've copied in all the required content. Let me know if something doesn't work.

A note mainly for the other forum users, feel free to also use only bits that interest you, including the time converter and the logging platform...

https://drive.google.com/open?id=0B3R3a2WGs6rYWVpzWnNHc2xwWTg

I know this is a very old thread, but I really want to thank you because I find your work excellent and very useful. I added a setting scene and some thingies here and there, and I have also some ideas to improve the project. I know maybe it's not such a great thing I have done, but I'm pretty new to Tasker and I feel very proud of my work. :D If you don't mind, I'm going to build an apk and share it here in the next days, just because it could be useful to others. I will mention you inside it as creator and author of the basic code.
 
  • Like
Reactions: codesplice
Upvote 0
I know this is a very old thread, but I really want to thank you because I find your work excellent and very useful. I added a setting scene and some thingies here and there, and I have also some ideas to improve the project. I know maybe it's not such a great thing I have done, but I'm pretty new to Tasker and I feel very proud of my work. :D If you don't mind, I'm going to build an apk and share it here in the next days, just because it could be useful to others. I will mention you inside it as creator and author of the basic code.


Knock yourself out! Worst case scenario, it's a great exercise. ;)
Just don't forget to post a link to your app once you're done, others might be interested in testing it and/or providing some feedback.
 
  • Like
Reactions: codesplice
Upvote 0
So, here it is!

App: http://renyhp.altervista.org/batterylog.apk
Tasker project: http://renyhp.altervista.org/batterylog.prj.xml

For now its core isn't so much different from the original code. As I said, basically I put a settings scene and fixed a little bug - if the phone was turned off while in charge, at the next boot, if the phone was still in charge it reported again that the charger was plugged in (therefore showing a negative decrease of battery) and if the phone was not in charge it didn't report that the charger was unplugged. It still could have some bugs: if someone finds out one, please let me know. I'm planning to add some new stats to display in the log, some more settings and also to optimize some little things in the code; I didn't do that before posting this beta version because I want to be sure that it's totally free of bugs before adding new code.

P.S. I didn't upload it on Google Play because I discovered that I needed to pay for this and.. I don't think it's worth it.
 
Upvote 0
Some people told me that the setting scene has too big text sizes on other phones due to different resolutions... I'll have to reprogram the entire scene using some variable reading the screen resolution. Also, I found a bug with the apk which won't appear in the tasker project. I don't know if also the original code has the same problem if built into apk, but when phone is charging it reports many times that the charger was plugged in, obviously showing again negative battery decreases.
At this point, finding this kind of issues, I don't know if developing an apk with Tasker and making it usable with other phones is such a good idea (unless someone who's reading has some simple idea to fix that!)... In any case, I will keep improving the Tasker project, just because I personally need something similar, and maybe I'll share it here as xml.
 
Upvote 0
Making scenes for different resolutions is a real pain from my personal experience. But maybe there are some tricks I don't know about. In the past I've even tried making different apks from different phones to cover a number of resolutions. Not optimal! :)
 
Upvote 0
Yeah... actually the problem is not so much the scene itself because Tasker scales it to the other resolutions, so the geometry is good. What is very strange is that with higher resolution the text becomes bigger, and a workaround for that could be testing the scene for Width and then dynamically create the objects with text size depending on some %Width variable... but it IS a big pain.
Plus, I can't figure out why the app does more reports of phone charging - it seems like the Charging profile becomes active over and over although never returning inactive. Maybe, I suppose, Android makes the app sleep every so often and then, when it wakes up, it recognises the charger is plugged in and performs the entry task. If it is so, maybe making it work as an apk could be very difficult to program. I'm sure this problem is not due to the code because I ran the app and the Tasker profile at the same time, adding a "Tasker" text to the logs by Tasker, and it worked just fine.
 
Upvote 0
Here it is, with a list of changes that I could think of. I haven't had time to test the project separately from the rest of my stuff but hopefully I've copied in all the required content. Let me know if something doesn't work.

A note mainly for the other forum users, feel free to also use only bits that interest you, including the time converter and the logging platform...

https://drive.google.com/open?id=0B3R3a2WGs6rYWVpzWnNHc2xwWTg

Changes (some stuff wasn't required but it corresponds to my own needs):

- Added extra reports every hour. It can easily be changed to 30 min but you then need to amend the text logged in the task 'Periodic Battery Report' (where it says '... over the last hour')
- Added discharge rate to Power On log
- Now using local variables whenever possible (I need to do that on the rest of my stuff)
- Added reusable task ConvertToHMS. Use it with a parameter. Then use the variable HMSnum or HMStext
- Added reusable task Log Event. String to log goes in parameter 1. Set parameter 2 to yes to also get a toast
- Added a scene to show the logs (set up for Nexus 4, not tested elsewhere). Add a shortcut to 'Show Logs' to your home screen for easy access
- Added a notification when the battery is overheating

Any question, anyone, please ask.
Brilliant job!! keep it up
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones