Files
refusol-datalogging/poller

On-site poller

refusol_poller.py (not in this repo yet) reads the inverters over USS/TCP (port 21062, USS address 0). It sends each cycle to the backend through backend_client.py — copy that file next to the poller.

Wiring it into refusol_poller.py

At the top of the file:

from backend_client import BackendClient

BACKEND_URL = "https://solar.bonamin.net"
API_KEY = "same value as API_KEY in the server's .env"

backend = BackendClient(BACKEND_URL, API_KEY)

At the end of every poll cycle, one dict per inverter that answered:

readings = []
for inverter_id, values in polled.items():      # however the poller holds them
    readings.append({"inverter_id": inverter_id, **values})
backend.send(readings)                          # also call it when the list is empty

Each dict uses the keys below (all optional — send what was read). Anything else you include (e.g. a newly discovered parameter as "p0xx_raw": 1234) is stored too and shows under "Other (unmapped)" on the inverter page.

key unit source
ac_voltage_l1_v / _l2_v / _l3_v V P050 / P05B / P064 raw / 40
dc_voltage_mppt1_v / _mppt2_v V P052 / P054 raw / 40
dc_current_mppt1_a / _mppt2_a A P05A / P05C raw / 10
ac_current_l1_a / _l2_a / _l3_a A P068 / P069 / P06A raw / 100
ac_power_total_w W P06D raw
grid_frequency_hz Hz P06C raw / 20
temperature_c °C P070 raw >> 16
daily_energy_wh Wh P063 IND=0 raw × 10
total_energy_wh Wh P063 IND=11 raw
status_code – inverter state, once identified
error_code – non-zero = fault (shows the inverter as Fault)
status_text – optional human text for the code

send() stamps each reading with the current UTC time, buffers to unsent_readings.jsonl when the internet is down and re-sends later, and never raises — a backend problem can't stop the polling loop.

Call send([]) even when no inverter answered. That's the heartbeat that lets the dashboard say "inverter not responding" (site online) instead of "datalogger offline" (site/internet down).

Trying the dashboard without the site

python fake_poller.py --url http://localhost:8090 --key change-me --backfill-days 30