Documentation
¶
Overview ¶
Package ops declares every eightsleep operation once. The CLI, the HTTP API on a Unix socket, MCP and the metadata document are generated from these declarations by the toolkit.
Writes change a real bed: temperature, power, alarms, away mode and audio. On the command line they apply immediately, as eightctl's always did, and --dry-run previews them. HTTP and MCP callers must send "apply": true, and deletes also "confirm": true.
Index ¶
- Constants
- func New(version string, b *Backend) *op.Registry
- func Options(b *Backend) toolkit.Options
- func Register(reg *op.Registry, b *Backend)
- type ActiveAlarms
- type AirportInput
- type AlarmChange
- type AlarmCreateInput
- type AlarmCreated
- type AlarmIDInput
- type AlarmRow
- type AlarmUpdateInput
- type AngleInput
- type AwayInput
- type AwayResult
- type AwayRow
- type Backend
- type Blanket
- type CreatePlanInput
- type CreateTripInput
- type DateRange
- type DismissAll
- type Done
- type EnabledInput
- type FeatureRow
- type FlightInput
- type Globals
- type NoInput
- type PlanEdit
- type PlanInput
- type PlayInput
- type PowerResult
- type PresenceDetail
- type PresenceDetailInput
- type PresenceDevice
- type PresenceInput
- type PresenceRow
- type PresetInput
- type Row
- type SeekInput
- type SessionInput
- type SideInput
- type Signal
- type SleepDayInput
- type SleepDayRow
- type SleepRangeInput
- type SleepRangeRow
- type StatusInput
- type StatusRow
- type Target
- type TempInput
- type TempResult
- type TrackInput
- type TrackRow
- type TrendsInput
- type TripInput
- type UpdatePlanInput
- type Version
- type VolumeInput
- type Whoami
- type Zone
Constants ¶
const Description = "Control an Eight Sleep Pod: temperature, power, alarms, away mode, audio and sleep data."
Description is the root help text.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActiveAlarms ¶
ActiveAlarms are the alarms ringing now, as the app API returns them.
type AirportInput ¶
type AirportInput struct {
Query string `json:"query,omitempty" help:"airport query"`
}
AirportInput is an airport search.
type AlarmChange ¶
type AlarmChange struct {
Applied bool `json:"applied"`
ID string `json:"id"`
Patch map[string]any `json:"patch,omitempty"`
}
AlarmChange is the result of an update or delete.
type AlarmCreateInput ¶
type AlarmCreateInput struct {
Time string `json:"time,omitempty" help:"HH:MM time"`
Days []int `json:"days,omitempty" help:"Comma-separated days 0=Sun..6=Sat"`
Disabled bool `json:"disabled,omitempty" help:"Create disabled"`
NoVibration bool `json:"no_vibration,omitempty" name:"no-vibration" help:"Disable vibration"`
Sound string `json:"sound,omitempty" help:"Sound id"`
}
AlarmCreateInput describes a new alarm.
type AlarmCreated ¶
AlarmCreated is the alarm created, or the alarm a preview would create.
type AlarmIDInput ¶
type AlarmIDInput struct {
ID string `json:"id" arg:"" help:"Alarm ID"`
}
AlarmIDInput names one alarm.
type AlarmRow ¶
type AlarmRow struct {
ID string `json:"id"`
Time string `json:"time"`
Enabled bool `json:"enabled"`
Days []int `json:"days"`
Vibration client.AlarmVibration `json:"vibration"`
Sound *string `json:"sound"`
}
AlarmRow is one alarm as alarm list prints it.
type AlarmUpdateInput ¶
type AlarmUpdateInput struct {
ID string `json:"id" arg:"" help:"Alarm ID"`
Time string `json:"time,omitempty" help:"HH:MM time"`
Days []int `json:"days,omitempty" help:"Comma-separated days 0=Sun..6=Sat"`
Enabled *bool `json:"enabled,omitempty" help:"Set enabled true/false"`
NoVibration *bool `json:"no_vibration,omitempty" name:"no-vibration" help:"Disable vibration"`
Sound string `json:"sound,omitempty" help:"Sound id"`
}
AlarmUpdateInput changes the given fields of an alarm.
type AngleInput ¶
type AngleInput struct {
Head int `json:"head,omitempty" help:"head angle"`
Foot int `json:"foot,omitempty" help:"foot angle"`
}
AngleInput sets the base angles.
type AwayInput ¶
type AwayInput struct {
SideInput
Both bool `json:"both,omitempty" help:"Apply to every household member"`
}
AwayInput selects whose away mode to change or read. on and off default to the authenticated user's side, status to every discovered side.
type AwayResult ¶
type AwayResult struct {
Applied bool `json:"applied"`
Away bool `json:"away"`
// Scope is "your side", "side left", "user <id>" or "<n> household members".
Scope string `json:"scope"`
Targets []Target `json:"targets"`
}
AwayResult is the result of away on or off. The cloud is eventually consistent: away status may show the previous state for a while.
type AwayRow ¶
type AwayRow struct {
Side string `json:"side"`
Name string `json:"name"`
UserID string `json:"user_id"`
Away bool `json:"away"`
}
AwayRow is one side's away state.
type Backend ¶
type Backend struct {
Globals *Globals
// Hosts replaces the Eight Sleep hosts when set.
Hosts *client.Hosts
// Getenv reads the environment. Nil means os.Getenv.
Getenv func(string) string
// Stderr receives notices such as the config-file line. Nil means os.Stderr.
Stderr io.Writer
// Now is the clock. Nil means time.Now.
Now func() time.Time
// LocalZone names the system's IANA zone for --timezone local. Nil
// reads TZ and /etc/localtime.
LocalZone func() string
// Version is the tool version, for the version operation.
Version string
// contains filtered or unexported fields
}
Backend is what the operations reach the outside world through. Tests replace the hosts, the environment, the clock and the local zone.
type CreatePlanInput ¶
CreatePlanInput adds a plan to a trip.
type CreateTripInput ¶
type CreateTripInput struct {
Destination string `json:"destination,omitempty" help:"destination"`
StartDate string `json:"start_date,omitempty" name:"start-date" help:"start date"`
EndDate string `json:"end_date,omitempty" name:"end-date" help:"end date"`
// Named --trip-timezone so the root --timezone keeps its meaning.
TripTimezone string `json:"trip_timezone,omitempty" name:"trip-timezone" help:"IANA timezone for the trip destination"`
}
CreateTripInput describes a trip.
type DateRange ¶
type DateRange struct {
From string `json:"from,omitempty" help:"from date YYYY-MM-DD"`
To string `json:"to,omitempty" help:"to date YYYY-MM-DD"`
}
DateRange is an optional date window.
type DismissAll ¶
type DismissAll struct {
OK bool `json:"ok,omitempty"`
Method string `json:"method,omitempty"`
// DismissedAlarmIDs is present when each active alarm was dismissed in
// turn, because the bulk route was missing.
DismissedAlarmIDs []string `json:"dismissed_alarm_ids,omitzero"`
DryRun bool `json:"dry_run,omitempty"`
Primary string `json:"primary,omitempty"`
Fallback string `json:"fallback,omitempty"`
NextAlarmID *string `json:"next_alarm_id,omitempty"`
}
DismissAll is eightsleepctl's dismiss-all result: what was done, or with --dry-run the routes it would use and the next scheduled alarm.
func (DismissAll) MarshalJSON ¶
func (d DismissAll) MarshalJSON() ([]byte, error)
MarshalJSON prints a dry run with next_alarm_id null when no alarm is scheduled, as eightsleepctl did.
type Done ¶
type Done struct {
// Applied is false for a preview.
Applied bool `json:"applied"`
// Action describes the change, such as "snooze alarm a1".
Action string `json:"action"`
}
Done is the result of a write that reports nothing else.
type EnabledInput ¶
type EnabledInput struct {
Enabled *bool `json:"enabled,omitempty" help:"enable or disable (default true)"`
}
EnabledInput turns a setting on or off. Without the flag it turns it on.
type FeatureRow ¶
FeatureRow is one release feature.
type FlightInput ¶
type FlightInput struct {
Flight string `json:"flight,omitempty" help:"flight number"`
}
FlightInput names a flight.
type Globals ¶
type Globals struct {
Config string `help:"Config file (default ~/.config/eightsleep/config.yaml if present, else ~/.config/eightctl/config.yaml)"`
Verbose bool `short:"v" help:"Verbose logging"`
Email string `help:"Eight Sleep account email"`
Password string `help:"Eight Sleep account password"`
ClientID string `name:"client-id" help:"Eight Sleep client ID (optional; defaults to public app client)"`
ClientSecret string `name:"client-secret" help:"Eight Sleep client secret (optional; defaults to public app client)"`
UserID string `name:"user-id" help:"Eight Sleep user ID"`
Timezone string `json:"timezone" help:"IANA timezone (e.g., America/New_York) or 'local'"`
Output string `help:"Human output format: table|json|csv (default table)"`
Quiet bool `help:"Suppress the config load message"`
}
Globals are the root flags. Timezone's json tag binds it into the timezone input of the operations that have one. The rest are read by the backend: credentials must never be operation inputs or travel in a request body.
type PlanEdit ¶
type PlanEdit struct {
Name string `json:"name,omitempty" help:"plan name"`
Date string `json:"date,omitempty" help:"plan date"`
}
PlanEdit describes a travel plan.
type PlanInput ¶
type PlanInput struct {
Plan string `json:"plan,omitempty" help:"plan id"`
}
PlanInput names a travel plan.
type PlayInput ¶
type PlayInput struct {
Track string `json:"track,omitempty" help:"track ID to play"`
}
PlayInput starts playback.
type PowerResult ¶
type PowerResult struct {
Applied bool `json:"applied"`
State string `json:"state"`
// Targets are the household members written. Empty means the
// authenticated user, when discovery found nobody.
Targets []Target `json:"targets"`
// contains filtered or unexported fields
}
PowerResult is the result of on or off.
type PresenceDetail ¶
type PresenceDetail struct {
// Present is null when the newest signal is between the two windows.
Present *bool `json:"present"`
// Reason is fresh_timeseries, stale_timeseries, ambiguous_timeseries or
// no_timeseries.
Reason string `json:"reason"`
LastSignal *Signal `json:"last_signal,omitempty"`
AgeSeconds *int `json:"age_seconds,omitempty"`
PresentWindowSeconds *int `json:"present_window_seconds,omitempty"`
AbsentWindowSeconds *int `json:"absent_window_seconds,omitempty"`
Device *PresenceDevice `json:"device,omitempty"`
}
PresenceDetail is eightsleepctl's presence estimate: the freshest biometric signal of the latest sleep session, and the device's state.
type PresenceDetailInput ¶
type PresenceDetailInput struct {
Zone
PresentWithin *int `` /* 180-byte string literal not displayed */
AbsentAfter *int `` /* 177-byte string literal not displayed */
}
PresenceDetailInput tunes eightsleepctl's presence heuristic. The windows are pointers with the defaults applied in windows(), so an explicit 0 from the flag, the environment or a request survives (toolkit gap G2).
type PresenceDevice ¶
type PresenceDevice struct {
ID string `json:"id"`
Online any `json:"online"`
LastHeard any `json:"lastHeard"`
Blanket *Blanket `json:"blanket,omitempty"`
}
PresenceDevice is the current device's connectivity.
type PresenceInput ¶
PresenceInput is the window presence looks at.
type PresenceRow ¶
type PresenceRow struct {
Present bool `json:"present"`
}
PresenceRow says whether the user is in bed.
type PresetInput ¶
type PresetInput struct {
Name string `json:"name,omitempty" help:"preset name"`
}
PresetInput names a base preset.
type SeekInput ¶
type SeekInput struct {
Position int `json:"position,omitempty" help:"position milliseconds"`
}
SeekInput moves the playhead.
type SessionInput ¶
type SessionInput struct {
ID string `json:"id,omitempty" help:"session id"`
}
SessionInput names a sleep session.
type SideInput ¶
type SideInput struct {
Side string `json:"side,omitempty" help:"target household side: left|right|solo"`
TargetUserID string `json:"target_user_id,omitempty" name:"target-user-id" help:"set or query a specific household user ID"`
}
SideInput selects one household member. Without either field a command acts as it documents: on, off and temp act on every discovered member.
type Signal ¶
type Signal struct {
Signal string `json:"signal"`
Timestamp string `json:"timestamp"`
Value any `json:"value"`
}
Signal is the newest sample of one biometric series.
type SleepDayInput ¶
type SleepDayInput struct {
Zone
Date string `json:"date,omitempty" help:"date YYYY-MM-DD (default today)"`
}
SleepDayInput selects a day.
type SleepDayRow ¶
type SleepDayRow struct {
Date string `json:"date"`
Score float64 `json:"score"`
Tnt int `json:"tnt"`
RespRate float64 `json:"resp_rate"`
HeartRate float64 `json:"heart_rate"`
Duration float64 `json:"duration"`
LatencyAsleep float64 `json:"latency_asleep"`
LatencyOut float64 `json:"latency_out"`
HRVScore float64 `json:"hrv_score"`
}
SleepDayRow is one day's sleep metrics.
type SleepRangeInput ¶
type SleepRangeInput struct {
Zone
From string `json:"from,omitempty" help:"start date YYYY-MM-DD"`
To string `json:"to,omitempty" help:"end date YYYY-MM-DD"`
}
SleepRangeInput selects a range of days.
type SleepRangeRow ¶
type SleepRangeRow struct {
Date string `json:"date"`
Score float64 `json:"score"`
Duration float64 `json:"duration"`
Tnt int `json:"tnt"`
RespRate float64 `json:"resp_rate"`
HeartRate float64 `json:"heart_rate"`
HRVScore float64 `json:"hrv_score"`
}
SleepRangeRow is one day of a range.
type StatusInput ¶
type StatusInput struct {
SideInput
AllSides bool `json:"all_sides,omitempty" name:"all-sides" help:"show status for all discovered household sides"`
}
StatusInput selects the sides status reads.
type StatusRow ¶
type StatusRow struct {
Side string `json:"side,omitempty"`
Name string `json:"name,omitempty"`
UserID string `json:"user_id,omitempty"`
Mode string `json:"mode"`
Level int `json:"level"`
}
StatusRow is one side's heating state. Side, name and user ID are absent when the account has no household.
type Target ¶
type Target struct {
Side string `json:"side,omitempty"`
Name string `json:"name,omitempty"`
UserID string `json:"user_id,omitempty"`
}
Target is a household member a command acted on.
type TempInput ¶
type TempInput struct {
SideInput
Value string `json:"value" arg:"" help:"Temperature: 68F, 20C, or a heating level -100..100"`
}
TempInput sets the temperature of one or every side.
type TempResult ¶
type TempResult struct {
Applied bool `json:"applied"`
Level int `json:"level"`
Targets []Target `json:"targets"`
// contains filtered or unexported fields
}
TempResult is the result of temp.
type TrackInput ¶
type TrackInput struct {
Track string `json:"track,omitempty" help:"track id"`
}
TrackInput names a track.
type TrackRow ¶
type TrackRow struct {
ID string `json:"id"`
Title string `json:"title"`
Type string `json:"type"`
}
TrackRow is one audio track.
type TrendsInput ¶
TrendsInput is the window of metrics trends.
type TripInput ¶
type TripInput struct {
Trip string `json:"trip,omitempty" help:"trip id"`
}
TripInput names a trip.
type UpdatePlanInput ¶
UpdatePlanInput changes a plan.
type VolumeInput ¶
type VolumeInput struct {
Level *int `json:"level,omitempty" help:"volume level 0-100 (default 50)"`
}
VolumeInput sets the volume.