Skip to content

Instantly share code, notes, and snippets.

@bestform
Created December 24, 2015 10:21
Show Gist options
  • Save bestform/500d4182ba0675b22d13 to your computer and use it in GitHub Desktop.
Save bestform/500d4182ba0675b22d13 to your computer and use it in GitHub Desktop.
package main
import (
"log"
"math/rand"
"time"
"github.com/bestform/gohue"
)
func main() {
client := gohue.NewClient("<username>", "<ip>")
err := client.Connect()
if err != nil {
log.Fatal(err)
}
christmasColors := []int{1000, 40000, 26000}
r := rand.New(rand.NewSource(99))
for {
c := r.Intn(len(christmasColors))
color := christmasColors[c]
duration := r.Intn(1000) + 500
for _, light := range client.Lights {
light.State.Brightness = 190
light.State.Hue = color
light.UpdateState()
time.Sleep(time.Duration(duration) * time.Millisecond)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment