← All posts
Predbat

How to set up Predbat — the complete guide for Fox ESS and Octopus Agile

Predbat is the Home Assistant add-on that automatically plans your battery charging and discharging based on Octopus Agile prices and solar forecasts. Here's how to get it running.

Predbat is the reason my battery system is genuinely smart rather than just sitting there. It reads Octopus Agile prices 48 hours ahead, checks the solar generation forecast, and plans every charge and discharge slot automatically. Once set up, it’s completely hands-off.

This guide covers setting it up for a Fox ESS inverter on Octopus Agile. The principles are the same for other supported inverters (Givenergy, Solis, Solaredge, etc.) but the specific sensor names will differ.

What Predbat actually does

Before diving into setup, it’s worth understanding what Predbat optimises:

  1. Charges the battery when Agile prices are cheapest (usually midnight–4am)
  2. Avoids charging when solar will fill the battery anyway
  3. Reserves battery capacity for high-price periods (typically 4–7pm)
  4. Exports to grid when prices are high enough to be worth it (if your inverter supports it)
  5. Plans 48 hours ahead — so if tomorrow is forecast to be very sunny, it won’t bother charging tonight

The result: your battery charges when electricity is cheapest, discharges when it’s most valuable, and you barely touch expensive grid electricity.

Prerequisites

Before installing Predbat you need:

  • Home Assistant running (any hardware)
  • HACS (Home Assistant Community Store) installed
  • Fox ESS integration installed and connected (or equivalent for your inverter)
  • Octopus Energy integration installed in HA
  • Solcast account (free tier works) for solar forecasting

I’ll cover each of these briefly before getting to Predbat itself.


Step 1 — Install HACS

HACS is the community store that gives you access to add-ons (including Predbat) that aren’t in the official HA store.

  1. Go to hacs.xyz and follow the installation instructions
  2. In HA: Settings → Add-ons → Add-on Store — HACS appears after restart
  3. Open HACS → click the three dots → Custom repositories
  4. You can now search for and install community integrations

Step 2 — Install the Octopus Energy integration

This pulls your live Agile rates into Home Assistant.

  1. In HACS → Integrations → search Octopus Energy
  2. Install and restart HA
  3. Go to Settings → Integrations → Add integration → Octopus Energy
  4. Enter your Octopus API key (find this in your Octopus account under Developer settings)
  5. Select your electricity meter

Once configured you’ll have sensors like:

  • sensor.octopus_energy_electricity_XXXX_current_rate — current p/kWh
  • sensor.octopus_energy_electricity_XXXX_next_rate — next half-hour rate

These are what Predbat reads for price planning.


Step 3 — Install the Fox ESS integration

This is how Predbat reads and controls your inverter. For Fox ESS, the Predbat team maintain a dedicated integration.

  1. In HACS → Integrations → search Fox ESS or add the custom repository: https://github.com/nathanmarlor/foxess_modbus
  2. Install and restart
  3. Go to Settings → Integrations → Add integration → FoxESS Modbus
  4. Enter your inverter’s local IP address (find it in your router’s DHCP list)
  5. Select your inverter model

You’ll now have sensors like:

  • sensor.foxess_pv_power — solar generation watts
  • sensor.foxess_battery_soc — battery percentage
  • sensor.foxess_grid_power — grid import/export

Check your exact sensor names in Developer Tools → States — search for foxess.


Step 4 — Set up Solcast (solar forecasting)

Predbat uses Solcast to predict how much solar you’ll generate over the next 48 hours. The free tier gives you 10 API calls per day — enough for Predbat’s needs.

  1. Sign up at solcast.com (hobbyist/free tier)
  2. Create a rooftop site — enter your location, panel count, azimuth (south = 180°), and tilt
  3. Copy your API key and Resource ID

In Home Assistant, install the Solcast PV Forecast integration via HACS:

  1. HACS → Integrations → search Solcast PV Forecast
  2. Install and configure with your API key
  3. You’ll get sensors like sensor.solcast_pv_forecast_today showing expected kWh

Step 5 — Install Predbat

Now everything is in place to install Predbat itself.

  1. In HACS → Integrations → three dots → Custom repositories
  2. Add: https://github.com/springfall2008/batpred
  3. Category: Integration
  4. Search Predbat and install
  5. Restart Home Assistant
  6. Go to Settings → Integrations → Add integration → Predbat

Step 6 — Configure Predbat

Predbat’s configuration file is predbat.yaml — you’ll find it in your HA config directory. This is where you tell it about your system. Open it via File Editor or Studio Code Server add-on.

Essential settings:

# Your inverter brand
inverter_type: Fox

# Battery settings
battery_size: 10.3        # kWh total capacity
battery_rate_max: 3.0     # kW max charge/discharge rate  
battery_loss: 0.07        # Round-trip loss (7% is typical)
battery_min_soc: 10       # Minimum SOC to keep (%)

# Solcast solar forecast
solcast_host: https://api.solcast.com.au
solcast_api_key: YOUR_API_KEY
solcast_resource_id: YOUR_RESOURCE_ID

# Octopus Agile - your rate sensor name
metric_octopus_import: sensor.octopus_energy_electricity_XXXX_current_rate
metric_octopus_export: sensor.octopus_energy_electricity_XXXX_export_current_rate

# Fox ESS sensor names (check yours in Developer Tools → States)
pv_power: sensor.foxess_pv_power
soc_kw: sensor.foxess_battery_soc
inverter_power: sensor.foxess_battery_power
grid_power: sensor.foxess_grid_power

# Your electricity standing charge (pence)
metric_standing_charge: 62.0

Charge window settings:

# How far ahead to plan (hours)
forecast_hours: 48

# Minimum battery to reserve for evening
best_soc_min: 10         # % — never go below this
best_soc_keep: 20        # % — aim to keep this for emergencies

# Export settings (if your inverter supports forced export)
inverter_can_export: true
best_export_rate: 15.0   # Only export if rate > this (pence)

Step 7 — Test it

After saving the config, check the Predbat panel in Home Assistant:

  1. Go to Settings → Integrations → Predbat → Configure
  2. Or search for predbat in your HA dashboard

You should see:

  • Charge plan — a list of upcoming cheap slots it plans to charge in
  • Battery SOC curve — predicted battery level over the next 48 hours
  • Import/export plan — when it expects to buy or sell electricity

If the plan looks sensible (charging at cheap overnight slots, discharging at peak times) — you’re done.


Common issues

Predbat isn’t charging at cheap times

  • Check your Octopus rate sensor name is correct in the config
  • Make sure the rate sensor is showing the right value in Developer Tools

Solar forecast is wrong

  • Double-check your Solcast panel azimuth (south = 180°, west = 270°, east = 90°)
  • Make sure your tilt angle is correct

Battery isn’t reaching target SOC

  • Check battery_rate_max — if it’s too high for your inverter, charging will be cut short
  • Check the inverter charge limit in your Fox ESS settings

Predbat shows an error

  • Check the HA logs: Settings → System → Logs — search for Predbat

How long does setup take?

Honestly? Half a day if you’re comfortable with Home Assistant, a full weekend if you’re new to it. The Octopus and Fox integrations are the fiddly part — finding the right sensor names for your specific setup.

Once it’s running, you’ll never need to touch it again. Predbat has been running hands-off in my house for 17 months. It charges every night at cheap/negative Agile rates and the battery covers my evening peak. My average effective import rate works out around 12p vs 28p on a standard flat tariff.

The setup time pays for itself within weeks.


Further reading

If you’re setting this up on a fresh Home Assistant installation, start with the Yellow guide first:

What is Home Assistant Yellow →