sunSale — Home Assistant solar + battery optimization using Nord Pool / dynamic electricity prices
I’ve been working on sunSale , a Home Assistant custom integration for automatically optimizing a solar + battery system against dynamic electricity prices. Main target was, still is disconnect my solar inverter from Chinese servers and know why which decision was taken.
The goal is to go beyond simple automations such as:
cheap electricity → charge battery
expensive electricity → discharge battery
Instead, sunSale builds a schedule across future time slots and considers:
dynamic electricity prices (Nord Pool, ENTSO-E, Octopus Agile, Amber, TOU schedules)
solar production forecasts
current battery state of charge
learned household baseload
import/export tariffs, taxes and markups
battery/inverter power limits
estimated battery degradation cost
future prices and expected solar production
The result is a schedule deciding when the battery should charge, discharge, hold, import or export. With that also there are multiple configurations on a spot - either to allow, charging/discharging to grid or not, manually override operation mode and also monitor what is happening in real time.
What makes it different?
A simple price-threshold automation might see:
electricity is cheap → charge
sunSale can instead ask:
Is charging now actually better than waiting for tomorrow’s solar production or a cheaper price later, after accounting for the expected load, battery capacity, efficiency, tariffs and battery degradation?
The optimizer uses a SoC-bucketed dynamic-programming approach to find that schedule.
Current status
This is still alpha , but so far no significant issues on my system. But please don’t blindly let it control your inverter without observation period.
The recommended rollout is:
- Install and configure with automation disabled.
- Observe the generated schedule for a day or two.
- Verify that manual mode changes reach the inverter correctly.
- Enable automation only after you’re comfortable with the results.
Currently Solis via solis_modbus is the only inverter platform I’ve verified on my own real hardware .
Drivers are also implemented for:
- Huawei
- SolaX
- Sungrow
- GoodWe
- Deye
These have not yet been verified by me on real hardware , so testers are very welcome.
Fronius, SMA and Kostal currently provide telemetry only.
Home Assistant entities
The integration exposes things such as:
- current/next battery action
- current buy/sell price
- expected daily profit
- complete schedule
- estimated battery capacity
- degradation cost
- learned household baseload
- battery runtime
- monthly bill
- observed vs commanded inverter mode
- import/export/generation counters
- automation and policy controls
- manual mode override
There is also a master automation switch so the optimizer can be observed before allowing it to control the inverter.
Installation
Currently it can be installed through HACS as a custom repository:
HACS → Integrations → ⋮ → Custom repositories → add the repository as an Integration .
GitHub:
Then:
Settings → Devices & Services → Add Integration → sunSale
I’m particularly interested in testers
If you have:
- a solar installation + battery
- dynamic electricity pricing
- Home Assistant
- one of the supported inverter platforms
I’d be interested in hearing how it behaves with your system.
Especially useful would be real-world testing of the non-Solis drivers.
Issues, feature requests and contributions are welcome on GitHub.
I’m also interested in feedback from people who are currently solving battery arbitrage / solar self-consumption / dynamic electricity price optimization with Home Assistant automations or other tools. It would be useful to understand which features are missing.
GitHub: GitHub - LaurisK/sunSale: HomeAssistan sunSale integration · GitHub