You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.7 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. package main
  2. import (
  3. lucifer3 "git.aiterp.net/lucifer3/server"
  4. "git.aiterp.net/lucifer3/server/commands"
  5. "git.aiterp.net/lucifer3/server/device"
  6. "git.aiterp.net/lucifer3/server/effects"
  7. "git.aiterp.net/lucifer3/server/events"
  8. "git.aiterp.net/lucifer3/server/internal/color"
  9. "git.aiterp.net/lucifer3/server/services"
  10. "git.aiterp.net/lucifer3/server/services/nanoleaf"
  11. "time"
  12. )
  13. func main() {
  14. bus := lucifer3.EventBus{}
  15. resolver := services.NewResolver()
  16. sceneMap := services.NewSceneMap(resolver)
  17. bus.JoinPrivileged(resolver)
  18. bus.JoinPrivileged(sceneMap)
  19. bus.Join(services.NewEffectEnforcer(resolver, sceneMap))
  20. bus.Join(nanoleaf.NewService())
  21. bus.JoinCallback(func(event lucifer3.Event) bool {
  22. switch event.(type) {
  23. case events.DeviceReady:
  24. bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:2d0c", Alias: "lucifer:name:Hex 5"})
  25. bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:542f", Alias: "lucifer:name:Hex 6"})
  26. bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:e760", Alias: "lucifer:name:Hex 7"})
  27. bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:207a", Alias: "lucifer:name:Hex 8"})
  28. bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:df9a", Alias: "lucifer:name:Hex 9"})
  29. bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:cdd5", Alias: "lucifer:name:Hex 4"})
  30. bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:4597", Alias: "lucifer:name:Hex 3"})
  31. bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:82cb", Alias: "lucifer:name:Hex 2"})
  32. bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:09fd", Alias: "lucifer:name:Hex 1"})
  33. bus.RunCommand(commands.Assign{
  34. Match: "nanoleaf:10.80.1.14:*",
  35. Effect: effects.Pattern{
  36. States: []device.State{
  37. {Power: p(true), Intensity: p(1.0), Color: p(color.MustParse("xy:0.22,0.18"))},
  38. {Power: p(true), Intensity: p(0.4), Color: p(color.MustParse("xy:0.22,0.18"))},
  39. {Power: p(true), Intensity: p(0.5), Color: p(color.MustParse("xy:0.22,0.18"))},
  40. },
  41. AnimationMS: 200,
  42. },
  43. })
  44. time.Sleep(time.Second * 1)
  45. bus.RunCommand(commands.AddAlias{Match: "nanoleaf:10.80.1.14:*", Alias: "lucifer:tag:Magic Lamps"})
  46. bus.RunCommand(commands.Assign{
  47. Match: "lucifer:tag:Magic Lamps",
  48. Effect: effects.Pattern{
  49. States: []device.State{
  50. {Power: p(true), Intensity: p(1.0), Color: p(color.MustParse("hs:0,0.9"))},
  51. {Power: p(true), Intensity: p(0.7), Color: p(color.MustParse("hs:100,0.8"))},
  52. },
  53. AnimationMS: 500,
  54. },
  55. })
  56. return false
  57. }
  58. return true
  59. })
  60. bus.RunCommand(commands.ConnectDevice{
  61. ID: "nanoleaf:10.80.1.14",
  62. APIKey: "QRj5xcQxAQMQsjK4gvaprdhOwr1sCIcj",
  63. })
  64. time.Sleep(time.Hour)
  65. }
  66. func p[T any](v T) *T {
  67. return &v
  68. }