Monitors solar panel output using the Fronius inverter API and power consumption in realtime and persists the data to either a MySQL or EclipseStore backend for display in Grafana.
- Monitors instantaneous power generation and consumption
- Calculates cost of power used
- Monitors per-string power generation
- Retrieves Solcast solar forecasts (https://solcast.com/)
- Uploads actual generation to tune the Solcast forecast
Configure your solar panel system in Solcast. Solcast has a free "home hobbyist" tier that includes 20 API calls per day.
Choose which backend to use:
- MySQL/MariaDB
- EclipseStore
Setup and run the app:
- Build the application using Maven:
mvn clean package - Install and run MySQL (https://www.mysql.com/) or MariaDB (https://mariadb.org/)
- Setup the database using
/solar-sql/src/main/resources/mysql/setup.sql(substitute your own passwords) - Add power tariffs (see below for details)
- Configure properties in
application.propertiesapp.inverter.host- hostname/IP of the inverter web APIapp.solcast.api-key- your Solcast API key valueapp.solcast.site-id- your Solcast site IDspring.datasource.username- your MySQL app userspring.datasource.password- your MySQL app user password
- Run the application:
java solar-sql-x.y.z.jar
Setup and run the app:
- Build the application using Maven:
mvn clean package - Add power tariffs (see below for details)
- Configure properties in
application.propertiesapp.inverter.host- hostname/IP of the inverter web APIapp.solcast.api-key- your Solcast API key valueapp.solcast.site-id- your Solcast site IDapp.eclipse-store.root-path- path to the EclipseStore storage folder
- Run the application:
java --add-exports java.base/jdk.internal.misc=ALL-UNNAMED -jar solar-eclipsestore-x.y.z.jar
EclipseStore reference manual: https://docs.eclipsestore.io/manual/storage/getting-started.html
To view the output, use Grafana:
- Install and run Grafana
- Configure the datasource:
- MySQL for the MySQL backend
- Infinity for the EclipseStore backend:
- Default API endpoint is http://localhost:8080/api
- Import the appropriate Solar dashboard, either:
/solar-sql/src/main/resources/grafana/Solar SQL.json, or/solar-api/src/main/resources/grafana/Solar API.json
There are two types of tariffs:
- Usage tariffs - what you are charged for using electricity.
- Feed-in tariffs - what you are paid (or possibly charged) for exporting electricity.
The application uses the Tariff data structure to represent power tariffs. The fields in the Tariff class are:
| Field | Type | Description |
|---|---|---|
feedIn |
boolean |
true for a feed-in tariff, false for a usage tariff. |
startEffectiveDateEpoch |
long |
The time when this tariff begins to be effective, in seconds since the epoch or as a date string. |
endEffectiveDateEpoch |
Long |
The time when this tariff stops being effective, in seconds since the epoch. Can be null. |
dayOfWeek |
DayOfWeek |
The day of the week this tariff applies to (e.g., SUNDAY, MONDAY). |
startOfPeriod |
LocalTime |
The time of day when this tariff starts being effective (e.g., 00:00:00, 15:00:00). |
endOfPeriod |
LocalTime |
The time of day when this tariff stops being effective (e.g., 10:00:00, 23:59:59). |
pricePerKwh |
BigDecimal |
The price for one kilowatt-hour (kWh) (e.g., 0.2174). |
To load tariffs into the application, follow these steps:
-
Create a CSV File: Create a CSV file containing the tariff data. The file must include both usage and feed-in tariffs for each day of the week, covering the entire day from
00:00:00to23:59:59.Example CSV file:
feedIn,startEffectiveDateEpoch,endEffectiveDateEpoch,dayOfWeek,startOfPeriod,endOfPeriod,pricePerKwh true,2024年11月10日 00:00:00,,SUNDAY,00:00:00,23:59:59,0.033 false,2024年11月10日 00:00:00,,SUNDAY,00:00:00,15:00:00,0.2174 false,2024年11月10日 00:00:00,,SUNDAY,15:00:00,21:00:00,0.4082 false,2024年11月10日 00:00:00,,SUNDAY,21:00:00,23:59:59,0.2174
-
Configure the Application: Update the
application.propertiesfile to point to the CSV file:app.tariff.file-path=/path/to/tariff-file.csv app.tariff.date-format=yyyy-MM-dd HH:mm:ss app.tariff.timezone=Australia/Melbourne
-
Trigger the Update: Call the
/update-tariffsendpoint to load the tariffs into the application. This endpoint validates the tariffs and applies them to the database.
If you are paid 0ドル.033 per kWh for export, regardless of the time of day, the CSV entry for Sunday would look like:
true,2024年11月10日 00:00:00,,SUNDAY,00:00:00,23:59:59,0.033
If you are charged different amounts depending on the time of day, you will have multiple rows per day. For example:
- 0ドル.2174 between midnight and 3pm,
- 0ドル.4082 between 3pm and 9pm,
- 0ドル.2174 between 9pm and midnight.
The CSV entries for Sunday would look like:
false,2024年11月10日 00:00:00,,SUNDAY,00:00:00,15:00:00,0.2174 false,2024年11月10日 00:00:00,,SUNDAY,15:00:00,21:00:00,0.4082 false,2024年11月10日 00:00:00,,SUNDAY,21:00:00,23:59:59,0.2174