Monitor and control your Pila battery from Home Assistant over MQTT.
- Compatibility
- Setup
- Entities
- Reliability
- Home Assistant Energy Dashboard
- Solar readings from Home Assistant
- Example Lovelace cards
- Example automations
- Troubleshooting
- Advanced: MQTT topics
- Changelog
| Requirement | Notes |
|---|---|
| Pila firmware | 1.2 or newer |
| Home Assistant | 2024.x or newer (MQTT discovery v2 schema) |
| MQTT broker | Any MQTT 3.1.1 broker. Mosquitto add-on recommended. |
| Network | Pila and Home Assistant must be on the same local network |
| TLS | Plaintext on port 1883 only today. TLS support is planned. |
Total time: about 5 minutes.
If you already have one, skip to step 2. For deeper detail, see Home Assistant's MQTT integration docs.
- Settings → Add-ons → Add-on Store (sometimes called Apps)
- Install Mosquitto broker
- Start the add-on; enable "Start on boot" and "Watchdog"
- Settings → Devices & services → Add Integration → MQTT. Home Assistant auto-detects the broker.
On your Pila:
-
Open Settings → Home Assistant
-
The IP Address field is pre-populated — Pila does an mDNS sweep for
homeassistant.localon boot and fills in what it finds. If the address looks right, use it. Otherwise, find it manually in HA under Settings → System → Network and overwrite.
-
Enter your Home Assistant username and password
-
Tap Save & Connect
The status indicator turns green when connected. The connection persists across reboots.
Have more than one Pila? You only need to do this once, on any Pila. It securely shares your Home Assistant settings with every other Pila in your home, and they all connect right away. Each Pila shows up in Home Assistant as its own device. A Pila you add later picks up the settings as soon as it joins your other Pilas.
💡 Optional: dedicated HA user. For tighter security, create a non-admin HA user just for Pila (Settings → People → Users → Add User) and use those credentials in step 3. Your normal credentials work fine otherwise.
In Home Assistant, Settings → Devices & services → MQTT should show your Pila with all entities listed below.
Home Assistant generates entity IDs from your Pila's device name. If your Pila is called Kitchen Pila, entities show up as sensor.kitchen_pila_battery_soc, switch.kitchen_pila_back_lower_outlet, and so on. The examples below use your_pila as a placeholder — replace it with your Pila's slug.
⚠️ The slug is sticky. Home Assistant bakes your Pila's name into entity IDs the first time it connects. If you rename the Pila later in the app, the friendly name updates in HA but the entity IDs stay the same. The fastest fix: in HA, go to Settings → Devices & services → MQTT → your Pila, open the ⋮ menu, and choose Recreate entity IDs. HA will regenerate every entity_id from the current device name in one click (requires HA 2025.6 or newer).
| Name | Unit | Description |
|---|---|---|
| Total Usage | W | Total load currently being powered by the Pila (battery + grid + solar combined). |
| Battery Charge / Discharge Rate | W | Signed power into/out of the battery pack. Positive = charging, negative = discharging. |
| Total Solar Input | W | Power currently arriving from solar. |
| Total AC Input | W | Power currently flowing in from the grid. |
| Name | Unit | Description |
|---|---|---|
| Battery SOC | % | State of charge, 0–100. |
| Battery energy remaining | Wh | Energy left in the pack at the current state of charge. |
| Backup Forecast | h | Estimated hours of backup runtime at current load. |
| Pila Status | — | Human-readable summary. One of: Solar powering devices, Battery powering devices, Charging from solar, Charging from utility, Utility powering devices, Idle. |
| Name | Unit | Description |
|---|---|---|
| Grid Status | — | One of: on_grid (connected to and using utility), off_grid (islanded — running on battery/solar), idle_off_grid (no grid and no AC output), unknown. |
Cumulative total_increasing counters designed for the Energy Dashboard.
| Name | Unit | Description |
|---|---|---|
| Pila Lifetime Import | Wh | Total energy imported from the grid through Pila over the device's lifetime. |
| Battery Lifetime Charge | Wh | Total energy charged into the battery pack over its lifetime. |
| Battery Lifetime Discharge | Wh | Total energy discharged from the battery pack over its lifetime. |
For each AC and USB-C outlet:
| Entity | Type | Unit | Description |
|---|---|---|---|
{outlet name} |
switch | — | Turn the outlet on or off. State reflects relay state. |
{outlet name} power |
sensor | W | Power currently flowing through the outlet. |
{outlet name} Lifetime Energy |
sensor | Wh | Cumulative energy delivered through the outlet. |
Outlet naming. If you've assigned an appliance name to an outlet in the Pila app (e.g. "Fridge"), Home Assistant uses that name. Otherwise it falls back to the orientation default ("Left USB Port", "Middle USB Port", "Right USB Port", "Front Left Outlet", "Front Right Outlet", "Back Upper Outlet", "Back Lower Outlet", etc.). The slug is derived from this name, so a default usb_1 becomes sensor.your_pila_right_usb_port_power, not sensor.your_pila_usb_1_power. Confirm the exact entity_id in Settings → Devices & services → MQTT → your Pila before referencing it in YAML.
Renaming an outlet in the Pila app updates the friendly name in HA but does not change the entity_id. Use the device's ⋮ → Recreate entity IDs menu in HA (2025.6+) to regenerate them.
| Name | Unit | Description |
|---|---|---|
| Battery Max Temperature | °C | Warmest cell in the battery pack. |
| Battery Min Temperature | °C | Coolest cell in the battery pack. |
| Internal Max Temperature | °C | Warmest reading across the battery and power electronics inside your Pila. |
| CPU Temperature | °C | Your Pila's processor. |
Home Assistant shows temperatures in the unit set under Settings → System → General, so you may see °F.
For each Pila fridge or freezer sensor paired to an appliance in the Pila app:
| Entity | Unit | Description |
|---|---|---|
{appliance name} fridge temperature |
°F | Temperature inside the fridge. |
{appliance name} fridge humidity |
% | Humidity inside the fridge. |
{appliance name} fridge light |
lx | Light level inside the fridge. Jumps when the door opens. |
A freezer sensor adds the same three entities, named {appliance name} freezer .... If a sensor stops reporting, its entities show Unknown until it comes back.
A sensor you pair after Pila connects to Home Assistant shows up the next time Pila republishes its discovery config, for example after a Home Assistant restart.
| Name | Type | Values | Description |
|---|---|---|---|
| Grid mode | select | on_grid, off_grid |
Switch Pila between on-grid and manual off-grid (island) mode. |
The integration recovers automatically from common failures. No manual reconnect needed.
- Home Assistant Core restart (from inside the HA UI) — Pila listens for the
homeassistant/statusbirth message and republishes its discovery config + state when HA comes back. - Mosquitto restart (e.g. broker add-on update) — Pila's MQTT client auto-reconnects with exponential backoff (1s → 120s).
- Home Assistant OS reboot — both of the above apply; Pila republishes once the broker is reachable again.
- Pila power loss or network drop — Pila reconnects on its own when it returns.
All Pila entities flip to Unavailable in HA within roughly 90 seconds of any failure (via the availability_topic and MQTT keepalive) and recover automatically when both sides are back online.
Wire Pila into Settings → Dashboards → Energy:
| Energy Dashboard tile | Pila entity |
|---|---|
| Grid consumption | Pila Lifetime Import |
| Battery in (charge) | Battery Lifetime Charge |
| Battery out (discharge) | Battery Lifetime Discharge |
The Energy Dashboard uses cumulative counters, not instantaneous power. Don't wire Battery Charge / Discharge Rate here.
This is how your Pila works with almost any solar or battery system. Pila connects to Enphase directly. For everything else, check whether your system is already on your network and shows up in Home Assistant. That covers inverters like SolarEdge, Fronius, or SMA, battery systems like Tesla Powerwall, EG4, or FranklinWH, and energy monitors like Sense or Shelly. If it does, Home Assistant can pass its live solar production to your Pila, so your Pila can charge from your excess solar.
Anything that reports current solar power in W or kW works. Integrations that only report daily energy in kWh won't.
Home Assistant sends the readings to Pila every 10 seconds with a blueprint. Every Pila connected to this Home Assistant receives them.
Or go to Settings → Automations & scenes → Blueprints → Import Blueprint and paste:
https://github.com/PilaEnergy/pila-home-assistant/blob/main/blueprints/automation/pila/send_solar_to_pila.yaml
Open Settings → Automations & scenes → Blueprints → Send solar readings to Pila → Create Automation and pick:
| Input | What to pick |
|---|---|
| Solar power sensor | Your current solar production, in W or kW. |
| Grid power sensor (optional) | Power flowing between your home and the grid, in W or kW. Leave empty if you don't have one. |
| Grid sensor reports export as positive | Turn on if your grid sensor shows a positive value while you're sending power to the grid. |
Without a grid sensor, Pila assumes your home uses 400 W and treats solar above that as excess it can charge from.
Your Pila needs to be connected to Home Assistant first (see Setup). Then, on your Pila, open Settings → Solar → Home Assistant and tap Use Home Assistant. Once readings arrive, the screen shows your current solar production.
If Home Assistant stops sending readings for 30 minutes, Pila falls back to its own solar estimate until they come back.
You can also publish the readings yourself. Pila listens on pila/solar for JSON:
| Key | Unit | Notes |
|---|---|---|
site_solar_p_W |
W | Required. Current solar production. |
site_grid_p_W |
W | Optional. Positive while importing from the grid, negative while exporting. |
alias: Send solar readings to Pila
trigger:
- platform: time_pattern
seconds: "/10"
action:
- service: mqtt.publish
data:
topic: pila/solar
payload: >
{"site_solar_p_W": {{ states('sensor.your_solar_power') | float(0) | round(0) | int }},
"site_grid_p_W": {{ states('sensor.your_grid_power') | float(0) | round(0) | int }}}
mode: singleexamples/automations/send-solar-to-pila.yaml
Drop these into a dashboard via Edit dashboard → Add card → Manual. Replace your_pila in entity IDs with your Pila's slug (e.g. kitchen_pila).
type: vertical-stack
cards:
- type: entities
entities:
- entity: sensor.your_pila_backup_forecast
name: Backup Time Remaining
icon: mdi:timer-outline
- type: gauge
entity: sensor.your_pila_battery_soc
name: Battery Level
needle: true
severity:
green: 50
yellow: 15
red: 0
- type: sensor
entity: sensor.your_pila_battery_soc
graph: line
name: 24h History
detail: 2
hours_to_show: 24examples/dashboards/battery-soc-card.yaml
type: vertical-stack
cards:
- type: glance
title: Pila Power Flow
columns: 4
entities:
- entity: sensor.your_pila_total_solar_input
name: Solar
- entity: sensor.your_pila_total_ac_input
name: Grid
- entity: sensor.your_pila_battery_charge_discharge_rate
name: Battery
- entity: sensor.your_pila_total_usage
name: Load
- type: entities
entities:
- entity: sensor.your_pila_pila_status
name: Status
- entity: sensor.your_pila_grid_status
name: Grid
- entity: sensor.your_pila_battery_soc
name: Battery SOC
- entity: sensor.your_pila_backup_forecast
name: Backup Forecastexamples/dashboards/power-flow-overview.yaml
type: vertical-stack
cards:
- type: history-graph
title: USB Power History
hours_to_show: 1
entities:
- entity: sensor.your_pila_left_usb_port_power
name: Left
- entity: sensor.your_pila_middle_usb_port_power
name: Middle
- entity: sensor.your_pila_right_usb_port_power
name: Right
- type: entities
entities:
- entity: sensor.your_pila_left_usb_port_power
name: Left USB Power
- entity: sensor.your_pila_middle_usb_port_power
name: Middle USB Power
- entity: sensor.your_pila_right_usb_port_power
name: Right USB Powerexamples/dashboards/usb-power-history.yaml
Paste into Settings → Automations → Add → Edit in YAML.
alias: Pila low battery notification
trigger:
- platform: numeric_state
entity_id: sensor.your_pila_battery_soc
below: 20
for:
minutes: 1
action:
- service: notify.notify
data:
title: Pila battery low
message: >
Pila is at {{ states('sensor.your_pila_battery_soc') }}%.
Estimated {{ states('sensor.your_pila_backup_forecast') }} hours of backup remaining.
mode: singleexamples/automations/low-soc-notification.yaml
alias: Pila grid outage notification
trigger:
- platform: state
entity_id: sensor.your_pila_grid_status
to: off_grid
action:
- service: notify.notify
data:
title: Pila is off-grid
message: >
Pila switched to off-grid mode. Currently {{ states('sensor.your_pila_pila_status') | lower }}.
Battery at {{ states('sensor.your_pila_battery_soc') }}%.
mode: singleexamples/automations/grid-outage-notification.yaml
Turn off a non-essential outlet when battery drops below 30 % during a grid outage.
alias: Pila shed non-essential load on low battery
trigger:
- platform: numeric_state
entity_id: sensor.your_pila_battery_soc
below: 30
condition:
- condition: state
entity_id: sensor.your_pila_grid_status
state: off_grid
action:
- service: switch.turn_off
target:
entity_id: switch.your_pila_front_right_outlet
mode: singleexamples/automations/turn-off-outlet-on-low-soc.yaml
Status stuck on "Disconnected" on the Pila screen. Check that (a) the HA IP is correct and stable (set a DHCP reservation if needed), (b) the username/password work in a browser, (c) the Mosquitto add-on is running, and (d) port 1883 is reachable from the local network (nc -vz <HA_IP> 1883). Reboot Pila and watch the indicator.
Pila is connected but no entities appear. In Home Assistant: Settings → Devices & services → MQTT → Configure → Listen to a topic, subscribe to homeassistant/device/pila/#. You should see a config payload shortly after Pila connects. If you see the payload but no device, restart HA once — discovery occasionally fails to register on first push.
Entities show "Unavailable" forever. On Pila 1.2+, this means Pila has genuinely lost its broker connection or the credentials are bad — recovery is automatic when both sides return, so persistent Unavailable is real. Subscribe to pila/availability/# on the HA broker: if the retained payload is offline, Pila isn't talking to the broker (check the Pila screen for status, verify credentials, check the broker is running). If it's online but entities are still Unavailable, open an issue with the raw pila/state/# payload.
Entities show "Unknown" forever. Subscribe to pila/state/# to confirm state messages are flowing. If they are, the value template may not be finding the key — open an issue with the raw payload.
Outlet switch doesn't change state when I toggle it. Relay commands are fire-and-forget; state reflects what Pila reports back. Give it 2–3 seconds. If it never changes, check whether a Pila-side schedule or timer is fighting your command.
Pila says "Waiting for solar data from Home Assistant." Check that the solar automation is turned on and that your solar sensor has a number, not unavailable. In Home Assistant, Settings → Devices & services → MQTT → Configure → Listen to a topic, subscribe to pila/solar. You should see a reading every 10 seconds.
Disconnecting from Home Assistant. Tap Disconnect on the Pila Home Assistant screen. The MQTT device goes offline in HA; the entities remain in HA's registry until you delete the device manually under Settings → Devices & services → MQTT.
Disconnecting with more than one Pila. Disconnect on any Pila disconnects all the Pilas in your home, and Forget Home Assistant clears the settings from all of them.
For anything else, open an issue with your Pila firmware version, Home Assistant version, broker, and what you've tried.
For users who want to bypass HA discovery and consume topics directly.
| Purpose | Topic | Retained |
|---|---|---|
| Discovery config (published by Pila) | homeassistant/device/pila/{device_id}/config |
no |
| State (published by Pila) | pila/state/{device_id} |
no |
| Availability (published by Pila, also the LWT) | pila/availability/{device_id} (online / offline) |
yes |
| HA Core birth/will (subscribed by Pila) | homeassistant/status |
— |
| Commands (subscribed by Pila) | pila/switch/outlet/{device_id} |
— |
| Solar readings (subscribed by Pila) | pila/solar |
no |
State messages are published at QoS 2. The discovery config is re-published every time Pila connects to the broker AND every time Home Assistant Core publishes online on homeassistant/status, so HA Core restarts auto-recover without any user action.
See LICENSE.




