Repository navigation
feat: set FTP and power zones - #329
Conversation
Add `gccli profile power-zones set <sport> --ftp WATTS [--floors F1,...]`. It sends one PUT to /biometric-service/powerZones/all with the sport, the FTP and the zone floors. Garmin changes only that sport and also records the FTP. Without --floors, the floors of cycling, rowing and cross-country skiing are 0, 55, 75, 90, 105, 120 and 150 percent of FTP, rounded half up. This rule gives the floors that Garmin stored for the FTP values in the tests. Running has 5 zones and no default rule, so it needs --floors with 5 values. zone6Floor and zone7Floor are sent as 0 for running. The command checks the FTP and the floors before it sends a request: FTP greater than 0, the zone count of the sport, no negative floor, and each floor higher than the one before.
|
Independent verification: PASS+NOTES
I did not write this change. I made no live Garmin calls. All binary runs used a local HTTPS CONNECT mock ( Gate on head
Head merged into origin/main 8a832a9
Base vs head binary on the mockThese match byte for byte (stdout, stderr, exit code and the request log): All differences are ones the PR names:
New command on the mockThe PUT bodies that the mock received:
Injected defectsI put in 16 defects one at a time. The tests caught all 16, and I reverted each one. I ran
PR Verification claims rerun
Notes (none blocks the merge)
CI on this head: all 6 checks pass (test, conformance, darwin-cgo-build, two runs each). |
Kong runs a command's Validate before it checks the enum of a required argument and the required flags. So Validate saw a sport with no rule or an FTP of 0 and gave a misleading message. Validate now returns nil for a sport with no rule and for a missing --ftp, which is a pointer now. Kong then gives its enum, missing-flag or missing-argument error.
An FTP of 1 to 6 W gives default floors with equal values, such as 0, 3, 4, 5, 5, 6, 8 for 5 W. The command sent them, but the same values given with --floors are a usage error. Validate now runs the order check on the floors that Run sends, and for the default floors it asks for --floors.
|
Independent verification: PASS+NOTES
I did not write this change. I made no live Garmin calls. All binary runs used a local HTTPS CONNECT mock ( Gate on head
Head merged into origin/main 8a832a9
Base vs head binary on the mockThese match byte for byte (stdout, stderr, exit code and the request log): All differences are ones the PR names:
New command on the mock: bad inputEach of these exits 2 and sends no request:
New command on the mock: good pathsThe PUT bodies that the mock received:
Injected defectsI put in 21 defects one at a time in a separate worktree and ran New goldens from 2063e52 and 52c633a:
Earlier tests:
PR Verification claims rerun
Notes (none blocks the merge)
CI on this head: all 6 checks pass (test, conformance and darwin-cgo-build, two runs each). |
Closes #328.
Summary
You can now set the FTP and the power zones of a sport from the CLI:
The command sends one
PUT /biometric-service/powerZones/allwith a single sport object. Garmin changes only that sport. It also adds a MANUAL FTP record, sogccli health cycling-ftpshows the new value.Decisions on the open questions in #328
connectapi.garmin.comwith the gccli OAuth2 token. An empty array returns 400powerZonesDTO cannot be null. A valid body returns 204.TestDefaultPowerZoneFloorspins those values.--floorssets exact values.--floorswith 5 values, and the command sends 0 forzone6Floorandzone7Floor, as Garmin stores them. Without--floors, running exits 2 before it sends a request.Before it sends a request, the command checks that FTP is greater than 0, that the number of floors is correct for the sport, that no floor is negative, and that each floor is higher than the one before. The default floors get the same order check, so an FTP below 7 W without
--floorsis refused. An unknown sport or a missing--ftpgets Kong's own usage error. Each failed check exits 2.Verification
make fmt-check,make lint(0 issues),go vet -tags e2e ./...andmake testpass.--ftp, a too low FTP and a 400 from the PUT. The second independent verifier injected 21 defects, and each made a test fail. Examples are a wrong percent, truncation instead of rounding, a missing zero fill for running, and the sport sent in lowercase.set cycling --ftp 279printedSet cycling FTP to 279 W, zone floors 0, 153, 209, 251, 293, 335, 419 W, andset running --ftp 179 --floors 116,143,162,179,206 --jsonprinted{"ok": true}.profile power-zones listwas the same before and after. Each write added a MANUAL FTP record with the same value.