[RELEASE] Virtual Battery Sensor

Wrote a small driver to record a battery reading for some of my tablets and phone. Intention is to send the current reading via Tasker / Maker API and record it in devices that use this driver.

Features of the driver:

  • Implements the Battery capability
  • Has a custom command setBattery(NUMBER) to allow updates via Maker API or RM rules
  • Includes a batteryStatus attribute to indicate if the battery is Discharging or Charging
  • Includes a lastUpdated attribute, so that a change is recorded event when no change to the battery is recorded, allow for an assessment of loss of communication with the device

The driver is available in HPM with Tags of "Monitoring","Energy Monitoring" and "Misc. Devices". It can also be accessed manually here.



Release Notes:

2021-08-28: 1.0.0 - Initial Release
2021-08-29: 1.1.0 - Added batteryStatus attribute

Nice - can you share an example of what the tasker profile looks like?

Here you go @rocketwiz ...

I'd post some of the XML from the Tasker backup, but not sure how to properly isolate it, so will just give a description for now.

In HE:

  • Create a new Virtual Device using this Virtual Battery Sensor driver
  • Note down the Device Id from the URL on the Device Edit Page
  • Setup or update an existing instance of the Maker API Built-In App to include the new Virtual Battery Sensor device
  • In the Maker API App setup screen, copy the example "Send Device Command" URL, substituting the [Device ID] with the Device Id for the new virtual device, the [Command] with setBattery, and the [Secondary Value] with %BATT (the Tasker variable representing the current battery reading on your device)
  • Get this URL string to your device in some way, or access / modify it on the device if convenient

In Tasker:

  • Create a new profile, selecting Event as the trigger
  • In the pop-up type battery in the filter textbox and select Battery Changed
  • From the profile screen displayed, hit back to return to the main screen
  • From the pop-up select New Task, type in a name if you want, press the Tick icon to enter the Task edit screen
  • Press the + icon to add an Action
  • Type HTTP in the filter textbox, select HTTP Request (if not available choose HTTP Get)
  • Paste in the modified send command URL string in the URL setting
  • Back out to accept all the changes

If you want to go a step further, I have made a start in setting this virtual device up in a separate Maker API instance that sends attribute readins to InfluxDB / Grafana, setup various reports in Device Watchdog, but haven't yet got to the obvious use case of managing charging of the devices to keep them in a sweet spot of 20-80%.



Got it, thanks! Should have no problem recreating it.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.