Automatic Solar Uploads
Set it up once and your production is sent to the Nova Scotia SolarRank leaderboard every evening after sunset, with no typing required. Works with Home Assistant, Enphase gateways, or anything that can run a script.
1. Request Your API Key
Your key identifies your uploads. Enter the system name you'd like on the leaderboard, answer the quick question, and your email app will open with the request ready to send.
2. Connect Your System
Choose the option that matches your setup. Replace anything in CAPITALS with your own details.
Step 1: Add to configuration.yaml
Add this rest_command to your config and restart Home Assistant.
rest_command: upload_solar_yield: url: "https://solarrank.scottbrookesdesigns.com/automate.php?key={{ key_pass }}" method: POST payload: "name={{ name_pass }}&size={{ size_pass }}&output={{ output_pass }}&dir={{ direction }}" content_type: "application/x-www-form-urlencoded"
Step 2: Create the automation
Create a new automation, switch to Edit in YAML, and paste the following. Set output_pass to your sensor for today's solar production in kWh (the one that resets at midnight).
alias: "Push Daily Solar Data" description: "Uploads data after sunset" triggers: - trigger: sun event: sunset offset: "00:30:00" actions: - delay: minutes: "{{ range(0, 50) | random }}" seconds: "{{ range(0, 60) | random }}" - action: rest_command.upload_solar_yield data: key_pass: "YOUR_KEY" name_pass: "YOUR_SITE_NAME" size_pass: SITE_KW_SIZE output_pass: "{{ states('sensor.DAILY_KWH_SENSOR') }}" direction: "S"
The random delay spreads everyone's uploads out so they don't all arrive at the same moment.
Enphase IQ Gateway: Local Integration
No Home Assistant? This small Python script reads today's production straight from your Enphase gateway on your home network.
- Open the Enphase App: Menu › System › Devices › Gateway.
- Tap "Connect Locally". Once detected, tap Connect.
- A browser window opens (likely with a security warning). Note the IP address in the address bar.
- Continue to find your Gateway Serial Number and copy it for step 2.
Tip: on many home networks you can use envoy.local instead of the IP address.
Log in to Enlighten in your browser, then open this link, replacing SERIAL in the address with your serial number:
Get My Security Token ↗⚠️ Note: this token expires after 1 year. Set a reminder to renew it.
Save the code below as solar.py on a computer or Raspberry Pi on the same network as your gateway. Install the requests library (pip install requests), then edit the USER CONFIGURATION section.
import requests import time import random # --- USER CONFIGURATION --- GATEWAY_IP = "192.168.x.x" # The IP from Step 1 TOKEN = "PASTE_TOKEN_HERE" # The Token from Step 2 API_KEY = "YOUR_RANK_KEY" # Your SolarRank API key SITE_NAME = "Your System Name" SITE_SIZE = 10.5 DIRECTION = "S" # Delay 1-180 mins to stagger updates time.sleep(random.randint(1, 180) * 60) requests.packages.urllib3.disable_warnings() headers = {'Authorization': f'Bearer {TOKEN}'} try: r = requests.get(f"https://{GATEWAY_IP}/ivp/pdm/energy", headers=headers, verify=False, timeout=10) wh_today = r.json()['production']['pcu']['wattHoursToday'] kwh_today = round(wh_today / 1000, 3) payload = {'name': SITE_NAME, 'size': SITE_SIZE, 'output': kwh_today, 'dir': DIRECTION} requests.post("https://solarrank.scottbrookesdesigns.com/automate.php?key="+API_KEY, data=payload) except Exception as e: print(f"Error: {e}")
- Linux / Raspberry Pi: add a cron job (
crontab -e):0 21 * * * /usr/bin/python3 /path/to/solar.py - Windows: use Task Scheduler to run the script daily at 9:00 PM.
- Mac: use cron as above, or a Shortcuts automation.
The computer must be on and on the same network as the gateway when the script runs.
Python
For SolarEdge, Fronius, Tesla, Sungrow or any system where you can already read today's kWh in code, just post it:
import requests payload = { 'name': 'YOUR_SITE_NAME', 'size': 10.5, 'output': 42.1, 'dir': 'S' } r = requests.post("https://solarrank.scottbrookesdesigns.com/automate.php?key=YOUR_KEY", data=payload) print(r.text)
cURL
Handy for testing your key, or for any device that can run a shell command.
curl -X POST \ -d "name=YOUR_SITE_NAME" \ -d "size=10.5" \ -d "output=42.1" \ -d "dir=S" \ "https://solarrank.scottbrookesdesigns.com/automate.php?key=YOUR_KEY"
Import Your History
Have months or years of data in your monitoring app? Export it as a CSV and import it all at once. This needs a one-time Bulk Key, which you can request below.
Each Bulk Key works for one import only. It expires as soon as it's used.
• Column 1: date (
YYYY-MM-DD, or a timestamp starting with it)• Column 2: total kWh for that day (numbers only)
Example:
2025-07-14,48.2
API Reference
Send a POST request to https://solarrank.scottbrookesdesigns.com/automate.php?key=YOUR_KEY with these form fields:
| Field | Required | Description |
|---|---|---|
name | Yes | Your system's name on the leaderboard. Keep it identical every day so your totals add up. |
size | Yes | System size in kW DC (total panel wattage ÷ 1000), e.g. 9.6. |
output | Yes | Energy produced that day in kWh, e.g. 42.1. Must be greater than 0. |
dir | No | Panel orientation: S, E, W, N, or a combination like S, W. |
date | No | The day the data is for, as YYYY-MM-DD. Defaults to today (Atlantic time). Useful for re-sending a missed day. |
Sending again for the same name and date replaces the earlier numbers, so it's safe to retry. A successful upload replies Success: Data received…
Troubleshooting
I get "Error: Invalid API Key."
Keys are activated by hand, so a new key may take up to a day to start working. Also check that the key is copied exactly, with no extra spaces, and is in the address after ?key=.
I get "Error: Invalid data parameters."
The name, size and output fields must all be sent, and size and output must be numbers greater than zero. In Home Assistant, check that your sensor isn't reporting unavailable at upload time.
My upload shows up on the wrong day.
Uploads are dated using Atlantic time when they arrive. If your script runs after midnight, send the date field so it's filed under the right day.
My Enphase script stopped working.
The Enphase security token expires after one year. Generate a new one (step 2 in the Enphase tab) and paste it into your script. Your gateway's IP address may also have changed after a router restart.
I renamed my system and now have two entries.
Totals are grouped by name. Email the admin with both names and they can be merged.