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/effects" "git.aiterp.net/lucifer3/server/events" "git.aiterp.net/lucifer3/server/internal/color" "git.aiterp.net/lucifer3/server/internal/gentools" "git.aiterp.net/lucifer3/server/services" "log" "time" ) func main() { bus := lucifer3.EventBus{} resolver := services.NewResolver() sceneMap := services.NewSceneMap(resolver) bus.Join(resolver) bus.Join(sceneMap) bus.Join(services.NewEffectEnforcer(resolver, sceneMap)) time.Sleep(time.Millisecond) bus.RunEvent(events.Connected{Prefix: "nanoleaf:10.80.1.11"}) 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{}, }) } time.Sleep(time.Millisecond) bus.RunCommand(commands.ReplaceScene{ Match: "lucifer:name:Hex*", SceneID: 7, }) time.Sleep(time.Millisecond) bus.RunCommand(commands.AddAlias{ Match: "nanoleaf:10.80.1.{11,7,16,5}:*", Alias: "lucifer:tag:Magic Lamps", }) time.Sleep(time.Millisecond) 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.Millisecond) bus.RunEvent(events.ExternalEvent{ Kind: "weather", Values: map[string]string{ "location": "Brekstad", "temperature_celsius": "21.00", "precipitation_mm": "3.21", }, }) time.Sleep(time.Millisecond) bus.RunCommand(commands.Assign{ Match: "**:Hexagon *", Effect: effects.Manual{ Power: gentools.Ptr(true), Color: gentools.Ptr(color.MustParse("rgb:#ffcc11")), Intensity: gentools.Ptr(1.0), }, }) time.Sleep(time.Millisecond * 100) 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) } }