]> git.giacomolli.uk - onehouse/blob - driver/command.go
Poll and command shared Alamo thermostats
[onehouse] / driver / command.go
1 package driver
2
3 import (
4 "time"
5
6 "onehouse/protocol"
7 )
8
9 // Command is one validated device request. A driver checks ownership, access,
10 // and Expired immediately before physical work. Each batch member keeps its own
11 // metadata, expiry, and payload. The queue consumer owns these values.
12 type Command struct {
13 DeviceID string
14 Capability string
15 Metadata protocol.Metadata
16 Payload protocol.ValuePayload
17 }
18
19 // Expired reports whether the command has no expiry or has reached it.
20 func (c Command) Expired(now time.Time) bool {
21 return c.Metadata.ExpiresAt == nil || !now.Before(*c.Metadata.ExpiresAt)
22 }