Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5f32d956e | ||
|
|
529894688b | ||
|
|
c77029188f | ||
|
|
9a81654579 | ||
|
|
2050051f66 | ||
|
|
704f55e595 | ||
|
|
851ec3a495 |
@@ -192,6 +192,7 @@ When the user corrects your approach, append a one-line rule here before ending
|
||||
- **`numberOfPoursSinceStartup` resets to 0 on a machine power cycle** (confirmed 2026-06-01: power-cycled the machine at pours=16, reloaded the integration, Pours read 0). It counts since machine startup, NOT since keg insertion. Do not base keg-change detection on the pour counter — a power cycle (outage, unplug, firmware update) would false-trigger it. `kegVolume` (Keg Remaining) was confirmed unchanged across the same power cycle/reload, so a power cycle produces no spurious volume jump — volume-jump signals (b/c) and the manual button are the power-cycle-safe detectors; prefer them.
|
||||
- **TODO — verification debt, do this when the next keg is fitted: confirm the keg-freshness baseline survives a reauth.** `fix-reauth-flow` (archived 2026-09-06) was verified on-device for the reauth flow itself, but the machine had no keg in the tap, so there was no freshness countdown to preserve and task 6.6 could not be checked. The fix uses `async_update_reload_and_abort`, which reloads the config entry — the exact moment a `RestoreEntity` baseline could be lost. After the next keg change, trigger a reauth (or reload the integration) and confirm Keg Freshness keeps its countdown instead of resetting to unknown. If it resets, that is a real regression in `PerfectDraftKegFreshnessSensor`'s restore path, not in the config flow.
|
||||
- **Never add a non-numeric key to `keg_catalog.json`.** `_load_keg_catalog` in `sensor.py` builds `{int(k): v for k, v in raw.items()}` and catches `ValueError` by returning `{}`. A single `_meta` or `_source` key therefore disables the *entire* catalog — every keg reports no name — and says so only at debug level. Recording provenance or attribution inside that file requires changing the loader first. `tests/test_keg_catalog.py::test_keys_are_numeric` guards this.
|
||||
- **Every UI string change needs English and French (since 0.4.6, 2026-11-07).** When you add, rename or remove a key in `strings.json`, make the same change to `translations/en.json` and `translations/fr.json` in the same commit, keeping each `{placeholder}` name. Write a real French string: no English placeholder, and do not relax `tests/test_translations.py`, which fails on any key mismatch. The maintainer chose strict parity over Home Assistant's English fallback so French never silently falls behind. Keep button and entity names short; they display in narrow UI space.
|
||||
- **A new integration catalog ID is not done until the card maps it.** The companion card joins on `kegId` against `scripts/keg-catalog.reference.json`. Adding a row to `keg_catalog.json` without binding the card entry (and re-syncing that snapshot) ships a named **Keg** sensor that the card still treats as unknown. The card may already have the beer under a slug with no `kegId` — check before adding a duplicate entry.
|
||||
- **TODO — verification debt from `backport-keg-catalog` (archived 2026-09-06), clear this after installing v0.3.2 via HACS: confirm the `Keg` sensor still resolves the fitted keg.** The catalog file was replaced wholesale (86 → 114 entries) and verified statically only: exact diff shape, 114 int keys through the loader, and format guards in `tests/test_keg_catalog.py`. What was never exercised is the live path. On-device checks were impossible at the time — no HA on the dev host, and `.credentials.json`'s refresh token had expired (`NotAuthorizedException: Refresh Token has expired`), so even `test_harness.py` could not reach the API. Task group 5 in the archived change lists the four checks.
|
||||
- **`test_harness.py` is stale: it reads `user_id` from `.credentials.json`, which now holds `email` / `access_token` / `id_token` / `refresh_token`.** It exits before doing anything useful. Fix the key names (and refresh the token per the README's reCAPTCHA step) before relying on it.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"domain": "perfectdraft",
|
||||
"name": "PerfectDraft",
|
||||
"version": "0.4.5",
|
||||
"version": "0.4.6",
|
||||
"documentation": "https://github.com/Falkvinge/hassio-integration-perfectdraft-pro",
|
||||
"issue_tracker": "https://github.com/Falkvinge/hassio-integration-perfectdraft-pro/issues",
|
||||
"codeowners": ["@Falkvinge"],
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"config": {
|
||||
"step": {
|
||||
"user": {
|
||||
"title": "Compte PerfectDraft",
|
||||
"description": "Entrez vos identifiants de l'application PerfectDraft.",
|
||||
"data": {
|
||||
"email": "Adresse e-mail",
|
||||
"password": "Mot de passe"
|
||||
}
|
||||
},
|
||||
"token": {
|
||||
"title": "Jeton de vérification",
|
||||
"description": "Collez le jeton de vérification depuis le site PerfectDraft. Consultez les [instructions d'installation](https://github.com/Falkvinge/hassio-integration-perfectdraft-pro#step-2-verification-token) pour le guide pas à pas de 30 secondes. Le jeton expire en 2 minutes, générez-le juste avant de le coller.",
|
||||
"data": {
|
||||
"recaptcha_token": "Jeton de vérification"
|
||||
}
|
||||
},
|
||||
"reauth_confirm": {
|
||||
"title": "Réauthentification PerfectDraft",
|
||||
"description": "Votre session a expiré. Veuillez saisir à nouveau vos identifiants.",
|
||||
"data": {
|
||||
"email": "Adresse e-mail",
|
||||
"password": "Mot de passe"
|
||||
}
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"invalid_auth": "Échec de l'authentification : {reason}. Réessayez avec un nouveau jeton.",
|
||||
"invalid_credentials": "PerfectDraft a rejeté l'adresse e-mail ou le mot de passe : {reason}.",
|
||||
"token_rejected": "PerfectDraft a rejeté le jeton de vérification : {reason}. Générez un nouveau jeton et collez-le sous 2 minutes.",
|
||||
"cannot_connect": "Impossible de se connecter au service PerfectDraft.",
|
||||
"unknown": "Une erreur inattendue s'est produite."
|
||||
},
|
||||
"abort": {
|
||||
"already_configured": "Ce compte PerfectDraft est déjà configuré.",
|
||||
"reauth_successful": "Réauthentification réussie.",
|
||||
"reauth_account_mismatch": "Ces identifiants correspondent à un autre compte PerfectDraft. Réauthentifiez-vous avec le compte initial de cette intégration, ou supprimez l'intégration et ajoutez l'autre compte séparément.",
|
||||
"already_in_progress": "La configuration pour ce compte PerfectDraft est déjà en cours. Terminez ou annulez la configuration en attente dans Paramètres > Appareils et services."
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"temperature": { "name": "Température" },
|
||||
"keg_remaining": { "name": "Niveau du fût" },
|
||||
"keg_product_id": { "name": "ID du fût" },
|
||||
"keg_name": { "name": "Fût" },
|
||||
"connection": { "name": "Connexion" },
|
||||
"door": { "name": "Porte" },
|
||||
"pours": { "name": "Tirages" },
|
||||
"last_pour": { "name": "Dernier tirage" },
|
||||
"firmware": { "name": "Firmware" },
|
||||
"mode": { "name": "Mode" },
|
||||
"keg_freshness": { "name": "Fraîcheur du fût" }
|
||||
},
|
||||
"button": {
|
||||
"mark_keg_changed": { "name": "Marquer le fût changé" }
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"step": {
|
||||
"init": {
|
||||
"title": "Options PerfectDraft",
|
||||
"data": {
|
||||
"scan_interval": "Intervalle d'actualisation (secondes)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-11-07
|
||||
@@ -0,0 +1,35 @@
|
||||
## Context
|
||||
|
||||
PR #14 is one commit, `704f55e` by aurel <aurelien.ruat@hotmail.fr>, whose parent is the current `master` head (`851ec3a`). GitHub reports it mergeable with no conflicts. Checked before this change:
|
||||
|
||||
- `fr.json` has exactly the key set of `strings.json` and `en.json`, which also match each other.
|
||||
- Every `{reason}` placeholder and the README link in the token step are carried over.
|
||||
- The full suite passes on the PR branch: 77 tests, 587 subtests, including the new `test_translations.py`.
|
||||
|
||||
`git fetch github pull/14/head` makes the commit available locally.
|
||||
|
||||
## Goals / Non-Goals
|
||||
|
||||
**Goals:**
|
||||
- Ship the contribution byte-for-byte, with aurel as the commit author, and have GitHub show PR #14 as merged.
|
||||
|
||||
**Non-Goals:**
|
||||
- Editing the French wording or the contributed test (style, unittest vs pytest, hardcoded `("en", "fr")`).
|
||||
|
||||
## Decisions
|
||||
|
||||
**Merge the original commit, not a squash or a re-applied diff.** The worktree branch `agent/add-french-translation` starts at `master` and fast-forwards to `704f55e`; the version bump is a separate maintainer commit on top. When the branch is later merged into `master` and pushed to `github`, `704f55e` is reachable from the PR's base branch, so GitHub marks PR #14 merged and attributes the commit to aurel. Squashing or cherry-picking would change the hash, lose that link, and need a manual PR close.
|
||||
|
||||
**Integration-only patch release (0.4.6).** The card has no translation files, so it is unchanged. The versioning rule in `PROJECT_HYGIENE.md` allows a diverging patch.
|
||||
|
||||
**Keep the test strict.** Home Assistant falls back to English for missing keys, so partial translations would work at runtime. The maintainer chose exact parity instead, so French never falls silently behind. The cost is one more file to touch per string change, recorded in `PROJECT_HYGIENE.md`.
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
- [A future agent adds a string to `strings.json` and `en.json` only] → The test fails in that change; the `PROJECT_HYGIENE.md` note tells the agent to write the French entry rather than relax the test.
|
||||
- [The new strings are shown on a narrow UI and truncate] → Not seen in testing, and the contributor runs it live. Fix in a follow-up only if a user reports it.
|
||||
- [No on-device check on the dev host] → As with 0.4.4 and 0.4.5, there is no Home Assistant on the dev host. The contributor's own instance is the live check; the static checks above cover the files.
|
||||
|
||||
## Migration Plan
|
||||
|
||||
None. Updating via HACS and restarting Home Assistant picks up `fr.json`. Rollback is reinstalling 0.4.5.
|
||||
@@ -0,0 +1,34 @@
|
||||
## Why
|
||||
|
||||
[PR #14](https://github.com/Falkvinge/hassio-integration-perfectdraft-pro/pull/14) from @Aurel004 (aurel) adds a complete French translation, so French-language Home Assistant installs show the config flow, errors and entity names in French instead of English. The contributor runs it on his own instance and checked the AI-generated strings by hand; the maintainer had a native French speaker look at it too. It is a first contribution, so it ships exactly as submitted, with his authorship kept.
|
||||
|
||||
## What Changes
|
||||
|
||||
- Merge the PR's single commit (`704f55e`, authored by aurel) unchanged. It adds:
|
||||
- `custom_components/perfectdraft/translations/fr.json`, covering every key in `strings.json`.
|
||||
- `tests/test_translations.py`, which fails when `en.json` or `fr.json` has a different key structure from `strings.json`.
|
||||
- No wording edits. "Marquer le fût changé" stays as submitted; it is correct, and shorter text suits the button label.
|
||||
- Bump the integration to 0.4.6. The card has no translations and stays at 0.4.5, which the versioning rule allows (shared major.minor, patch may diverge).
|
||||
- Record in `PROJECT_HYGIENE.md` that from now on every new or renamed UI string needs an English and a French entry, because the new test enforces exact key parity.
|
||||
- Release v0.4.6 crediting @Aurel004.
|
||||
|
||||
Not in scope:
|
||||
|
||||
- Translated entity states or attributes. `strings.json` defines none, so there is nothing to translate.
|
||||
- Other languages, or loosening the parity test to allow partial translations.
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
|
||||
None.
|
||||
|
||||
### Modified Capabilities
|
||||
|
||||
- `hacs-packaging`: the "Translations" requirement covers English only. It now also requires a French translation and exact key parity between `strings.json` and every shipped translation file.
|
||||
|
||||
## Impact
|
||||
|
||||
- Users with Home Assistant set to French see French labels after updating. Existing entity IDs are kept in the entity registry and don't change; only display names do. Everyone else is unaffected.
|
||||
- Contributors and agents: any change to `strings.json` must update `translations/en.json` and `translations/fr.json` in the same commit, or `tests/test_translations.py` fails.
|
||||
- Files: `custom_components/perfectdraft/translations/fr.json` (new), `tests/test_translations.py` (new), `custom_components/perfectdraft/manifest.json` (version), `PROJECT_HYGIENE.md` (main checkout).
|
||||
@@ -0,0 +1,19 @@
|
||||
## MODIFIED Requirements
|
||||
|
||||
### Requirement: Translations
|
||||
The integration SHALL provide English and French UI strings for all config flow steps, errors, abort reasons, options, and entity names. Every shipped translation file SHALL have exactly the same key structure as `strings.json`.
|
||||
|
||||
#### Scenario: Translation files
|
||||
- **WHEN** HA renders the integration UI
|
||||
- **THEN** `strings.json` and `translations/en.json` SHALL provide labels for all steps, fields, errors, and entity names
|
||||
- **THEN** descriptions SHALL not contain curly braces (parsed as translation placeholders) or newlines (cause MALFORMED_ARGUMENT)
|
||||
|
||||
#### Scenario: French UI
|
||||
- **WHEN** HA renders the integration UI with its language set to French
|
||||
- **THEN** `translations/fr.json` SHALL provide French labels for all steps, fields, errors, abort reasons, options, and entity names
|
||||
- **THEN** each French string SHALL use the same `{placeholder}` names as its English counterpart
|
||||
|
||||
#### Scenario: Key parity
|
||||
- **WHEN** a key is added to, renamed in, or removed from `strings.json`
|
||||
- **THEN** `translations/en.json` and `translations/fr.json` SHALL be updated to the same key structure in the same change
|
||||
- **THEN** the test suite SHALL fail if any of the three files has a key the others lack
|
||||
@@ -0,0 +1,23 @@
|
||||
## 1. Worktree and contribution
|
||||
|
||||
- [x] 1.1 `scripts/agent-worktree.sh create add-french-translation`; verify `.worktree/add-french-translation/.agent-lock` exists and `git worktree list` shows branch `agent/add-french-translation` at `master`
|
||||
- [x] 1.2 `git fetch github pull/14/head`, then put the worktree branch on `704f55e5958717899fea2265f1a3c627dd4cde9d`; verify `git log -1 --format='%H %an'` shows `704f55e…` by aurel and `git diff 851ec3a --stat` lists only `translations/fr.json` and `tests/test_translations.py`
|
||||
- `master` had moved on by the proposal commit (`2050051`, `openspec/` only), so `--ff-only` was impossible. The fresh branch had no commits of its own, so it was reset to `704f55e` (parent `851ec3a`) instead; the commit is unchanged. Diff vs `851ec3a`: the two files, 109 insertions
|
||||
- [x] 1.3 Verify the contribution against the spec: `fr.json` key set equals `strings.json`, and every string uses the same `{placeholder}` names as `strings.json`; then `../../.venv-test/bin/pytest tests/` from the worktree passes, including `test_translations.py`
|
||||
- 34 keys match, no placeholder mismatches; 77 passed, 587 subtests passed
|
||||
|
||||
## 2. Version
|
||||
|
||||
- [x] 2.1 Bump `custom_components/perfectdraft/manifest.json` to 0.4.6 and commit as the maintainer; verify `git diff HEAD~1` is the single version line and the full suite still passes. Record the commit hash here
|
||||
- Commit `9a81654` on `agent/add-french-translation`, on top of `704f55e`; one-line diff; 77 passed, 587 subtests passed
|
||||
|
||||
## 3. Project hygiene
|
||||
|
||||
- [x] 3.1 Add a line to `PROJECT_HYGIENE.md` section 11 (main checkout): every new, renamed or removed key in `strings.json` must be mirrored in `translations/en.json` and `translations/fr.json` in the same commit, with a French string written rather than an English placeholder or a relaxed test; `tests/test_translations.py` enforces it. Commit in the main checkout; verify with `git log -1 -- PROJECT_HYGIENE.md`
|
||||
|
||||
## Workflow follow-up
|
||||
|
||||
- Archive per `AGENTS.md`: merge `agent/add-french-translation` into `master` with `--no-ff` (keeps `704f55e` intact), push `master` to `origin` and `github`, sync the `hacs-packaging` delta into `openspec/specs/`, archive, remove the worktree and branch.
|
||||
- After the push, confirm via the GitHub API that PR #14 reports `merged: true`. If it doesn't, close it with a comment linking the merge commit.
|
||||
- Tag `v0.4.6` and publish the GitHub release "v0.4.6 — French translation" in the format of v0.4.5: French UI for setup, errors and entity names; thanks to @Aurel004 for [#14](https://github.com/Falkvinge/hassio-integration-perfectdraft-pro/pull/14); note that the card stays at 0.4.5, no breaking changes, no re-configuration.
|
||||
- Comment on PR #14 with a thank-you and the release link.
|
||||
@@ -0,0 +1,39 @@
|
||||
"""Verify that translation files match strings.json key structure."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
COMPONENT_DIR = Path(__file__).parent.parent / "custom_components" / "perfectdraft"
|
||||
|
||||
|
||||
def _key_paths(obj, prefix=""):
|
||||
paths = set()
|
||||
if isinstance(obj, dict):
|
||||
for k, v in obj.items():
|
||||
full = f"{prefix}.{k}" if prefix else k
|
||||
if isinstance(v, dict):
|
||||
paths |= _key_paths(v, full)
|
||||
else:
|
||||
paths.add(full)
|
||||
return paths
|
||||
|
||||
|
||||
class TestTranslations(unittest.TestCase):
|
||||
def test_en_and_fr_match_strings_json_keys(self):
|
||||
strings = json.loads(
|
||||
(COMPONENT_DIR / "strings.json").read_text(encoding="utf-8")
|
||||
)
|
||||
expected = _key_paths(strings)
|
||||
|
||||
for lang in ("en", "fr"):
|
||||
with self.subTest(lang=lang):
|
||||
data = json.loads(
|
||||
(COMPONENT_DIR / "translations" / f"{lang}.json").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
)
|
||||
self.assertEqual(_key_paths(data), expected)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user