Skip to main content
The client provides typed convenience methods for every controllable entity domain. Each method accepts the entity key (a uint32 from ListEntities) and a value or options struct. If ListEntities has been called, the key is validated against the registry before the command is sent.

Entity key validation

When the entity registry is populated (after calling ListEntities), every command method validates the key:
  • ErrEntityNotFound — key does not exist in the registry
  • ErrEntityTypeMismatch — key exists but belongs to a different domain
If the registry is empty (entities have not been listed), validation is skipped and the command is sent as-is.

Low-level: SendCommand

SendCommand accepts any pb.*CommandRequest and resolves the message type ID automatically. Use this for entity types not covered by the typed methods, or when building commands programmatically.
func (c *Client) SendCommand(cmd proto.Message) error
err := client.SendCommand(&pb.SwitchCommandRequest{
    Key:   0x12345678,
    State: true,
})

Typed command methods

SetSwitch turns a switch on or off.
func (c *Client) SetSwitch(key uint32, state bool) error
// Turn on
err := client.SetSwitch(key, true)

// Turn off
err := client.SetSwitch(key, false)
PressButton triggers a stateless button entity.
func (c *Client) PressButton(key uint32) error
err := client.PressButton(key)