A fast, minimal CLI for monitoring Solar-Assistant via its REST API.
- Battery state of charge with color-coded progress bar (green → yellow → red)
- Battery charging/discharging status with optional %/h rate (
--battery-capacity) - Per-battery breakdown: voltage, current, SOC, temperature
- Solar PV production
- Load power
- Grid power and voltage (detects power cuts)
- Inverter temperature
- Output source priority and charger source priority
- Live
--watchmode that polls and redraws on a configurable interval --rawand--metricflags for scripting / piping tojq- Zero external dependencies — pure Go standard library
- Solar-Assistant running on your local network
- A device password configured — see the local password guide
- Go 1.21+ (to build from source)
git clone https://github.com/youruser/solar.git
cd solar
go build -o solar .Fetch the current stats and print them once:
./solar --host solar-assistant.local --password secretPoll and redraw every 2 seconds (press Ctrl+C to exit):
./solar --host solar-assistant.local --password secret --watchShow charge/discharge rate in %/h by providing your total battery capacity in Wh:
./solar --host solar-assistant.local --password secret --battery-capacity 10000Print the raw JSON response from the API (useful with jq):
./solar --password secret --raw | jq '.[] | select(.topic | startswith("battery_"))'Print a single metric value as plain text:
./solar --password secret --metric total/pv_power
# → 1240| Flag | Default | Description |
|---|---|---|
--host |
solar-assistant.local |
Solar-Assistant hostname or IP |
--username |
admin |
Device username |
--password |
Device password | |
--battery-capacity |
Total battery capacity in Wh (e.g. 10000 for 10 kWh) |
|
--timeout |
10s |
HTTP request timeout (one-shot mode) |
--interval |
2s |
Poll interval (watch mode) |
--watch |
Enable live mode | |
--raw |
Print the raw JSON response from /api/v1/metrics and exit |
|
--metric |
Print the plain-text value of a single metric topic and exit |
The CLI calls GET /api/v1/metrics and reads the following topics from the response:
| Metric | Topic |
|---|---|
| Battery state of charge | total/battery_state_of_charge |
| Battery power | total/battery_power |
| Battery voltage (inverter bus) | inverter_1/battery_voltage |
| Load power | total/load_power |
| Solar PV power | total/pv_power |
| Grid power | total/grid_power |
| Grid voltage | inverter_1/grid_voltage |
| Device mode | inverter_1/device_mode |
| Inverter temperature | inverter_1/temperature |
| Output source priority | inverter_1/output_source_priority |
| Charger source priority | inverter_1/charger_source_priority |
| Per-battery voltage | battery_N/voltage |
| Per-battery current | battery_N/current |
| Per-battery power | battery_N/power |
| Per-battery state of charge | battery_N/state_of_charge |
| Per-battery temperature | battery_N/temperature |
Per-battery topics (battery_N/*) are auto-discovered: every battery_* index present in the API response is rendered. With a single battery the temperature is appended to the main Battery row; with multiple batteries a dedicated Batt N row is added per battery.
