device-runs
device-runs - the durable record of ONE run of a device: a washing cycle, a dishwasher cycle, later a mow or a clean.
device-runs - the durable record of ONE run of a device: a washing cycle, a dishwasher cycle, later a mow or a clean.
A run is a DOCUMENT (opened at one instant, closed at another, carrying what was measured over it), never a sample - device-history keeps the numbers over time and its device-runs provider keeps these documents beside them, because the energy of a run is a question about device-history's own series. The record is written from the running-state flip on DeviceStateChanged; it survives a restart (the open row is on disk) and a missed flip (boot compares the open rows against the live snapshots).
Every measurement is number | null and null means "could not be measured", never 0. A run closed by the boot reconcile because the device stopped while nobody was watching has outcome: 'unknown'.
At a glance
| Capability | device-runs |
| Provided by | An addon wraps the device and provides it. It is bound to a device through the device bindings and can be bound automatically to compatible devices. |
| Active providers per device | one |
| Device types | washer, dryer, dishwasher |
| Source | packages/types/src/capabilities/device-runs.cap.ts |
Methods
Every method takes the device id (deviceId) to address the device; the input tables below list the other fields.
| Method | Kind | Required of a provider | Access |
|---|---|---|---|
listRuns | query | yes | default |
getRun | query | yes | default |
getCurrentRun | query | yes | default |
listRuns
query
Runs of a device, newest first. limit is bounded; page with cursor.
Input
| Field | Type | Required | Description |
|---|---|---|---|
outcome | "completed" | "aborted" | "error" | "unknown" | no | |
atFrom | number | no | |
atTo | number | no | |
limit | number | no (default 50) | |
cursor | string | no |
Output
| Field | Type | Required | Description |
|---|---|---|---|
runs | ({ runId: string; deviceId: number; kind: "appliance" | "mower" | "vacuum"; state: "open" | "closed"; startedAt: number; endedAt: number | null; durationMs: number | null; outcome: "completed" | "aborted" | "error" | "un… | yes | |
nextCursor | string | null | yes |
getRun
query
Input
| Field | Type | Required | Description |
|---|---|---|---|
runId | string | yes |
Output
| Field | Type | Required | Description |
|---|---|---|---|
runId | string | yes | |
deviceId | number | yes | |
kind | "appliance" | "mower" | "vacuum" | yes | |
state | "open" | "closed" | yes | |
startedAt | number | yes | |
endedAt | number | null | yes | |
durationMs | number | null | yes | |
outcome | "completed" | "aborted" | "error" | "unknown" | null | yes | |
startSource | "running-state" | "activity" | "reconcile" | yes | |
endSource | "running-state" | "activity" | "reconcile" | null | yes | |
runningSource | "native" | "assigned" | null | yes | |
phases | ({ phase: string; at: number })[] | yes | |
detail | { kind: "appliance"; energyKwh: number | null; energyMethod: "counter-delta" | "history-integral" | null; peakW: number | null; avgW: number | null; program: string | null; remainingAtStartSec: number | null; finalPhase:… | yes |
getCurrentRun
query
The run open right now, or null (answered: there is none).
Input
No fields besides deviceId.
Output
| Field | Type | Required | Description |
|---|---|---|---|
runId | string | yes | |
deviceId | number | yes | |
kind | "appliance" | "mower" | "vacuum" | yes | |
state | "open" | "closed" | yes | |
startedAt | number | yes | |
endedAt | number | null | yes | |
durationMs | number | null | yes | |
outcome | "completed" | "aborted" | "error" | "unknown" | null | yes | |
startSource | "running-state" | "activity" | "reconcile" | yes | |
endSource | "running-state" | "activity" | "reconcile" | null | yes | |
runningSource | "native" | "assigned" | null | yes | |
phases | ({ phase: string; at: number })[] | yes | |
detail | { kind: "appliance"; energyKwh: number | null; energyMethod: "counter-delta" | "history-integral" | null; peakW: number | null; avgW: number | null; program: string | null; remainingAtStartSec: number | null; finalPhase:… | yes |
Events
onRunOpened
| Field | Type | Required | Description |
|---|---|---|---|
runId | string | yes | ${deviceId}:${startedAt}. |
deviceId | number | yes | |
kind | "appliance" | "mower" | "vacuum" | yes | |
state | "open" | "closed" | yes | |
startedAt | number | yes | |
endedAt | number | null | yes | |
durationMs | number | null | yes | |
outcome | "completed" | "aborted" | "error" | "unknown" | null | yes | |
startSource | "running-state" | "activity" | "reconcile" | yes | |
endSource | "running-state" | "activity" | "reconcile" | null | yes | |
runningSource | "native" | "assigned" | null | yes | Where the device's running bit came from (running-state.source); null when it did not say. |
phases | ({ phase: string; at: number })[] | yes | |
detail | { kind: "appliance"; energyKwh: number | null; energyMethod: "counter-delta" | "history-integral" | null; peakW: number | null; avgW: number | null; program: string | null; remainingAtStartSec: number | null; finalPhase:… | yes |
onRunClosed
| Field | Type | Required | Description |
|---|---|---|---|
runId | string | yes | ${deviceId}:${startedAt}. |
deviceId | number | yes | |
kind | "appliance" | "mower" | "vacuum" | yes | |
state | "open" | "closed" | yes | |
startedAt | number | yes | |
endedAt | number | null | yes | |
durationMs | number | null | yes | |
outcome | "completed" | "aborted" | "error" | "unknown" | null | yes | |
startSource | "running-state" | "activity" | "reconcile" | yes | |
endSource | "running-state" | "activity" | "reconcile" | null | yes | |
runningSource | "native" | "assigned" | null | yes | Where the device's running bit came from (running-state.source); null when it did not say. |
phases | ({ phase: string; at: number })[] | yes | |
detail | { kind: "appliance"; energyKwh: number | null; energyMethod: "counter-delta" | "history-integral" | null; peakW: number | null; avgW: number | null; program: string | null; remainingAtStartSec: number | null; finalPhase:… | yes |