lume/cmd/lifx.go

27 lines
535 B
Go
Raw Normal View History

2020-02-24 03:01:12 +00:00
package main
import (
"fmt"
"git.kill0.net/chill9/go-lifx"
2020-02-24 03:01:12 +00:00
"os"
"time"
)
func main() {
apiToken := os.Getenv("LIFX_API_TOKEN")
if apiToken == "" {
fmt.Println("LIFX_API_TOKEN is undefined")
os.Exit(1)
}
s := &lifx.State{Power: "on", Color: "blue"}
2020-02-24 03:01:12 +00:00
c := lifx.NewSession(apiToken)
c.SetState("group:Office", s)
time.Sleep(10 * time.Second)
s.Color = "white"
res, _ := c.SetState("group:Office", s)
fmt.Println(res)
//c.SetState("all", &lifx.State{Power: "on", Color: "green"})
2020-02-24 03:01:12 +00:00
time.Sleep(10)
//c.PowerOff("all")
2020-02-24 03:01:12 +00:00
}