15 Commits
Author SHA1 Message Date
rick 48434a7af3 Merge agent/add-keg-48180: Camden Stout (48180) in the keg catalog 2026-11-07 12:23:49 +01:00
8b2c4418b3 Add keg 48180 (Camden Stout) to the catalog
Observed by MThomas564 on a machine with the keg fitted (#9, PR #10).
Appended after 48134 to keep numeric key order; catalog floor ratchets
to 117.

Co-authored-by: MThomas564 <mattraethomas97@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-07 12:07:47 +01:00
rickandCursor f489b4e915 README: say 'Click THIS BLACK BOX' so users know where to click
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-07 11:59:09 +01:00
rickandCursor 6ca1f1ff4e README: copy the token with an on-page button
Chromium truncates prompt() default values at 2,000 characters, cutting off the ~2,500-character token. The command now adds a 'Click to copy' button whose handler calls navigator.clipboard.writeText; the click supplies the user activation the Clipboard API needs in every browser. The token is also logged as a fallback.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-07 11:56:13 +01:00
rickandCursor 77967e5244 README: one token command, handed over in a pre-selected prompt
Console copy() cannot copy a value that arrives asynchronously in Firefox (it only sets a helper result read when the command returns) or Chromium (copy is gone by then). A second command would work but adds a step. Instead the single command opens prompt() with the token selected, so Ctrl+C/Cmd+C copies it, and also logs it as a fallback.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-07 11:51:02 +01:00
rickandCursor 8b2f8ce1c3 README: two-step token copy that also works in Firefox
Firefox's console copy() only records a helper result that is read when the command returns, so calling it from the token promise copied nothing. Store the token in window.pdToken, then copy(pdToken) in a second command, which every browser supports.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-07 11:48:45 +01:00
rickandCursor 20ed62b963 Sign in via Cognito directly so PerfectDraft gets the domain
PerfectDraft's Cognito PreAuthentication Lambda now requires a "domain"
field in ClientMetadata. The api.perfectdraft.com /authentication/sign-in
gateway does not forward it, so every setup and reauth failed with
"PreAuthentication failed with error 'domain'" (#11, #12, #13).
authenticate() now calls Cognito InitiateAuth (USER_PASSWORD_AUTH)
itself, the endpoint token refresh already uses.

A failed sign-in now says what was rejected and why. A wrong email or
password returns to the credentials form; a rejected token stays on the
token step; both show Cognito's reason instead of the old blanket "token
may have expired", which hid this outage.

The README snippet copies the token to the clipboard. It captures copy()
up front because Chromium removes it once the console command returns.

Root cause and fix by @cesa030 in #11; confirmed in @brettjenkins' fork.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-07 11:20:47 +01:00
rickandCursor 3b82df6e83 Add Camden Eazy (47792) to the keg name catalog.
The Keg sensor stayed blank for this product ID. 47629 remains Camden Eazy IPA.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-26 07:14:57 +02:00
rickandCursor fc8a25c41a Add Anheuser-Busch Bud (48050) to the keg name catalog
The DE/AT wrap is a distinct SKU from the UK Budweiser keg at 31747.
Observed from a fitted machine in issue #3. Bump to 0.3.3.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 12:41:54 +02:00
rick 44fd73f661 Credit the catalog backport and guard its format
Companion to the previous commit, which is Brett Jenkins' catalog work
cherry-picked with authorship intact rather than copied in as data. This
commit adds what the backport needs around it.

README: credit Brett and his fork for the keg name sensor, the Keg and
Keg Product sensors, and the whole 114-entry catalog, and explain why the
catalog is hand-maintained — the API will not return the ID-to-name
mapping in bulk, so every entry is observed from a machine with that keg
fitted and none of it can be inferred. Also tells a user with a blank Keg
sensor to report their Keg Product ID, which is the only way the catalog
grows.

tests/test_keg_catalog.py: format and content guards for the spec
scenarios, stdlib-only so it runs under python3 -m unittest alongside
test_keg_detection.py without the opt-in HA harness.

Two of those guards cover failure modes that are silent rather than loud:

  - Duplicate keys. json.loads() keeps the last one, so a repeated ID
    would quietly discard an observed name. Only a pair-count comparison
    sees it.

  - Non-numeric keys. _load_keg_catalog builds {int(k): v ...} and
    catches ValueError by returning an empty dict, so one "_meta" or
    "_source" key would disable the entire catalog and leave every keg
    with no name. This matters because embedding attribution or
    provenance in the JSON is the obvious next idea, and it cannot be
    done without changing the loader first. The test documents that.

Version 0.3.2, continuing from 0.3.1. Not the fork's 0.4.1: 0f3b4c2
renumbered to 0.3.1 deliberately because no v0.4.0 tag was ever cut.
hacs.json is left alone, including the 2024.11.0 floor the fork predates.
2026-09-06 16:16:03 +02:00
Brett Jenkins 9b3852b9fd Add active-keg detection and a keg name sensor
Resolves the tapped keg's product id to a beer name via a bundled
catalog (keg_catalog.json), exposing it as a new Keg sensor alongside
the existing Keg Remaining/Freshness sensors.
2026-07-05 00:49:29 +01:00
rick 1ba8f22f1f Add companion card section to README with screenshot
Links to the PerfectDraft Card custom Lovelace card that visualises
keg data as beer emoji pictograms on wall-mounted panels.

Made-with: Cursor
2026-04-18 19:59:23 +02:00
rick 471b493879 README: clarify no login needed on perfectdraft.com for token generation
Made-with: Cursor
2026-04-13 13:33:18 +02:00
rick 35693cd2df README: soften session expiry language — lifespan TBD
Made-with: Cursor
2026-04-13 12:13:33 +02:00
rick 70882b939e v0.2.0: Fix token refresh, HACS compliance, brand icon, keg freshness
Critical fix:
- Cognito refresh now parses response with content_type=None
  (was crashing after 1hr when access token expired)

HACS compliance:
- Added README.md with full setup instructions including the
  token generation command
- Fixed manifest.json URLs to point at actual repo
- Version bumped to 0.2.0

Brand:
- Added brand/icon.png (PerfectDraft glass icon from official app)

New sensor:
- Keg Freshness: 30-day countdown from keg insertion, detected
  via numberOfPoursSinceStartup reset + kegVolume near full,
  persisted across restarts via RestoreEntity

Polish:
- Fixed MALFORMED_ARGUMENT in token step description
- Cleaner description referencing README for instructions

Made-with: Cursor
2026-04-13 12:12:43 +02:00