XMRig script that keeps track of CPU power consumption and solar energy generation (from a goodwe inverter) and shows it in a nice dashboard. BTW the dashboard itself is mostly vibe coded, I just needed something that showed the info in a nice way, because SEMS can't make a nice UI for some reason. And the XMRig script (main.py) is partially vibe coded, like I made a script for something else before and I just repurposed it with AI.
- Shows your total generated energy from your solar panel(s) (since max 11 months before you started the main.py script).
- Shows your average solar energy per month.
- Shows your total CPU/PC usage.
- Shows what your CPU/PC uses on average in kWh.
- Shows how many watts your CPU is using on average the last 24hrs.
- Shows how many kWh your solar panels have generated this month.
- Shows how much electricity costs you need to pay for last month.
- A monthly comparison card.
- Python 3.12+
- Goodwe inverter (I do not know which ones are supported by this, but I think most)
- XMRig
- XMRig config file
Follow these steps to get the dashboard running:
git clone https://github.com/XanderTheDev/xmrig-solar-program.git
cd xmrig-solar-programpip install requestsnix-shell # You need to be in the repository to do thisGo to SEMS Portal and register or login.
If you haven't setup a goodwe inverter, you need to do that obviously.
When you are in the SEMS Portal look at your url. You will see something like https://www.semsportal.com/PowerStation/PowerStatusSnMin/5ed23680-1929-5f82-bdbf-f748ff54f43b,
you need to copy the 5ed23680-1929-5f82-bdbf-f748ff54f43b and put it in where the placeholder is for 'gw_station_id' in goodwe_scripts/config.py.
Put in all your info with how you logged in into the SEMS Portal in goodwe_scripts/config.py. So like:
'gw_account'is your email for the SEMS Portal'gw_password'is your password for the SEMS Portal
Keep in mind this will just be in plain text in a file. So if you are ever going to publish this to the web make sure to
use an .env file or something. You would then use os.getenv("SEMS_PASSWORD") for example for the gw_password field.
You also need to add import os then. You could also just put the config.py in a ignore file lik gitignore. BUT IF
YOU ARE GOING TO MAKE YOUR DASHBOARD PUBLIC THIS DOES NOT WORK! You then really need to change how it gets it's information.
I am just not using it publically or directly putting my files on github (I just copy the code to be safe), so I do not really need
the extra security. And also the SEMS Portal account is not so important to me.
Copy your XMRig config.json and move it to ~/.config/xmrig/config.json if not already. Then in goodwe_scripts/main.py change YOUR_USER to your username in the XMRIG_CMD variable.
change const costPerKWh = 0.22; // €/kWh to what your actual price is for 1 kWh.
Go to the goodwe_scripts folder and run:
sudo python main.pysudo is recommended, because otherwise MSR does not work, but if you do not care about that, it still keeps working, but just without MSR.
In another terminal go to back to the goodwe_scripts folder and run:
python run_server.py
# Or alternatively you can also just make it an executable and run it:
chmod +x run_server.py
./run_server.pyIf everything went well you can now access your Dashboard!
- Data updates every 60 seconds.
- Logs are stored in monthly_stats.json automatically.
- The dashboard uses a dark theme and is mobile-friendly.
This project is licensed under the BSD-4 Clause License. See the LICENSE file for details.