You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

38 lines
792 B

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)
}
func (c SetState) VerboseKey() string {
return "SetState"
}
type SetStateBatch map[string]device.State
func (c SetStateBatch) CommandDescription() string {
return fmt.Sprintf("SetStateBatch(%d devices)", len(c))
}
func (c SetStateBatch) VerboseKey() string {
return "SetStateBatch"
}