Remote battery status with Zooper Widget and Tasker


I have a plethora of gadgets scattered around my home and office, and they all need periodic charging. I decided to try out some of the functions of Tasker, AutoRemote and Zooper to get (close to) real-time information on the battery status of my devices. Here’s how I went about it.

…this will be a long one…

Required apps

  • Tasker ($2.99) is why I love Android. It allows me to automate everything from automatic rain alerts in the morning to automatic silent mode. It’ll be the foundation for the project.
  • AutoRemote ($3.99) is used to send data between different devices. It opens up an API that can be used to gather data from platforms other than Android. A bit pricey, but opens up a lot of possibilities for customization.
  • Zooper Widget Pro ($2.99) is used to display the data on my phone. Fully customizable. You could easily get by with the free version, but I like the app and like to show my support.

AutoRemote Setup

After installing all the appropriate apps, you’ll need to set up some options for AutoRemote. You should create a password inside preferences, and select a name for the device (Nexus 5, here). Register any Android devices with eachother.

Setup AutoRemote tasks in Tasker

Usually it’s safer to pull information when needed, instead of pushing it to the ‘server’. I cut a few corners and decided to push battery data, instead, as AutoRemote provides an easy GET API for computers and jailbroken iOS devices.

Pushing information periodically

  • Create a Time based task by selecting Time under the + sign on the toolbar.
  • Make it start at 00:00, end at 23:59 and repeat every 3 hours.
  • For the task select: Plugin –> AutoRemote Message – Recipient: Nexus 5 – Message: devicebattery=:=%BATT – Advanced settings: — password (you did set it, before, right?) — Time To Live: 3600

I set TTL to 3600 seconds (one hour), as it’s possible that my phone is not receiving the messages at all times, and buffering the messages is not needed.

Receiving information

  • New state –> Plugin –> Autoremote
  • Message filter: battery=:=
  • Exact message unchecked
  • New Task –> Plugin –> Zooper Widget Pro
  • ZW Variable: devicebattery
  • ZW Text: %arcomm
  • If %arpar() ~ devicebattery

(repeat for all devices, using the appropriate ZW Variable and If condition)

Testing the connection

AutoRemote displays a toast message by default, whenever it receives or sends messages. Later on, you might want to disable reception notifications on your main device, but for now it’s nice to see what’s going on in the background.

Open the Autoremote send task and press the play button on the bottom bar. You should see a toast message on both your devices.

Extra: Push battery information from non-Android devices

You can use AutoRemote’s GET API to send information from pretty much any device you can automate. I ended up with four devices: the company cellphone, my 7” Android tablet, an old iPad and a Macbook Air. You can use the following information to push pretty much any information to your device.

OSX / Linux

You basically want to retrieve your battery status with one command, and send the data to your AutoRemote url in the same manner that Tasker does.

Retrieving the battery level depends on your system. Here’s a magical line that does the trick on OSX:

/usr/sbin/ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%.0f%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}'
Code language: JavaScript (javascript)

After this you need to find out your AutoRemote url. You’ll find it on the first screen that opens up when you launch AutoRemote on your (main) Android device. It starts with Opening this url forwards you to a page with a very long url: Copy that url and add the same variables in, as you did with Tasker, above (message, target, password, Message validity time). You can enter your information on the page and copy the long url directly from a text area box. There’s even a Send button for you to test the connection.

Collect everything above into a script you can schedule:

#!/bin/bash BATTERY=$(/usr/sbin/ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%.0f%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}') curl "$BATTERY&password=secret&ttl=3600&sender=MacBook" -s >/dev/null 2>&1
Code language: JavaScript (javascript)

You can now run the script locally, or edit crontab (system scheduler) to automate it with the command ‘crontab -e’. Adding the following line will run every hour (but only when the computer is on). This system works on all Unix based systems.

0 * * * * /Users/juhani/conf/sh/
Code language: JavaScript (javascript)

Displaying data with Zooper

At this point we have battery data coming in, processed by Tasker and being forwarded to Zooper variables. The rest should be easy.

  • Create a new Zooper widget by long pressing on your home screen background.
  • Select Layout and press the + button on the top
  • Add a Text module (plaintext will do, for now) – Scroll down to Edit text manually and select it – Add your Tasked imported variables to the text as #T…# with the variable name in the middle, i.e. #Tdevicebattery# – I lumped everything together and added some tweaks to the UI.

I have some extra network information on the widget. Might try to style it a bit more, at some point, but I’m pretty happy with it.

About the author

Juhani Naskali

IT System Architect and PhD Candidate at University of Turku, member of Future Ethics research group, consultant, programmer, physics enthusiast and nerd.

Add comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.