add pattern cache and id sorting to resolver.

This commit is contained in:
2022-08-17 19:55:24 +02:00
parent 6eb03b2e44
commit b6262007c0
2 changed files with 93 additions and 33 deletions
+9 -8
View File
@@ -21,10 +21,11 @@ func main() {
time.Sleep(time.Second / 2)
numbers := []int{5, 2, 3, 1, 4}
for i, id := range []string{"e28c", "67db", "f744", "d057", "73c1"} {
bus.RunEvent(events.HardwareState{
ID: "nanoleaf:10.80.1.11:" + id,
InternalName: fmt.Sprintf("Hexagon %d", i+1),
InternalName: fmt.Sprintf("Hexagon %d", numbers[i]),
SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
ColorFlags: device.CFlagRGB,
State: device.State{},
@@ -45,13 +46,6 @@ func main() {
time.Sleep(time.Second / 8)
bus.RunCommand(commands.ReplaceScene{
Match: "lucifer:name:Hex*",
SceneID: 7,
})
time.Sleep(time.Second / 8)
bus.RunEvent(events.HardwareState{
ID: "nanoleaf:10.80.1.11:40e5",
InternalName: "Hexagon 6",
@@ -62,6 +56,13 @@ func main() {
time.Sleep(time.Second / 8)
bus.RunCommand(commands.ReplaceScene{
Match: "lucifer:name:Hex*",
SceneID: 7,
})
time.Sleep(time.Second / 8)
log.Println("Search \"**:Hexagon {1,5,6}\"")
for _, dev := range resolver.Resolve("lucifer:name:Hexagon {1,5,6}") {
log.Println("- ID:", dev.ID)