Files
hassio-integration-perfectd…/custom_components/perfectdraft/strings.json
T
rickandCursor 0f3b4c20af fix: make reauth update the existing entry instead of aborting
async_step_token is shared by the user and reauth sources but was written
only for the former. It called _abort_if_unique_id_configured() on every
path, and during reauth the unique ID belongs to the entry being repaired,
so the duplicate guard fired by design: authentication succeeded, the flow
aborted with already_configured, the new tokens were discarded, and the
coordinator's next poll re-raised the reauth repair. The integration was
unrecoverable through the UI short of delete-and-re-add, which costs entity
history and the restored keg-freshness baseline.

Branch on self.source at the terminal step, per HA's documented pattern for
flows shared between setup and reauth: reauth now guards with
_abort_if_unique_id_mismatch() and persists through
async_update_reload_and_abort(), which merges the new tokens into the
existing entry, keeps email and machine ID, reloads, and aborts with
reauth_successful. The user path keeps _abort_if_unique_id_configured()
unchanged.

Reauth also stops re-fetching /api/me when the entry already records a
machine ID, removing a round trip from a flow the user waits on and a
failure mode where a transient /api/me error turned a successful sign-in
into cannot_connect.

The helpers require core 2024.11, so declare that floor in hacs.json —
otherwise older cores would AttributeError mid-flow, which is worse than
the bug being fixed.

Adds the repo's first HA test harness (requirements-test.txt, opt-in) with
regression tests covering token persistence, entry reload, account
mismatch, case-insensitive email, and the explicit assertion that reauth
never aborts as already_configured. tests/test_keg_detection.py still runs
standalone under python3 -m unittest.

Version set to 0.3.1 rather than the 0.4.0 that PR #2 introduced; no
v0.4.0 tag was ever cut, so nothing was released under that number.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-06 15:26:48 +02:00

68 lines
2.4 KiB
JSON

{
"config": {
"step": {
"user": {
"title": "PerfectDraft Account",
"description": "Enter your PerfectDraft app credentials.",
"data": {
"email": "Email",
"password": "Password"
}
},
"token": {
"title": "Verification Token",
"description": "Paste a verification token from PerfectDraft's website. See the [setup instructions](https://github.com/Falkvinge/hassio-integration-perfectdraft-pro#step-2-verification-token) for the 30-second walkthrough. The token expires in 2 minutes, so generate it right before pasting.",
"data": {
"recaptcha_token": "Verification Token"
}
},
"reauth_confirm": {
"title": "Re-authenticate PerfectDraft",
"description": "Your session has expired. Please re-enter your credentials.",
"data": {
"email": "Email",
"password": "Password"
}
}
},
"error": {
"invalid_auth": "Authentication failed. Token may have expired (2 min limit) or credentials are wrong. Try again with a fresh token.",
"cannot_connect": "Cannot connect to PerfectDraft service.",
"unknown": "An unexpected error occurred."
},
"abort": {
"already_configured": "This PerfectDraft account is already configured.",
"reauth_successful": "Re-authentication successful.",
"reauth_account_mismatch": "Those credentials are for a different PerfectDraft account. Re-authenticate with the account this integration was set up with, or delete the integration and add the other account separately."
}
},
"entity": {
"sensor": {
"temperature": { "name": "Temperature" },
"keg_remaining": { "name": "Keg Remaining" },
"keg_product_id": { "name": "Keg Product" },
"keg_name": { "name": "Keg" },
"connection": { "name": "Connection" },
"door": { "name": "Door" },
"pours": { "name": "Pours" },
"last_pour": { "name": "Last Pour" },
"firmware": { "name": "Firmware" },
"mode": { "name": "Mode" },
"keg_freshness": { "name": "Keg Freshness" }
},
"button": {
"mark_keg_changed": { "name": "Mark Keg Changed" }
}
},
"options": {
"step": {
"init": {
"title": "PerfectDraft Options",
"data": {
"scan_interval": "Polling interval (seconds)"
}
}
}
}
}