more error handling, separate request function
This commit is contained in:
13
cmd/lifx.go
13
cmd/lifx.go
@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.kill0.net/chill9/lifx"
|
||||
"git.kill0.net/chill9/go-lifx"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
@ -13,11 +13,14 @@ func main() {
|
||||
fmt.Println("LIFX_API_TOKEN is undefined")
|
||||
os.Exit(1)
|
||||
}
|
||||
s := &lifx.State{Power: "on", Color: "white"}
|
||||
s := &lifx.State{Power: "on", Color: "blue"}
|
||||
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"})
|
||||
time.Sleep(10)
|
||||
c.SetState("all", &lifx.State{Power: "on", Color: "green"})
|
||||
time.Sleep(10)
|
||||
c.SetState("all", &lifx.State{Power: "off"})
|
||||
//c.PowerOff("all")
|
||||
}
|
||||
|
Reference in New Issue
Block a user