Skip to content

Get Battery Health

Summary

  • Internal name: GetBatteryHealth
  • Category: Battery
  • Purpose: Read the current battery health status. Returns a descriptive string such as Good, Overheat, Dead, Over Voltage, or Cold.
  • Task type: Normal

Compatibility

  • Minimum AndroMate version: 1.1.0

  • Maximum AndroMate version: 1.1.0

  • Minimum Android: Android 13 (API 33)

  • Maximum Android tested: Android 16 (API 36)

  • Required permissions: None


Detailed description

The Get Battery Health task reads the battery health indicator from the Android battery broadcast (ACTION_BATTERY_CHANGED). The result is a human-readable string stored in value_output, making it easy to detect degraded or unsafe battery conditions during automated monitoring workflows.

No special permissions are required — ACTION_BATTERY_CHANGED is a protected system broadcast available to all apps.


Input parameters

This task has no input parameters.


Output parameters

Field Type Trigger condition Android Compatibility AndroMate Compatibility Default
value_output String Always on success — one of Good, Overheat, Dead, Over Voltage, Cold, Unknown Android 13 (API 33) → Android 16 (API 36) 1.1.0 → 1.1.0 <ANDROMATE_NULL_VALUE>

Possible output values

Value Description
Good Battery is functioning normally
Overheat Battery temperature is too high
Dead Battery is dead and cannot be used
Over Voltage Battery voltage is above safe limits
Cold Battery temperature is too low
Unknown Health status cannot be determined

Special variables

When comparing the output of this task in a condition (e.g. Compare Strings), you can use the built-in AndroMate special variables instead of hardcoded strings. This avoids typos and keeps your workflow readable.

Special variable Resolved value
${BATTERY_HEALTH_GOOD} "Good"
${BATTERY_HEALTH_OVERHEAT} "Overheat"
${BATTERY_HEALTH_DEAD} "Dead"
${BATTERY_HEALTH_OVER_VOLTAGE} "Over Voltage"
${BATTERY_HEALTH_COLD} "Cold"
${BATTERY_HEALTH_UNKNOWN} "Unknown"

Example — compare $battery_health against ${BATTERY_HEALTH_GOOD} in a Compare Strings task instead of typing "Good" manually.


Exceptions

This task does not throw exceptions. If the health status cannot be read, "Unknown" is stored in value_output.


Execution flowchart

flowchart TD
    Start([▶ GetBatteryHealth]) --> Register[📡 Register ACTION_BATTERY_CHANGED\none-shot receiver]

    Register --> ReadHealth[🔋 Read EXTRA_HEALTH\nmap to string]

    ReadHealth --> StoreResult[💾 Set value_output\nStrTaskResult]

    StoreResult --> LogReport[📋 Log report]

    LogReport --> Success([✅ StrTaskResult])

    style Start fill:#e3f2fd
    style Success fill:#c8e6c9
    style Register fill:#fff9c4
    style ReadHealth fill:#f3e5f5
    style StoreResult fill:#c8e6c9

How it works:

  1. Register battery receiver: registers a one-shot receiver for ACTION_BATTERY_CHANGED
  2. Read health: extracts EXTRA_HEALTH and maps the integer constant to a descriptive string
  3. Store result: sets value_output with the health string
  4. Result: returns StrTaskResult

Code examples

Example 1 — Read battery health

{
  "GetBatteryHealth": [
    {
      "id": "1",
      "title": "Check battery health",
      "value_output": "$battery_health"
    }
  ]
}

Input parameter details

This task has no input parameters.


Output parameter details

value_output — Battery health

Stores the battery health as a descriptive string in the specified workflow variable.

  • One of Good, Overheat, Dead, Over Voltage, Cold, Unknown
  • If the health cannot be determined, "Unknown" is stored
  • Tip: compare against the ${BATTERY_HEALTH_*} special variables instead of hardcoded strings

Complete JSON example

{
  "GetBatteryHealth": [
    {
      "id": "1",
      "title": "Get Battery Health",
      "value_output": "$BATTERY_HEALTH"
    }
  ]
}