more error handling, separate request function

This commit is contained in:
2020-02-25 00:41:29 -06:00
parent 57d7dd6f85
commit 584c2b2ec5
3 changed files with 69 additions and 14 deletions

View File

@ -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")
}