func main() { if config_filename != "" { k := key.New(config_filename) portal := portal.GetPortal() ll := lights.NewLights(portal[0].InternalIpAddress, k.Username) lights := ll.GetAllLights() fmt.Println("All Lights: ") for _, l := range lights { light := ll.GetLight(l.Id) print_light(light) } } else { usage() } }
package main import ( "fmt" MQTT "git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang.git" "github.com/heatxsink/go-hue/src/groups" "github.com/heatxsink/go-hue/src/lights" ) // Some config var ( topic = "/lights/set" hueIP = "192.168.1.5" hueUsername = "******" l = lights.NewLights(hueIP, hueUsername) g = groups.NewGroup(hueIP, hueUsername) ) // Handles incoming MQTT messages var onMessage MQTT.MessageHandler = func(client *MQTT.Client, msg MQTT.Message) { switch msg.Payload()[0] { default: fmt.Printf("Unknown payload: %s\n", msg.Payload()) case '0': g.SetGroupState(0, lights.State{On: false}) case '1': g.SetGroupState(0, lights.State{On: true, Bri: 255, Ct: 370}) case '2': g.SetGroupState(0, lights.State{On: true, Bri: 144, Sat: 211, Hue: 13122}) case '3':