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.

78 lines
2.0 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. "fmt"
  4. lucifer3 "git.aiterp.net/lucifer3/server"
  5. "git.aiterp.net/lucifer3/server/commands"
  6. "git.aiterp.net/lucifer3/server/device"
  7. "git.aiterp.net/lucifer3/server/events"
  8. "git.aiterp.net/lucifer3/server/internal/color"
  9. "git.aiterp.net/lucifer3/server/internal/gentools"
  10. "git.aiterp.net/lucifer3/server/services"
  11. "time"
  12. )
  13. func main() {
  14. bus := lucifer3.EventBus{}
  15. bus.Join(services.Resolver())
  16. bus.RunEvent(events.Connected{Prefix: "nanoleaf:10.80.1.11"})
  17. time.Sleep(time.Second / 2)
  18. for i, id := range []string{"e28c", "67db", "f744", "d057", "73c1"} {
  19. bus.RunEvent(events.HardwareState{
  20. ID: "nanoleaf:10.80.1.11:" + id,
  21. InternalName: fmt.Sprintf("Hexagon %d", i+1),
  22. SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
  23. ColorFlags: device.CFlagRGB,
  24. State: device.State{},
  25. })
  26. }
  27. bus.RunCommand(commands.ReplaceScene{
  28. IDs: []string{"lucifer:name:Hexagon*"},
  29. SceneID: 7,
  30. })
  31. time.Sleep(time.Second / 4)
  32. for _, id := range []string{"nanoleaf:10.80.1.11:e28c", "nanoleaf:10.80.1.11:67db", "nanoleaf:10.80.1.11:f744", "nanoleaf:10.80.1.11:d057", "nanoleaf:10.80.1.11:73c1"} {
  33. bus.RunCommand(commands.SetState{
  34. ID: id,
  35. State: device.State{
  36. Power: gentools.Ptr(true),
  37. Intensity: gentools.Ptr(0.75),
  38. Color: gentools.Ptr(color.MustParse("xy:0.3209,0.1542")),
  39. },
  40. })
  41. }
  42. time.Sleep(time.Second / 2)
  43. bus.RunEvent(events.HardwareState{
  44. ID: "nanoleaf:10.80.1.11:40e5",
  45. InternalName: "Hexagon 6",
  46. SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
  47. ColorFlags: device.CFlagRGB,
  48. State: device.State{},
  49. })
  50. bus.RunCommand(commands.ReplaceScene{
  51. IDs: []string{"lucifer:name:Hexagon*"},
  52. SceneID: 7,
  53. })
  54. time.Sleep(time.Second / 4)
  55. bus.RunCommand(commands.SetState{
  56. ID: "nanoleaf:10.80.1.11:40e5",
  57. State: device.State{
  58. Power: gentools.Ptr(true),
  59. Intensity: gentools.Ptr(0.75),
  60. Color: gentools.Ptr(color.MustParse("xy:0.3209,0.1542")),
  61. },
  62. })
  63. time.Sleep(time.Second / 4)
  64. }