P06D is a latched 21450 (not power), P052/P05A static, P063 frozen; power is computed V*I. Lists what's sent, what isn't, the unmapped diagnostics, the INV1-INV5 IP assignments, and that timestamps must be real UTC. The simulator now sends the same payload shape. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3.4 KiB
3.4 KiB
Brief: sending inverter readings to the Solar Monitor backend
You are building (or updating) the script on the site laptop that reads the Refusol 020K inverters over USS/TCP and reports to the backend. The backend and dashboard already run at https://solar.bonamin.net. Your job is only the on-site side: read the inverters, POST the values.
Files to use
backend_client.py(next to this brief): copy it next to your script and use it to send. It's standard library only. It timestamps readings, keeps them inunsent_readings.jsonlwhen the internet is down, re-sends them later, and never raises.README.md(next to this brief): the field names, units and the current state of the register map (what's verified, what isn't sent yet).
What to do every 60 s
from backend_client import BackendClient
BACKEND_URL = "https://solar.bonamin.net"
API_KEY = "<ask the owner; same value as API_KEY in the server's .env>"
backend = BackendClient(BACKEND_URL, API_KEY)
while True:
readings = []
for inv in INVERTERS: # e.g. [{"id": "INV1", "host": "192.168.1.51"}, ...]
try:
values = read_inverter(inv) # your USS code -> dict of converted values
readings.append({"inverter_id": inv["id"], **values})
except Exception as e:
log.warning("%s not answering: %s", inv["id"], e)
# just leave it out: the dashboard marks it Offline (by day) or Sleeping (at night)
backend.send(readings) # ALWAYS call it, even with an empty list
sleep_until_next_minute()
Rules that matter
- Always call
send(), even with an empty list. The empty list is the heartbeat. It's how the dashboard tells "inverter dead" (laptop still reporting) apart from "site/internet down". inverter_idmust stay the same forever for each physical inverter, e.g.INV1..INV5matching labels on the units. It's the database key. Pretty names are set later in the dashboard, not here. Allowed characters: letters, digits,_ . -.- Send converted values, not raw ones, using the keys in
README.md. Leave out anything you couldn't read or haven't verified; every field is optional. Timestamps must be real UTC (see README). - New or unconfirmed parameters: send them too, under a descriptive key
(e.g.
p0xx_raw). The backend stores unknown keys and shows them on the inverter page under "Other (unmapped)". Tell the owner when a mapping is confirmed so it gets promoted to a proper field. - Fault status: if you find the parameter holding the inverter's
state/error code, send it as
status_code/error_code(non-zeroerror_code= the dashboard shows Fault), with an optionalstatus_text. This is high priority: it's the most direct "is it broken?" signal. - A failed inverter read must never stop the loop or the other inverters.
- Run it so it survives reboots: Windows Task Scheduler "at startup" or a service; systemd on Linux.
Checking it works
curl -X POST https://solar.bonamin.net/api/readings \
-H "X-API-Key: <key>" -H "Content-Type: application/json" \
-d '[{"inverter_id":"INV1","ac_power_total_w":1234}]'
# use a real inverter id: every id sent shows up as an inverter on the dashboard
# -> {"received":1,"stored":1,"duplicates":0}
Then open https://solar.bonamin.net. The inverter appears within 30 s. API reference: https://solar.bonamin.net/api/docs