I finally decided to let go of my domain name, since i always forgot to pay it before it expired. so here I am on a new blogger blog from which I imported all of my old stuff. First thing i have to say is that Blogger really improved it's web interface since the last time i used it, it is now a charm to use and makes me want to post more often (this is highly unlikely).
I am posting today because i think i was able to do something pretty impressive using no programming at all (as i said in an earlier post, i like to tweak around) but instead using Tasker and Google Spreadsheet. I've built a spreadsheet which enables me to track my android battery draining problem. That will hopefully in the end enables me to fix it!.
Without further due, here is what it looks like:
The columns from left to right are: the battery discharge in that period, the approximated discharge for one hour, the date of the record, and then the approximate amount of time I go with the battery in this situation (from 100% to 0%). This data is then used to create a graphic(okay i know i don't have enough data to make it look nice)
It is important to note that once all of this was created, i don't have anything to do and the graph will keep populating itself and stay up to date. Of course the nice part is how i was able to create this amazing utility from scratch without any programming involved!!!
1: Creating the Google Spreadsheet with a Google Form
This part was simple enough, i only had to create a single spreadsheet and then add a form to it (you can do it the other way around i guess) the important thing is that you want to create as much entry in your form that you wan column in your table (in my case, 4) the entry all need to be as "Text".
Then, once you have the form, you need to retrieve the names of the input HTML elements (to do this i used Google Chrome's inspect element functionality (in that case it was entry.2.single (i had 4 actually, going from 0 to 3))
you also need to retrieve the URL address to your form (i "blurred" some of mine)
2: Inputting the values in the form with Tasker
On the android phone, the task was a bit more complicated, i had to create a tasker profile that started when I disconnected my phone from a charger, and ended when i reconnected it.
For the profile to do what i wanted, I then needed to create a task that recorded the battery charge when entering the profile as well as the time, and then another task that did the same when leaving the profile, that is when i reconnected the phone to the charger.
On the profile exit task, i then needed to be able to send the data to Google data and that's where the Google form came in useful. Tasker has a really nice feature which makes it possible to interact with the Google form, it can actually send HTTP Post Requests! I found a really
nice page that helped me with the creation of the request, but since this page was written, some things changed and the way to do it isn't exactly the same, i had to experiment a bit there, but you won't have to since i did it for you!
in the server:Port area, you need to add the address from the Google form, not including the "Https://" or last part of the address, that is "#gid=2" for me. I think it might differ for every form. in Data part, it needs to be entered in a similar fashion as in the screenshot, by entering a newline between each values. the %... are the variables recorded by the two tasks.
3: Formatting the values from Tasker
this part was a pain and not fun at all. I'm a programmer at heart and this just felt like the wrong way to do stuff.
i had to use a complicated combination of split() function, time(), date(), if() and other stuff in order to get the number of hours the phone was disconnected, i had to take into account the date and the time, this way if the phone was disconnected one day and only reconnected the next, the number of hours would still be accurate.
4: Displaying the graph
after that, the creation of the graph was really simple, just had to use the appropriate function in Google Spreadsheet.
It's only been 2 days since i created this, so i am not entirely sure if it works correctly all the time, but i will report back when i know more.