feat(cmd): add away mode (vacation) command#25
Closed
omarshahine wants to merge 3 commits intosteipete:mainfrom
Closed
feat(cmd): add away mode (vacation) command#25omarshahine wants to merge 3 commits intosteipete:mainfrom
omarshahine wants to merge 3 commits intosteipete:mainfrom
Conversation
The Eight Sleep auth server (auth-api.8slp.net/v1/tokens) expects standard OAuth2 form-urlencoded requests, not JSON. The previous implementation sent JSON with hardcoded "sleep-client" credentials, which caused a 400 from Joi validation. The fallback to legacy /login then tripped the rate limiter, resulting in a permanent 429 loop. Changes: - Send application/x-www-form-urlencoded instead of application/json - Use c.ClientID and c.ClientSecret (the real app creds extracted from the Android APK) instead of hardcoded "sleep-client"/"" - Make authURL a var so tests can point it at a local server - Add tests for form encoding, credential passthrough, and legacy login fallback Fixes steipete#7, fixes steipete#8, fixes steipete#12 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The do() method sends Accept-Encoding: gzip but never decompresses
the response body, causing json.Decode to fail with:
invalid character '\x1f' looking for beginning of value
(0x1f is the gzip magic byte.)
Check Content-Encoding: gzip on responses and wrap the body in a
gzip.Reader before decoding. Added test with a mock gzip response.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add `eightctl away on` and `eightctl away off` to activate/deactivate
away mode. When away, the pod stops heating/cooling.
Supports per-side and whole-pod control:
- Default: authenticated user's side only
- --both: both sides of the pod
- --user-id: specific user/side
The away-mode API lives on app-api.8slp.net (separate from the client
API), so this also refactors `do()` into `do()` + `doURL()` to support
requests to different base URLs. Adds `Device().Sides()` to fetch the
left/right user ID assignments from device info.
API details reverse-engineered from the Eight Sleep Home Assistant
integration (pyEight):
- PUT /v1/users/{userId}/away-mode
- Payload: {"awayPeriod": {"start"|"end": "<ISO 8601 timestamp>"}}
- Timestamps set 24h in the past to trigger immediately
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
7f61513 to
8835a6e
Compare
Author
|
Superseded by a new PR based on main (not dependent on #24). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
eightctl away onandeightctl away offcommands to activate/deactivate away mode (vacation mode) for the authenticated user's pod sidedo()(path-based, usesBaseURL) +doURL()(absolute URL) to support the app API hostDetails
The away-mode endpoint lives on
app-api.8slp.net, separate from theclient-api.8slp.netused by other endpoints. The command sends a PUT to/v1/users/{userId}/away-modewith a start/end timestamp.API contract reverse-engineered from the Eight Sleep Home Assistant integration (pyEight):
Timestamps are set 24 hours in the past to trigger immediately (same pattern as pyEight).
Usage
Test plan
eightctl away on --quietactivates away modeeightctl away off --quietdeactivates away modeeightctl away --helpshows subcommandsgo test ./...)Dependencies
This PR is based on #24 (OAuth + gzip fixes). It should be merged after #24.
🤖 Generated with Claude Code