package main import ( "fmt" lucifer3 "git.aiterp.net/lucifer3/server" "git.aiterp.net/lucifer3/server/commands" "git.aiterp.net/lucifer3/server/device" "git.aiterp.net/lucifer3/server/events" "git.aiterp.net/lucifer3/server/services" "log" "time" ) func main() { bus := lucifer3.EventBus{} resolver := services.NewResolver() bus.Join(resolver) bus.RunEvent(events.Connected{Prefix: "nanoleaf:10.80.1.11"}) time.Sleep(time.Second / 2) numbers := []int{5, 2, 3, 1, 4} for i, id := range []string{"e28c", "67db", "f744", "d057", "73c1"} { bus.RunEvent(events.HardwareState{ ID: "nanoleaf:10.80.1.11:" + id, InternalName: fmt.Sprintf("Hexagon %d", numbers[i]), SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity, ColorFlags: device.CFlagRGB, State: device.State{}, }) } bus.RunCommand(commands.ReplaceScene{ Match: "lucifer:name:Hex*", SceneID: 7, }) time.Sleep(time.Second / 8) bus.RunCommand(commands.AddAlias{ Match: "nanoleaf:10.80.1.{11,7,16,5}:*", Alias: "lucifer:tag:Magic Lamps", }) time.Sleep(time.Second / 8) bus.RunEvent(events.HardwareState{ ID: "nanoleaf:10.80.1.11:40e5", InternalName: "Hexagon 6", SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity, ColorFlags: device.CFlagRGB, State: device.State{}, }) time.Sleep(time.Second / 8) bus.RunCommand(commands.ReplaceScene{ Match: "lucifer:name:Hex*", SceneID: 7, }) time.Sleep(time.Second / 8) log.Println("Search \"**:Hexagon {1,5,6}\"") for _, dev := range resolver.Resolve("lucifer:name:Hexagon {1,5,6}") { log.Println("- ID:", dev.ID) log.Println(" Aliases:", dev.Aliases) } time.Sleep(time.Second / 4) }