Dominevo
ReferenceDevice capabilities

timed-run

timed-run - run a device for a chosen time, then stop it.

timed-run - run a device for a chosen time, then stop it.

"Heat for 30 minutes", "run the fountain pump for 2 minutes": the device has no timer of its own, so the hub keeps one. runFor turns the device on and records a deadline; cancel switches the device off and forgets the deadline, and the device being switched off by hand just forgets it; at the deadline the hub issues the off once.

The deadline is DURABLE: it is a row in the records store, so a hub restart neither loses a pending off nor leaves the device running past its time. At boot a deadline already past sends the off once; a future one is re-armed.

What a device may be run for, and for how long at most, is per device type and role ({ so a request above it is REFUSED with a typed reason, never clamped.

At a glance

Capabilitytimed-run
Provided byAn 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 deviceone
Device typesswitch, pet-fountain
Device rolesswitch: switch-heater
Device settingsYes: its settings section on the device page is built from this capability's methods.
Sourcepackages/types/src/capabilities/timed-run.cap.ts

Methods

Every method takes the device id (deviceId) to address the device; the input tables below list the other fields.

MethodKindRequired of a providerAccess
getOptionsqueryyesdefault
setSettingsmutationyesadmin
runFormutationyesprotected
cancelmutationyesprotected

getOptions

query

Input

No fields besides deviceId.

Output

What the settings form needs: the unit, the bounds and the type's default.

FieldTypeRequiredDescription
unit"s" | "min"yes
maxDurationnumberyesThe longest run, in unit.
defaultDurationnumberyes

setSettings

mutation

The one-tap run of this device. A duration above the type's maximum is REFUSED (thrown), like runFor: the maximum is a safety bound.

Input

FieldTypeRequiredDescription
settings{ quickRunDuration?: number | null }yes

Output

Nothing.

runFor

mutation

Turn the device on and arm its off. A run already armed is replaced (the new deadline wins). Refuses with a typed reason above the type's maximum.

Input

FieldTypeRequiredDescription
durationnumberyes
unit"s" | "min"yes

Output

{ ok: true; activeUntil: number } | { ok: false; reason: "unsupported-device" | "over-max" | "command-failed"; maxSeconds: number | null }

Actions (offered in automations and on device cards)

ActionLabelSets
timedRun.runForMinutesRun for minutes
timedRun.runForSecondsRun for seconds

cancel

mutation

Stop the run: switch the device off (once) and forget the pending off. Nothing armed: nothing is sent.

Input

No fields besides deviceId.

Output

Nothing.

Actions (offered in automations and on device cards)

ActionLabelSets
timedRun.cancelCancel the timer

Runtime state

The state Dominevo keeps for each device with this capability, readable without calling the provider.

FieldTypeRequiredDescription
activeUntilnumber | nullyesEpoch ms the pending off is due; null while nothing is armed.
requestedBystring | nullyesWho asked for the run (a user id or an addon id); null when nothing is armed or it did not say.
quickRun{ duration: number; unit: "s" | "min" } | nullyesThe one-tap run of THIS device: what a "Run" button on any surface starts. null when the device is gone or its type has no timed run; a status from before this field existed has none, and a surface falls back to the type's default.
lastFetchedAtnumberyes