pvmon

module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MIT

README

pvmon

pvmon is a self-hosted monitor for photovoltaic (PV) systems. It reads inverters, batteries, meters and wallboxes from different vendors. It shows where the electricity of a household comes from and where it goes. It also shows how self-sufficient the household is and if a device has a fault.

pvmon only monitors. It does not control devices, it does not calculate costs and it does not send data to the internet.

Overview

Documentation: https://dombyte.github.io/pvmon/

Contents

Features

  • Reads devices over Modbus TCP, Modbus RTU (RS485) and HTTP/JSON.
  • Describes each device model in a YAML profile. A new model needs no Go code.
  • Keeps one energy balance for the site: PV, battery, grid, backup and consumers.
  • Stores energy in 15-minute buckets in SQLite. It calculates days, months, years and lifetime values from these buckets.
  • Shows live values, a day view, history, reports (PDF and CSV) and device status.
  • Shows only what your site has. A site without a battery shows no battery.
  • Has an English and a German user interface. You can install it as a PWA.
  • Has admin accounts, API tokens and an audit log. Read access needs no login (you can change this).
  • Imports the history of an existing solis database.
  • Ships as one binary. The binary contains the user interface, the profiles and the database migrations.

Supported devices

Profile Device Transport Verified
solis/s6-hybrid Solis S6 hybrid inverter (and RHI) Modbus TCP/RTU yes
shelly/pro-3em Shelly Pro 3EM energy meter HTTP (Gen2) yes
shelly/3em Shelly 3EM energy meter HTTP (Gen1) no
eastron/sdm630 Eastron SDM630 energy meter Modbus TCP/RTU no
goe/charger-v2 go-eCharger (API v2) HTTP yes
tinkerforge/warp3 Tinkerforge WARP3 Charger Pro HTTP yes
opendtu/total OpenDTU (Hoymiles micro inverters) HTTP no

Installation

  1. Copy the example/ directory to your host.

  2. Edit example/config.yaml. Set the addresses of your devices.

  3. Set your time zone in TZ in compose.yaml.

  4. Start pvmon:

    docker compose up -d
    
  5. Open http://<host>:8080.

The image is ghcr.io/dombyte/pvmon. It is available for amd64, arm64 and armv7. The database, the backups and the encryption key are in the volume /app/data.

For an RS485 adapter on the host, add the device to compose.yaml (see the comments in the file).

Binary
  1. Download the archive for your platform from the GitHub releases.

  2. Extract the archive.

  3. Write a config.yaml (see Configuration).

  4. Start pvmon:

    TZ=Europe/Berlin ./pvmon -config config.yaml
    

pvmon does not restart itself after a fatal error. It stops with exit code 1. Use a supervisor (systemd, Docker restart: unless-stopped) to restart it.

First start

  1. Start pvmon.
  2. Find the setup code in the log. The code has 8 characters.
  3. Open the user interface. Enter the setup code.
  4. Create the first admin account.
  5. If your config.yaml has no meters, the setup wizard starts. Add your devices, examine the live values and save.

You can also create an admin account on the command line (stop the server first):

printf '%s\n' "$PASSWORD" | pvmon user add admin

Configuration

You can configure pvmon in two ways:

  • In the user interface (settings and setup wizard). pvmon applies the changes without a restart.
  • In config.yaml and in environment variables.

You can use both at the same time. The file has priority. An object that is in the file is locked in the user interface.

A minimal config.yaml:

site:
  name: Home
  interval: 5s                 # poll interval of all devices

connections:
  lan-solis: { address: "tcp://10.0.0.20:502", timeout: 2s }

devices:
  wr1:   { connection: lan-solis, unit: 1, profile: solis/s6-hybrid }
  meter: { address: "http://10.0.0.31", profile: shelly/pro-3em, interval: 2s }

meters:
  pv:      { device: wr1, source: pv, kwp: 10, label: Roof }
  battery: { device: wr1, source: battery, capacity: 10kWh }
  grid:    { device: meter, source: total }

example/config.yaml shows a full site with two wallboxes.

Rules:

  • A site needs exactly one meter with the role grid.
  • Each duration needs a unit, for example 5s, 30d or 10y.
  • The time zone comes only from the environment variable TZ.
  • Do not write passwords into the file. Use a reference: ${env:NAME} or ${file:/run/secrets/name}.
  • An environment variable overrides a key. Use the prefix PVMON_ and two underscores for each level. Example: PVMON_APP__LOG_LEVEL=debug sets app.log_level.

Frequently used settings:

Key Default Meaning
app.port 8080 HTTP port
app.log_level info debug, info, warn or error
auth.public_read true Read access without login
storage.path ./data/pvmon.db Database file
storage.retention 10y How long pvmon keeps data
storage.backup_interval 24h Interval of the online backups
storage.max_backups 3 Number of backups that pvmon keeps
status.offline_after 15m Offline time during the day that counts as a fault
log.file empty Log file in addition to stdout

SPEC.md section 3 gives all keys and rules.

To examine your configuration, use:

pvmon config validate
pvmon config export      # shows the full configuration as YAML, without secrets

Security

  • pvmon serves HTTP only. For access from the internet, put pvmon behind a reverse proxy with TLS and authentication.
  • With auth.public_read: true, all persons in your LAN can read your energy data. Set auth.public_read: false to prevent this.
  • Keep data/secret.key. pvmon uses this key to encrypt the device passwords that you enter in the user interface. Without the key, you must enter these passwords again.
  • pvmon makes no outgoing connections, except to your devices.

Command line

Command Purpose
pvmon or pvmon serve [-config path] Start the server
pvmon version Show the build information
pvmon config validate / config export Examine the configuration
pvmon user add / reset-password / list Manage admin accounts
pvmon token create / list / revoke Manage API tokens
pvmon profile validate <file> Examine a profile file
pvmon dump --device <id> Record the raw values of a device
pvmon simulate --setup R1..R7 Run with simulated devices
pvmon import-solis --db <file> --map <file> Import a solis database

Stop the server before you use user, token, dump or import-solis. These commands make and verify a backup before they write. Exit codes: 0 = success, 1 = failure, 2 = usage error.

The REST API is at /api/v1. pvmon shows its reference (Swagger UI) at /docs/. Live values are available over the WebSocket /ws. To use the API from a script, create a token and send it as Authorization: Bearer <token>.

Import from solis

pvmon can import the history of solis, an earlier monitoring application for Solis inverters.

  1. Stop pvmon.

  2. Copy example/import-solis.map.yaml and adapt it to your meters.

  3. Run the import:

    pvmon import-solis --db solis.db --map import-solis.map.yaml
    
  4. Read the summary. It shows each series, the skipped days and all differences.

pvmon opens the solis database read-only. It imports only the days before its own data.

Device profiles

A profile describes one device model: registers or JSON paths, scales, signs, counters and status values. pvmon contains the profiles in profiles/. To use your own profile, set its path as profile of the device:

devices:
  meter: { address: "tcp://10.0.0.50:502", unit: 2, profile: ./profiles/my-meter.yaml }

To write or examine a profile:

  1. Record the raw values of the device. Stop the server first.

    pvmon dump --device meter --count 10 -o meter.fixture.json
    
  2. Write the profile. SPEC.md section 4 gives the schema.

  3. Examine the profile:

    pvmon profile validate ./profiles/my-meter.yaml
    

A dump contains only the values that the profile reads. Profiles do not read serial numbers.

Development

  • SPEC.md is the specification of the application: behaviour, configuration, profiles, storage, API, user interface and acceptance gates.
  • AGENTS.md gives the rules for the codebase: structure, architecture, code rules, tests, dependencies and the Git workflow. It applies to persons and to coding agents.
make build                       # build ./pvmon with the version from git
go run ./cmd simulate --setup R3 # run with simulated devices
make check                       # all checks of the CI and the collector simulation

To build, you need Go 1.27.4 and Node.js for the frontend. Read AGENTS.md before you send a pull request.

License

MIT, see LICENSE. The licenses of the third-party code are in LICENSES/. The release archives and the container image contain THIRD_PARTY_NOTICES.md.

Directories

Path Synopsis
Command pvmon polls PV devices and serves the dashboard.
Command pvmon polls PV devices and serves the dashboard.
Package docs embeds the API documentation: openapi.yaml and the Swagger UI build (docs/dist, built by `make docs`).
Package docs embeds the API documentation: openapi.yaml and the Swagger UI build (docs/dist, built by `make docs`).
Package frontend embeds the built web UI (frontend/dist, built by `make assets`) into the binary.
Package frontend embeds the built web UI (frontend/dist, built by `make assets`) into the binary.
internal
app
Package app is the composition root: it loads the configuration, maps it onto the Settings and Specs of every package and builds all components (Create* factories).
Package app is the composition root: it loads the configuration, maps it onto the Settings and Specs of every package and builds all components (Create* factories).
auth
Package auth implements accounts, sessions, API tokens, the setup code, brute-force limits and the audit entries of these actions (spec 10).
Package auth implements accounts, sessions, API tokens, the setup code, brute-force limits and the audit entries of these actions (spec 10).
buildinfo
Package buildinfo carries the version information set by the linker.
Package buildinfo carries the version information set by the linker.
collector
Package collector polls the devices of one connection, normalises their values, turns counters into energy deltas, nets grid energy and books everything into 15-minute buckets (spec 5, 6).
Package collector polls the devices of one connection, normalises their values, turns counters into energy deltas, nets grid energy and books everything into 15-minute buckets (spec 5, 6).
config
Package config loads the layered configuration (defaults → DB → file → env), decodes it into typed sections and validates its structure.
Package config loads the layered configuration (defaults → DB → file → env), decodes it into typed sections and validates its structure.
configstore
Package configstore persists the UI configuration (spec 3): objects and settings with a revision (config_rev), history snapshots, audit entries with a diff, and encrypted secrets.
Package configstore persists the UI configuration (spec 3): objects and settings with a revision (config_rev), history snapshots, audit entries with a diff, and encrypted secrets.
database
Package database opens the SQLite database, applies the embedded, versioned migrations (always after a verified backup) and makes verified online backups (spec 7.6).
Package database opens the SQLite database, applies the embedded, versioned migrations (always after a verified backup) and makes verified online backups (spec 7.6).
derive
Package derive turns 15-minute buckets into periods (day, month, year, total) and site quantities, caching closed periods in derived_cache (spec 5.1 step 8, 7.3).
Package derive turns 15-minute buckets into periods (day, month, year, total) and site quantities, caching closed periods in derived_cache (spec 5.1 step 8, 7.3).
eventbus
Package eventbus is the typed in-process event bus through which background components meet (AGENTS.md section 4).
Package eventbus is the typed in-process event bus through which background components meet (AGENTS.md section 4).
health
Package health is the single supervisor: it starts restartable components, watches their state and heartbeat, restarts them within a budget and cancels the root context with ErrHealthFatal when that is no longer possible (spec 8.2).
Package health is the single supervisor: it starts restartable components, watches their state and heartbeat, restarts them within a budget and cancels the root context with ErrHealthFatal when that is no longer possible (spec 8.2).
http/handler
Package handler holds the HTTP handlers; they contain no business logic and call services only.
Package handler holds the HTTP handlers; they contain no business logic and call services only.
http/middleware
Package middleware holds HTTP middleware; handlers live in package handler.
Package middleware holds HTTP middleware; handlers live in package handler.
http/router
Package router declares every HTTP route and its access level in one place.
Package router declares every HTTP route and its access level in one place.
http/server
Package server runs the HTTP server lifecycle.
Package server runs the HTTP server lifecycle.
livecache
Package livecache keeps the newest value per live key ("<meter>/<channel>") and publishes a change event for every new value.
Package livecache keeps the newest value per live key ("<meter>/<channel>") and publishes a change event for every new value.
logging
Package logging builds the injected zerolog.Logger: JSON to stdout and, when a file is configured, additionally to a file rotated by timberjack.
Package logging builds the injected zerolog.Logger: JSON to stdout and, when a file is configured, additionally to a file rotated by timberjack.
maintenance
Package maintenance holds the CLI jobs that run with the server stopped: the shared lock next to the database, dumps, backups, backfill, import and data correction (spec 13).
Package maintenance holds the CLI jobs that run with the server stopped: the shared lock next to the database, dumps, backups, backfill, import and data correction (spec 13).
profile
Package profile holds the declarative device profiles (spec 4): schema, loader for built-in and local profiles, validation, decoder and status maps.
Package profile holds the declarative device profiles (spec 4): schema, loader for built-in and local profiles, validation, decoder and status maps.
report
Package report is the pure energy report model (spec 12): complete days of the site quantities go in, sums, ratios, sections, patterns and key figures (with an optional comparison period) come out.
Package report is the pure energy report model (spec 12): complete days of the site quantities go in, sums, ratios, sections, patterns and key figures (with an optional comparison period) come out.
report/csv
Package csv writes a report's buckets as CSV: one row per day, month or year with the site quantities and the derived columns (this app's estimates end in _est_kwh).
Package csv writes a report's buckets as CSV: one row per day, month or year with the site quantities and the derived columns (this app's estimates end in _est_kwh).
report/pdf
Package pdf renders a report as an A4 PDF (spec 12): a summary page with key figures, energy charts and where the energy came from and went, the sections the site has (battery, PV sources, loadpoints, load profile), patterns, comparison and data quality, a compact table and a last page on how the report is calculated.
Package pdf renders a report as an A4 PDF (spec 12): a summary page with key figures, energy charts and where the energy came from and went, the sections the site has (battery, PV sources, loadpoints, load profile), patterns, comparison and data quality, a compact table and a last page on how the report is calculated.
service
Package service holds the read services behind the HTTP handlers.
Package service holds the read services behind the HTTP handlers.
simulate
Package simulate provides fake device sources for "pvmon simulate": a small, deterministic household model whose values are encoded through the real profiles, so the whole pipeline runs as with real devices (spec 13).
Package simulate provides fake device sources for "pvmon simulate": a small, deterministic household model whose values are encoded through the real profiles, so the whole pipeline runs as with real devices (spec 13).
site
Package site builds the effective site model from configured connections, devices and meters plus their profiles: roles, categories, hierarchy, the series catalogue and the capabilities the UI is built from (spec 2, 3, 11).
Package site builds the effective site model from configured connections, devices and meters plus their profiles: roles, categories, hierarchy, the series catalogue and the capabilities the UI is built from (spec 2, 3, 11).
sitecalc
Package sitecalc computes the live site quantities (spec 5.5) from the live cache: on a change of a meter value, debounced, and on a refresh tick so missing inputs remove the quantity.
Package sitecalc computes the live site quantities (spec 5.5) from the live cache: on a change of a meter value, debounced, and on a refresh tick so missing inputs remove the quantity.
storage
Package storage is the sole owner of the SQLite database.
Package storage is the sole owner of the SQLite database.
transport/http
Package http is the HTTP(S) JSON transport: GET requests only, basic and digest authentication, no redirects to other hosts, per-request timeouts and backoff after failures (spec 4.4, 10).
Package http is the HTTP(S) JSON transport: GET requests only, basic and digest authentication, no redirects to other hosts, per-request timeouts and backoff after failures (spec 4.4, 10).
transport/modbus
Package modbus is the Modbus TCP/RTU transport: one shared connection with a FIFO request queue per address, raw register reads (FC 03/04 only), error classification and reconnect with exponential backoff.
Package modbus is the Modbus TCP/RTU transport: one shared connection with a FIFO request queue per address, raw register reads (FC 03/04 only), error classification and reconnect with exponential backoff.
util
Package util holds small dependency-free helpers shared by all packages: the injected Clock, dependency checks, the Slot container and numeric helpers.
Package util holds small dependency-free helpers shared by all packages: the injected Clock, dependency checks, the Slot container and numeric helpers.
util/clocktest
Package clocktest provides a manually driven util.Clock for tests: time only moves when the test calls Advance or Set, so polling, backoff and debounce run without sleeps.
Package clocktest provides a manually driven util.Clock for tests: time only moves when the test calls Advance or Set, so polling, backoff and debounce run without sleeps.
ws
Package ws serves live values over WebSocket (spec 9.3): subscriptions per client, a per-client diff against what was sent, pushes coalesced into one frame per tick.
Package ws serves live values over WebSocket (spec 9.3): subscriptions per client, a per-client diff against what was sent, pushes coalesced into one frame per tick.
Package profiles embeds the built-in device profiles into the binary (spec 4.5).
Package profiles embeds the built-in device profiles into the binary (spec 4.5).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL