|
|
package main
import ( 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/services" "git.aiterp.net/lucifer3/server/services/nanoleaf" "time" )
func main() { bus := lucifer3.EventBus{}
resolver := services.NewResolver() sceneMap := services.NewSceneMap(resolver)
bus.JoinPrivileged(resolver) bus.JoinPrivileged(sceneMap) bus.Join(services.NewEffectEnforcer(resolver, sceneMap)) bus.Join(nanoleaf.NewService())
bus.JoinCallback(func(event lucifer3.Event) bool { switch event.(type) { case events.DevicesReady: bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:2d0c", Alias: "lucifer:name:Hex 5"}) bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:542f", Alias: "lucifer:name:Hex 6"}) bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:e760", Alias: "lucifer:name:Hex 7"}) bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:207a", Alias: "lucifer:name:Hex 8"}) bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:df9a", Alias: "lucifer:name:Hex 9"}) bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:cdd5", Alias: "lucifer:name:Hex 4"}) bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:4597", Alias: "lucifer:name:Hex 3"}) bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:82cb", Alias: "lucifer:name:Hex 2"}) bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:09fd", Alias: "lucifer:name:Hex 1"}) bus.RunCommand(commands.Assign{ Match: "nanoleaf:10.80.1.14:*", Effect: effects.Pattern{ States: []device.State{ {Power: p(true), Intensity: p(0.3), Color: p(color.MustParse("xy:0.22,0.18"))}, {Power: p(true), Intensity: p(0.4), Color: p(color.MustParse("xy:0.22,0.18"))}, {Power: p(true), Intensity: p(0.5), Color: p(color.MustParse("xy:0.22,0.18"))}, }, AnimationMS: 200, }, })
time.Sleep(time.Second * 3) bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:*", Alias: "lucifer:tag:Magic Lamps"}) bus.RunCommand(commands.Assign{ Match: "lucifer:tag:Magic Lamps", Effect: effects.Gradient{ States: []device.State{ {Power: p(true), Intensity: p(0.5), Color: p(color.MustParse("xy:0.22,0.18"))}, {Power: p(true), Intensity: p(0.8), Color: p(color.MustParse("xy:0.22,0.18"))}, }, Interpolate: true, AnimationMS: 500, }, })
return false }
return true })
bus.RunCommand(commands.ConnectDevice{ ID: "nanoleaf:10.80.1.14", APIKey: "QRj5xcQxAQMQsjK4gvaprdhOwr1sCIcj", })
time.Sleep(time.Hour) }
func p[T any](v T) *T { return &v }
|