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.

73 lines
1.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
  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/services"
  9. "log"
  10. "time"
  11. )
  12. func main() {
  13. bus := lucifer3.EventBus{}
  14. resolver := services.NewResolver()
  15. bus.Join(resolver)
  16. bus.RunEvent(events.Connected{Prefix: "nanoleaf:10.80.1.11"})
  17. time.Sleep(time.Second / 2)
  18. numbers := []int{5, 2, 3, 1, 4}
  19. for i, id := range []string{"e28c", "67db", "f744", "d057", "73c1"} {
  20. bus.RunEvent(events.HardwareState{
  21. ID: "nanoleaf:10.80.1.11:" + id,
  22. InternalName: fmt.Sprintf("Hexagon %d", numbers[i]),
  23. SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
  24. ColorFlags: device.CFlagRGB,
  25. State: device.State{},
  26. })
  27. }
  28. bus.RunCommand(commands.ReplaceScene{
  29. Match: "lucifer:name:Hex*",
  30. SceneID: 7,
  31. })
  32. time.Sleep(time.Second / 8)
  33. bus.RunCommand(commands.AddAlias{
  34. Match: "nanoleaf:10.80.1.{11,7,16,5}:*",
  35. Alias: "lucifer:tag:Magic Lamps",
  36. })
  37. time.Sleep(time.Second / 8)
  38. bus.RunEvent(events.HardwareState{
  39. ID: "nanoleaf:10.80.1.11:40e5",
  40. InternalName: "Hexagon 6",
  41. SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
  42. ColorFlags: device.CFlagRGB,
  43. State: device.State{},
  44. })
  45. time.Sleep(time.Second / 8)
  46. bus.RunCommand(commands.ReplaceScene{
  47. Match: "lucifer:name:Hex*",
  48. SceneID: 7,
  49. })
  50. time.Sleep(time.Second / 8)
  51. log.Println("Search \"**:Hexagon {1,5,6}\"")
  52. for _, dev := range resolver.Resolve("lucifer:name:Hexagon {1,5,6}") {
  53. log.Println("- ID:", dev.ID)
  54. log.Println(" Aliases:", dev.Aliases)
  55. }
  56. time.Sleep(time.Second / 4)
  57. }