Skip to content

Latest commit

 

History

History
163 lines (132 loc) · 8.02 KB

CONTRIBUTING.md

File metadata and controls

163 lines (132 loc) · 8.02 KB

Contributing

Energy Node started on one specific site's hardware, but the goal is a flexible, general solution anyone with a remote energy site could run as-is — see Background. Getting there is what contributions are for, and every kind is welcome: bug reports, fixes, documentation, dashboard improvements, and pushing site-specific assumptions out into configuration.

What helps the most is support for a family of devices Energy Node doesn't cover yet — a new bridge widens what everyone can monitor without touching the rest of the system. If you only send one thing upstream, make it that; see New device services below.

(Forking and adapting privately is fine too, and no one expects you to upstream that work — but it is no longer the assumed way to use this.)

Before you start

  • For anything beyond a small fix, open an issue first describing the change. This is a single-maintainer project; a heads-up avoids wasted work on a PR that doesn't fit the architecture in dashboard/AGENTS.md or the invariants documented under docs/.
  • Bridge- or dashboard-specific conventions live next to the code (dashboard/AGENTS.md, the module docstrings under services/ and libs/). Read the one for the area you're touching before changing it.
  • The README and the documentation are in English, but most comments in the code are still German.
  • Maintainer notes that are not on the documentation site live in docs/_internal/.

New device services

The most useful thing you can send upstream is a bridge for hardware Energy Node doesn't support yet — another inverter, meter, battery stick or switchable load. The device-service pattern is deliberately uniform, so a new one is mostly filling in a known shape rather than inventing architecture:

  • Each service is a single systemd unit that polls one family of hardware locally, with no cloud account, and publishes Home Assistant MQTT Discovery entities under outstation/<id>/…. Nothing talks HTTP to the dashboard — the broker is the only coupling.
  • libs/energy_node_common/ already provides the MQTT setup and last will, discovery-payload construction, availability publishing, the poll scheduler with its separate diagnostic-poll cycle, the central config loader, and both sides of the master/slave poll-rate protocol. A new bridge consumes that package; it should not re-implement any of it.
  • services/shelly/ (read + switch) and services/trucki/ (read-only) are the cleanest templates. Copy the one whose direction matches your device.
  • Ship the service with a *_devices.schema.json next to it — the dashboard renders that schema as the configuration form, so a new service is editable from the UI with no dashboard changes.
  • Keep it honest on a Raspberry Pi 1: declare capabilities per device rather than probing for them, put slow-changing values on the diagnostic cycle, never publish credentials, and support the MQTT simulation mode every other slave has.

docs/services/index.md describes every existing service and the conventions they share — read it before starting. Open an issue naming the hardware first, so the maintainer can flag anything site-specific that would block a merge.

Development setup

See INSTALLATION.md ("Development machine") for the full environment. In short:

python3 -m venv .venv && .venv/bin/pip install -e libs/energy_node_common -e libs/battery_soc_core pytest
.venv/bin/pip install -r requirements-dev.txt   # needed for the full services/ test suite

The Home Assistant integration needs its own virtualenv, because pytest-homeassistant-custom-component pulls plugins that conflict with the plain suite. Build it once:

python3.14 -m venv .venv-ha
.venv-ha/bin/pip install -e ./libs/battery_soc_core -r integrations/homeassistant/requirements-test.txt

Running the checks

Run whichever of these apply to your change before opening a PR — CI runs all of them:

.venv/bin/pytest services libs scripts/tests                                    # Python bridges + tooling
bash scripts/tests/test_publish_mirror.sh                             # HACS mirror assembly
cd integrations/homeassistant && ../../.venv-ha/bin/pytest            # HA integration
cd dashboard && gofmt -l . && go vet ./... && go test ./...           # Go dashboard
cd dashboard && npm install && npm test                               # dashboard JS
dashboard/test/smoke/smoke.sh                                        # real dashboard with fakes, no Pi, no broker

Deploying to your own node

The installer's developer CLI builds a bundle from your checkout and runs the same bootstrap steps on a node that the installer's UI runs. scripts/dev/run-installer.sh builds the installer and passes every argument through, so a subcommand works as well:

scripts/dev/run-installer.sh deploy --dev-unsigned --dry-run            # preview what would change
scripts/dev/run-installer.sh deploy --dev-unsigned                      # full deploy
scripts/dev/run-installer.sh deploy --dev-unsigned --only dashboard     # or a single step
scripts/dev/run-installer.sh diagnose                                   # check the node
scripts/dev/run-installer.sh restart --only shelly                      # restart without deploying

The target node comes from secrets/deploy-target.env. For that file, SSH authentication and every subcommand, see Installer developer CLI.

Secrets

Never commit real credentials, IPs from your own site's private range, or device serials — see docs/operating/secrets.md. ./scripts/dev/check_tracked_secrets.sh scans tracked files for obvious leaks; run it before pushing.

Disclose AI use

If an AI coding assistant helped write your change, say so in the PR description — see AI-DISCLAIMER.md for what to include and why. This is a hard requirement, not a preference.

Commit hygiene

Commit messages follow Conventional Commits: a type(scope): summary subject, where type is one of feat, fix, docs, test, refactor, chore, ci, build or perf, and scope names the area touched (dashboard, shelly, battery-soc, docs, …). Keep the summary imperative and under ~72 characters; put the rationale in the body. This is a rule, not a suggestion — matching the existing history in git log is the quickest way to get it right.

Mark a breaking change with a ! before the colon (feat!: …, fix(dashboard)!: …). The generated component changelog keeps the commit in its normal section but prefixes the entry with ⚠ Breaking.

Opening and merging a PR

Open PRs with scripts/dev/create-pr.sh and merge them with scripts/dev/merge-pr.sh. The script fills the whole PR template, so nothing is maintained by hand afterwards. The PR title is the squash subject. The fenced block in the description is the squash body: it never repeats the title and ends with Co-authored-by: Claude Sonnet|Opus x.y <noreply@anthropic.com>, never Haiku. Pass the model as PR_AI_MODEL="Sonnet 5.5", the test suites you ran as PR_SUITES, and optionally PR_SUMMARY, PR_ISSUE or PR_MESSAGE_FILE. merge-pr.sh --check validates the message without merging.

Per-component VERSION files are patch-bumped on the PR branch by CI (.github/workflows/version-bump.yml); major/minor you bump by hand on the branch. CI (.github/workflows/ci.yml, the Vendored artefacts in sync job) also fails a PR that leaves the vendored battery_soc_core copy under integrations/homeassistant/, the vendored battery-card-core.js in the Lovelace card, or the generated energy-node-icons.js out of sync with their sources — run .venv/bin/python scripts/vendor_core.py / scripts/vendor_card.py / scripts/icons/flatten_icons.py and commit the result if any fires.