Tesla Powerwall Battery
Publishes the current Powerwall battery charge and status via MQTT, including a dynamic icon that reflects charge level and battery mode.
Built by Team Super Panda
Published 27 August 2025 · updated 27 August 2025 · 2 downloads
Long Description
This automation monitors your Tesla Powerwall battery and sends updates via MQTT. It triggers when Home Assistant starts and whenever the battery power sensor changes.
1. Battery Charge and Power Status
- Reads the battery state of charge (
sensor.powerwall_3_percentage_charged) and rounds it to the nearest integer. - Reads the battery power (
sensor.powerwall_3_battery_power) to determine if the battery is:- Charging (
power < 0) - Discharging (
power > 0) - Idle (
power = 0)
- Charging (
2. Dynamic Icon Selection
-
Based on the charge level and battery mode, a numeric icon ID is selected.
-
Icon numbers used in this automation are:
Charging mode icons:
32047, 32049, 32050, 32051, 32052, 32053Discharging mode icons:
32059, 32058, 32057, 32056, 32055, 32054Idle/Other mode icons:
13735, 13732, 13731, 13725, 13734 -
To select or verify these icons, open the Awtrix web interface in your browser using the device's IP address. Navigate to the Icons page in the GUI, and you can browse or copy the numeric icon IDs directly. This ensures you are using valid icons that exist in your Awtrix installation.
-
Initially didn't work unless I downloaded them myself hence why I haven't included them below.
3. MQTT Payload Construction
- Chooses the correct state for the icon
- Publishes a status bar on the bottom
4. Automation Mode
- Runs in
singlemode, ensuring updates are sent sequentially without overlap.
Effectively, this automation provides real-time battery status updates, including charge level and mode, through MQTT, with visual feedback via the selected icons.
Shout out to: https://flows.blueforcer.de/flow/QE6B5QWRoMq0 for the inspiration.
rM3xoBwBO8Lz.yaml · 2.1 KB
alias: Awtrix Battery App
description: ""
triggers:
- trigger: homeassistant
event: start
- trigger: state
entity_id:
- sensor.powerwall_3_battery_power
conditions: []
actions:
- action: mqtt.publish
data:
topic: awtrix/custom/Powerwall
payload: >
{%- set charge = states('sensor.powerwall_3_percentage_charged') |
float(-1) | round(0) %}
{%- set power = states('sensor.powerwall_3_battery_power') | float(0) %}
{%- if power < 0 %}
{%- set mode = "Charge" %}
{%- elif power > 0 %}
{%- set mode = "Discharge" %}
{%- else %}
{%- set mode = "Idle" %}
{%- endif %}
{%- if mode == "Charge" %}
{%- if charge > 85 %}
{%- set icon = 32047 %}
{%- elif charge > 69 %}
{%- set icon = 32049 %}
{%- elif charge > 51 %}
{%- set icon = 32050 %}
{%- elif charge > 34 %}
{%- set icon = 32051 %}
{%- elif charge > 17 %}
{%- set icon = 32052 %}
{%- else %}
{%- set icon = 32053 %}
{%- endif %}
{%- elif mode == "Discharge" %}
{%- if charge > 85 %}
{%- set icon = 32059 %}
{%- elif charge > 69 %}
{%- set icon = 32058 %}
{%- elif charge > 51 %}
{%- set icon = 32057 %}
{%- elif charge > 34 %}
{%- set icon = 32056 %}
{%- elif charge > 17 %}
{%- set icon = 32055 %}
{%- else %}
{%- set icon = 32054 %}
{%- endif %}
{%- else %}
{%- if charge > 90 %}
{%- set icon = 13735 %}
{%- elif charge > 70 %}
{%- set icon = 13732 %}
{%- elif charge > 40 %}
{%- set icon = 13731 %}
{%- elif charge > 10 %}
{%- set icon = 13725 %}
{%- else %}
{%- set icon = 13734 %}
{%- endif %}
{%- endif %}
{ "text": "{{ charge }} %", "icon": "{{icon}}", "progress": {{ charge }}
}
mode: single