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.3 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
  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/events"
  7. "git.aiterp.net/lucifer3/server/internal/color"
  8. "git.aiterp.net/lucifer3/server/internal/gentools"
  9. "log"
  10. "time"
  11. )
  12. func main() {
  13. bus := lucifer3.EventBus{}
  14. bus.JoinCallback(func(event lucifer3.Event) bool {
  15. switch event := event.(type) {
  16. case events.Connected:
  17. log.Println("Callback got connect event for", event.Prefix)
  18. }
  19. return true
  20. })
  21. bus.RunEvent(events.Connected{Prefix: "nanoleaf:10.80.1.11"})
  22. time.Sleep(time.Second / 2)
  23. for _, id := range []string{"e28c", "67db", "f744", "d057", "73c1"} {
  24. bus.RunEvent(events.HardwareState{
  25. DeviceID: "nanoleaf:10.80.1.11:" + id,
  26. SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
  27. ColorFlags: device.CFlagRGB,
  28. State: device.State{},
  29. })
  30. }
  31. bus.RunCommand(commands.ReplaceScene{
  32. IDs: []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. SceneID: 7,
  34. })
  35. 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"} {
  36. bus.RunCommand(commands.SetState{
  37. ID: id,
  38. State: device.State{
  39. Power: gentools.Ptr(true),
  40. Intensity: gentools.Ptr(0.75),
  41. Color: gentools.Ptr(color.MustParse("xy:0.3209,0.1542")),
  42. },
  43. })
  44. }
  45. time.Sleep(time.Second / 2)
  46. bus.RunEvent(events.HardwareState{
  47. DeviceID: "nanoleaf:10.80.1.11:40e5",
  48. SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
  49. ColorFlags: device.CFlagRGB,
  50. State: device.State{},
  51. })
  52. bus.RunCommand(commands.ReplaceScene{
  53. IDs: []string{"nanoleaf:10.80.1.11:40e5", "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"},
  54. SceneID: 7,
  55. })
  56. bus.RunCommand(commands.SetState{
  57. ID: "nanoleaf:10.80.1.11:40e5",
  58. State: device.State{
  59. Power: gentools.Ptr(true),
  60. Intensity: gentools.Ptr(0.75),
  61. Color: gentools.Ptr(color.MustParse("xy:0.3209,0.1542")),
  62. },
  63. })
  64. time.Sleep(time.Second / 4)
  65. time.Sleep(time.Second * 4)
  66. }