Skip to content

martensson/solar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

solar

A fast, minimal CLI for monitoring Solar-Assistant via its REST API.

screenshot

Features

  • 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 --watch mode that polls and redraws on a configurable interval
  • --raw and --metric flags for scripting / piping to jq
  • Zero external dependencies — pure Go standard library

Requirements

Installation

git clone https://github.com/youruser/solar.git
cd solar
go build -o solar .

Usage

One-shot

Fetch the current stats and print them once:

./solar --host solar-assistant.local --password secret

Live mode

Poll and redraw every 2 seconds (press Ctrl+C to exit):

./solar --host solar-assistant.local --password secret --watch

With battery capacity

Show charge/discharge rate in %/h by providing your total battery capacity in Wh:

./solar --host solar-assistant.local --password secret --battery-capacity 10000

Scripting

Print 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

Options

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

REST topics used

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.

About

Solar-Assistant Terminal Monitoring

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages