package commands import ( "fmt" "git.aiterp.net/lucifer3/server/device" "strings" ) type SetState struct { ID string State device.State } func (c SetState) Matches(driver string) (sub string, ok bool) { if strings.HasPrefix(c.ID, driver) && strings.HasPrefix(c.ID[len(driver):], ":") { return strings.SplitN(c.ID[len(driver)+1:], ":", 2)[0], true } else { return "", false } } func (c SetState) CommandDescription() string { return fmt.Sprintf("SetState(%s, %s)", c.ID, c.State) } type SetStateBatch map[string]device.State func (c SetStateBatch) CommandDescription() string { return fmt.Sprintf("SetStateBatch(%d devices)", len(c)) }