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.

72 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. 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. Match: "lucifer:name:Hex*",
  29. SceneID: 7,
  30. })
  31. time.Sleep(time.Second / 8)
  32. bus.RunCommand(commands.AddAlias{
  33. Match: "nanoleaf:10.80.1.{11,7,16,5}:*",
  34. Alias: "lucifer:tag:Magic Lamps",
  35. })
  36. time.Sleep(time.Second / 8)
  37. bus.RunCommand(commands.ReplaceScene{
  38. Match: "lucifer:name:Hex*",
  39. SceneID: 7,
  40. })
  41. time.Sleep(time.Second / 8)
  42. bus.RunEvent(events.HardwareState{
  43. ID: "nanoleaf:10.80.1.11:40e5",
  44. InternalName: "Hexagon 6",
  45. SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
  46. ColorFlags: device.CFlagRGB,
  47. State: device.State{},
  48. })
  49. time.Sleep(time.Second / 8)
  50. log.Println("Search \"**:Hexagon {1,5,6}\"")
  51. for _, dev := range resolver.Resolve("lucifer:name:Hexagon {1,5,6}") {
  52. log.Println("- ID:", dev.ID)
  53. log.Println(" Aliases:", dev.Aliases)
  54. }
  55. time.Sleep(time.Second / 4)
  56. }