I love my HBS-730 Bluetooth headphones. They come with all the bells and whistles, heck, even a battery feedback. All good but one little detail: the battery feedback comes in 3 levels HIGH, MEDIUM, LOW. Here is the problem:

  • HIGH – the device just has been charged, has full battery, mode lasts about 10 min
  • MEDIUM – this is where you spend the 99% of you 8h power time
  • LOW – battery about to die, you have literally 5 min to get a cable and start charging

It is entirely possible for me to go for a bike ride with 6 min left on my headphones thinking that I will be ok. The companion app although exist and let you pass through calls, messages etc, has no information about the exact battery level of the headphones. I had enough, time to employ Tasker.  The Bluetooth battery monitor lets you keep track of any Bluetooth device, even if that gadget has no battery indicator whatsoever.

Tasker – Bluetooth battery monitor

screenshot_20161003-121554

Although you can streamline the project quite a bit with plugins, I’m using vanilla Tasker for best compatibility with all Android users. The project consists three profiles. Not all of them are necessary, but they create an application that you can use straight away. The only editing that needs to be done is entering the device name in the Bluetooth battery monitor context.

The project offers you 2 calibrations modes.
You can choose to measure a lifespan of your fully charged device (more accurate). This measurement will be used in the battery life estimation later.
Alternatively, you can enter an estimated value of the battery life in hours and minutes.

The calibration is being done once, then the main profile is enabled. A notification will appear on each connects and disconnects from the Bluetooth device to let you know about the estimated life span.

Headset override

This profile is responsible for opening the calibration scene and making sure the calibration profiles are triggered correctly. Initially, the Bluetooth device had to be off, for calibration to work correctly, now it doesn’t matter.

We are using BT device to set a variable (%BToverride), then to launch a scene unless the profile has been launched before. Once calibration screen is open it won’t run again (%Startup).

PROFILE - Headset Override

Start scene

screenshot_20161003-121454This task creates then opens a scene. It also notifies our headset override profile that set up has been completed (%Startup =1). The scene contains initial elements and few hidden ones that will become visible when selection is done. The calibration button simply closes the scene and enables a calibration profile. Time button hides other elements and enables all hidden UI elements including number pickers for hour and  minute values. These are written  to variables %BTh and %BTm and converted later to  a total number of seconds. The OK button closes the scene and sets the %B_Tmax value – which is the maximum battery life. Please note that %BT and %B_T spelling are intentional as not all variables will be cleared by the reset  button later.

TASK Start scene

BT calibration

This mode will measure how long your device lasts on a single charge. Bluetooth battery monitor will use this value to set a correct %B_Tmax. The profile alone is a simplified version of the main profile, all variable referenced have the %BTC prefix to it. Each time your device is disconnected from the mobile a notification is issued that gives you the option to continue measurement if the device is not discharged, or end the calibration if your Bluetooth device run out of power.

When calibration is done the BT measuring done task is executed. It will set the correct %B_Tmax and clear the %BTC related variables. At this point, the main profile becomes activated and the calibration profile is no longer in use.

PROFILE - BLuetooth Calibration

BT battery MAIN

screenshot_20161003-121705This is the meat of things. When connected, if previous readings are available, a notification will let you know how long your device will live (%btttlchour and %btttlcminute) This values are calculated in a disconnect task and come from %BTttl (time to live) estimation. If the profile is run for the  first time a current time in seconds is measured and set as %BTstart. If a notification has been displayed before it will close within 10 sec.

The actions responsible for calculating minutes and hours from  total seconds value are shared across the connect and disconnect tasks. These are slightly modified for the purpose of displaying a correct message.

To calculate the estimated time to live we have to take into consideration two scenarios:

  • TTL<60 min
  • TTL>60 min

By default system will treat the %BTttl as if was smaller than 60 min and values of %btttlchours/minutes will become overridden in an IF condition should that value was greater than 60. The notification gives us two options. Close, if the Bluetooth device has some battery life in it (close notification) and reset if the battery device needs a charge (clear all %BT variables). The %B_Tmax will be unaffected.

PROFILE - BT Battery MAIN

Calculations

The math behind is simple.

  • Time of disconnect (s) – Time of connect (s) = %BTstop
  • Time in use %BTtotal(s) + %BTstop = %BTtotal
  • Time to live (s) = B_Tmax -%BTtotal

To calculate the seconds into minutes we need two operations. For TTL below 60min we have:

%btttlchour = 0 AND %btttlcminutes = (%btttc)%60 (%btttc is a copy of %BTttl)

For TTL above 60 min:

 %btttlchour = ceil(%btttlc)/60  AND %btttlcminutes = (%btttc)%60 (%btttc is a copy of %BTttl)

Ready files

As usual, you can follow Bluetooth battery monitor tutorial and the video above. In addition to this, you can download the complete file below. You can also consider supporting the website, it starts from 0.99  and it means a lot! Either way happy talking!

Ready Project xml file (please remove the underscore from the file name) : bluetooth_battery-prj

SHARE