-
Notifications
You must be signed in to change notification settings - Fork 0
Command Structure
Logan Savage edited this page Jun 13, 2026
·
3 revisions
This library is designed around a builder and a per-device syntax.
The builder syntax contains two sections for a command:
- Filters, which sequentially filter down the devices shown
- Actions, which are a sequence of actions to perform on the devices that pass through every filter
With this, the structure of a command is:
err := controller.Devices().
<filterFunctions>.
<actionFunctions>.
Exec()
err = controller.Devices().
TypeIs(veego.DeviceLight). // Filter function
NameMatches("^Living Room"). // Filter function
Off(). // Action function
Exec()Using the per-device syntax involves getting devices from the filter section of the builder syntax, followed by a .Query() call to get a slice of Devices. Each device can individually be checked for capability statuses and be acted upon similar to the builder syntax.
// Get every light device as a []veego.Device
devs := controller.Devices().
TypeIs(veego.DeviceLight).
Query()
// Guard for ensuring at least one device was found
if len(devs) == 0 {
log.Fatal("0 devices found.")
}
// Turn off the first returned device
devs[0].Off()