Battery Status
On your display
Show the status of your battery on screen
- Topic
- Smarthome
- Includes
- Script
Runs on
- Does not run on 32×8 (TC001 & DIY) Made for 52×16 (TC002).
- Runs on 52×16 (TC002)
- Does not run on 32×8 with AWTRIX 3 (TC001 & DIY) Made for AWTRIX NG.
Choose your display in the next step.
Script description
Battery Status
Shows your home battery on the full 52 × 16 display of the Ulanzi TC002: an animated battery with the state of charge, the live charge/discharge power and how long until the battery is full or empty. Press the middle button for a 24-hour graph and a daily SOC graph.
Features
- Animated battery icon – the fill colour runs smoothly from red (empty) to green (full). While charging a light wave moves up; while discharging a dark wave moves down.
- SOC on the largest uniform area – below 46 % the number sits in the empty part, above that it is cut out of the fill. At 100 % the number is hidden.
- Live power with direction – a lightning bolt and an arrow: green ↑ while charging, red ↓ while discharging, grey without an arrow when idle (up to 3500 W fits).
- Time remaining – while discharging the time until empty (
left 1:35), while charging the clock time at which the battery will be full (full 14:20). - Three screens – cycle through them with the middle button; you choose which one is the start screen.
- English, Dutch, German or French – choose the language of the on-screen words.
- History stored on the clock – SOC is averaged per half hour and kept in the script store, so a restart does not erase the graphs.
Screens
- Battery – battery, power and time remaining.
- Battery + graph – as screen 1, but when the battery is idle the last 24 hours of SOC are shown as a dimmed background behind the power.
- Daily graph – SOC from 00:00 to 24:00, each row in its own colour of the battery gradient.
The middle button always moves to the next screen in the order 1 → 2 → 3 → 1. When the clock moves on to another app, the script starts on your start screen again next time.
Requirements
- Ulanzi TC002 running AWTRIX NG – the layout is designed for the 52 × 16 display.
- An MQTT broker that both the clock and your home automation use.
- Something that publishes your battery data as JSON to one topic, e.g. Home Assistant or Node-RED (see below).
- Time on the clock – the graphs and the "full at" time need the clock to know the time.
MQTT payload
Publish one JSON message to the configured topic (default awtrix/accu) whenever a value changes:
{ "soc": 64, "power": 420, "energy": 1.73, "status": "Discharging" }
| Key | Meaning |
|---|---|
soc |
State of charge in percent (0–100) |
power |
Battery power in watts; the sign is ignored, the direction comes from status |
energy |
Energy stored in the battery in kWh |
status |
Charging, Discharging, or anything else for idle (matches the Anker Solarbank status sensor in Home Assistant) |
Example: Home Assistant automation
Replace the entity IDs with your own sensors.
alias: Battery Status to AWTRIX
triggers:
- trigger: state
entity_id:
- sensor.battery_soc
- sensor.battery_power
- sensor.battery_energy
- sensor.battery_status
actions:
- action: mqtt.publish
data:
topic: awtrix/accu
payload: >-
{"soc": {{ states('sensor.battery_soc') | int(0) }},
"power": {{ states('sensor.battery_power') | float(0) }},
"energy": {{ states('sensor.battery_energy') | float(0) }},
"status": "{{ states('sensor.battery_status') }}"}
mode: queued
Settings
| Setting | Default | Description |
|---|---|---|
topic |
awtrix/accu |
MQTT topic the script listens to |
rustms |
15000 |
Milliseconds without charging/discharging before the screen switches to idle (prevents flicker) |
capaciteit |
0 |
Battery capacity in kWh, used for the "full at" time. 0 derives it from energy and soc; entering the real capacity is more accurate |
start |
1 |
Start screen: 1 = battery, 2 = battery + graph when idle, 3 = daily graph |
lang |
English | Language of the on-screen words (dropdown): English, Dutch, German or French |
Setup
- Open the AWTRIX NG web interface of your TC002.
- Go to Scripts and create a new script.
- Paste the code and save it.
- Fill in the settings (at least the MQTT topic).
- Start publishing the JSON payload; the battery appears as soon as the first message arrives.
Notes
-
On-screen words per language:
Time left Full (at) Idle English left full idle Dutch nog vol rust German noch voll Ruhe French reste plein repos -
The graphs fill up from the moment you install the script. Screen 3 shows today from the start; screen 2 needs one full day before its 24-hour window is complete.
-
If the clock does not know the time yet (right after a restart), the charging line shows the duration (
+1:20) instead of a clock time.
Sign in to view and copy the code of this script.
Discussion 0
Ask a question, suggest a change or share how you use it.
No comments yet. Start the conversation.
Have an idea?
Sign in to ask questions and join the conversation.