func turn(hub *huego.Hub, args []string) { status, err := hub.Status() if err != nil { fmt.Println("error:", err) return } name := args[2] if sw := status.FindSwitchable(name); sw != nil { sw.Switch().State(args[1] == "on").Send() } else { fmt.Println(name, " not found") } }
func temp(hub *huego.Hub, args []string) { status, err := hub.Status() if err != nil { fmt.Println("error:", err) return } name := args[1] temp, err := strconv.ParseInt(args[2], 10, 32) if err != nil { fmt.Println("error:", err) return } if sw := status.FindSwitchable(name); sw != nil { sw.Switch().Transition(5).Temperature(int(temp)).Send() } else { fmt.Println(name, " not found") } }
func list(hub *huego.Hub, args []string) { status, err := hub.Status() if err != nil { fmt.Println("error:", err) return } switch args[1] { case "lights": for _, light := range status.Lights { fmt.Println(light) } case "groups": for _, group := range status.Groups { fmt.Println(group) } default: fmt.Println("lights|groups") } }
func colour(hub *huego.Hub, args []string) { status, err := hub.Status() if err != nil { fmt.Println("error:", err) return } name := args[1] hue, err := strconv.ParseInt(args[2], 10, 32) if err != nil { fmt.Println("error:", err) return } sat, err := strconv.ParseInt(args[3], 10, 32) if err != nil { fmt.Println("error:", err) return } if sw := status.FindSwitchable(name); sw != nil { sw.Switch().Transition(5).Colour(int(hue), int(sat)).Send() } else { fmt.Println(name, " not found") } }