Author: Pavel Mikula
A Spring Boot application (Java 17+) running on a Raspberry Pi 4B, designed to dynamically control a Solax X3‑Hybrid‑G4 inverter via Modbus TCP. By leveraging real‑time weather data and energy pricing, this tool maximizes self‑consumption and cost savings for private installations.
Note: This application is intended for private use and may require adjustments to suit different environments. It is provided "as-is" without warranty.
- Dynamic Inverter Control through GPIO pins and Modbus TCP
- Weather‑Aware Operation using Meteosource API forecasts
- Price‑Driven Scheduling via spotovaelektrina.cz (scraped from OTE)
- Daily Rotating Logs with automatic compression
- Raspberry Pi 4B (Raspbian or compatible)
- Solax X3‑Hybrid‑G4 inverter with Modbus TCP enabled
- If no Modbus TCP on inverter: RS485 → Ethernet converter (e.g., Waveshare industrial server)
- Meteosource: Request an API key at https://www.meteosource.com/
- spotovaelektrina.cz: Ensure access
- Java 17 or higher
- Maven 3.x
- Network access between RPi and Solax inverter
- Clone the repository
git clone https://github.com/Firestone82/SolaxAutomation.git cd SolaxAutomation
- Configuration file
Edit
cp src/main/resources/application.yml.example application.yml
application.yml
(see Configuration below). - Build
mvn clean package
- Run
java -jar target/solax-automation-*.jar
- (Optional) Install as Service
Create a systemd unit
/etc/systemd/system/solax-automation.service
:[Unit] Description=Solax Automation After=network.target [Service] User=pi ExecStart=/usr/bin/java -jar /home/pi/SolaxAutomation/target/solax-automation-*.jar WorkingDirectory=/home/pi/SolaxAutomation Restart=on-failure [Install] WantedBy=multi-user.target
sudo systemctl daemon-reload sudo systemctl enable solax-automation sudo systemctl start solax-automation
Edit application.yml
or set corresponding environment variables.
solax:
modbus:
# Modbus TCP connection
host: 192.168.0.31
port: 502
# Time management required for modbus
time:
# Delay between two requests
delay: 1000
# ID of the inverter in modbus, can differ if you have multiple inverters
unitId: 1
# Advanced password for the inverter
password: 2014
# API for electricity prices provided to grid
# - Documentation: https://spotovaelektrina.cz/api
ote:
api:
url: "https://spotovaelektrina.cz/api/"
# API for weather data
# - Documentation: https://www.meteosource.com/documentation
meteosource:
api:
url: "https://www.meteosource.com/api/"
key: "YOUR_API_KEY"
# Location for weather data. Lat and lon is always better. How to find is described in the documentation
location:
placeId: "prague"
# Coordinates for the location
lat: 50.0755
lon: 14.4378
# Logging configuration
logging:
config: classpath:log4j2.xml
Logs are provided to console as well as to the files stored in the logs
directory. The log files are rotated daily and compressed to save space.
This project is provided "as-is" for personal use. No warranty is offered. Adapt for your needs, but please do not redistribute without permission.