Development
pip install -r requirements_test.txt
pytest tests/
cd frontend && npm ci && npm test && npm run check-distThe card source is in frontend/. The compiled bundle in custom_components/spotnav/www/ and its language files in www/i18n/ are committed. npm run build regenerates both, and npm run check-dist fails while either is stale.
docs/supported.md is generated from the integration's own tables: edit tools/gen_supported.py and run python tools/gen_supported.py, never the page itself.
Pull requests are welcome, for code as well as translations.
Reporting a problem
Open an issue with the bug report form, then send the debug info from the card (Settings → Support → Send debug info) and mention the reference it shows. Or download the file and e-mail it to support@sensnology.se with the issue's number in the subject. The file holds your entity names and charging times, so do not attach it to the public issue. See Troubleshooting.
Type checking (Pyright)
Pyright runs in basic mode over custom_components/spotnav (config in pyrightconfig.json, Home Assistant's own types from the installed homeassistant). CI runs the "Pyright ratchet" job in .github/workflows/validate.yml.
pip install pyright==1.1.414
python tools/typecheck_ratchet.py # check, as CI does
python tools/typecheck_ratchet.py --update # lower the baseline after fixing errors
python -m pyright path/to/file.py # see the actual errors
The baseline is tools/pyright_baseline.json (error count per file). Use the same Home Assistant version as requirements_test.txt, since the counts depend on its types.
Broad excepts
tests/test_broad_except_ratchet.py counts except Exception and bare except: per module and fails if a module gains one, or loses one without the baseline being lowered. Prefer catching the specific errors.
python tests/test_broad_except_ratchet.py --update # rewrite tests/broad_except_baseline.json
Battery recipe revisions
A battery recipe's revision (BrandControl.recipe_rev in battery/commands.py) is part of the key a plant's check is kept under, so raising it makes every plant of that brand run the check again, as after a firmware update. tests/test_recipe_fingerprints.py holds each revision to what the recipe writes: a fingerprint per brand (tests/fixtures/battery/recipe_fingerprints.json) hashes the recipe's control data (roles, entities, services, orders, the writes each action returns at fixed rates, hold variants, phase spec, expiry renewals; never notes or test flags) and the writes its golden traces pin (tests/fixtures/battery/golden/, control_trace*.json, expiry_golden.json: service calls, entities, values and their order, never logs or times). The test fails when a brand's writes changed while its revision did not.
python tools/recipe_fingerprints.py # check, as the test does
python tools/recipe_fingerprints.py --update # refresh; refused for a brand whose writes changed at the same revision
git worktree add --detach /tmp/last v3.0.0b8 # a read-only checkout of the last release
python tools/recipe_fingerprints.py --since /tmp/last # the brands whose writes changed since then, and where
When a brand's writes change, raise its recipe_rev by one and run --update. New golden coverage alone needs only --update. A change to how much SpotNav charges or when (the plan, the fuse margins) is not a recipe change: it writes the same things to the plant in the same order, and does not raise a revision. --rehash rewrites every hash and is only for a change to the tool's own canonical form.