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.
121 lines
3.1 KiB
121 lines
3.1 KiB
package main
|
|
|
|
import (
|
|
"fmt"
|
|
lucifer3 "git.aiterp.net/lucifer3/server"
|
|
"git.aiterp.net/lucifer3/server/commands"
|
|
"git.aiterp.net/lucifer3/server/device"
|
|
"git.aiterp.net/lucifer3/server/effects"
|
|
"git.aiterp.net/lucifer3/server/events"
|
|
"git.aiterp.net/lucifer3/server/internal/color"
|
|
"git.aiterp.net/lucifer3/server/internal/gentools"
|
|
"git.aiterp.net/lucifer3/server/services"
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
bus := lucifer3.EventBus{}
|
|
|
|
resolver := services.NewResolver()
|
|
sceneMap := services.NewSceneMap(resolver)
|
|
|
|
bus.Join(resolver)
|
|
bus.Join(sceneMap)
|
|
bus.Join(services.NewEffectEnforcer(resolver, sceneMap))
|
|
|
|
time.Sleep(time.Millisecond)
|
|
|
|
bus.RunEvent(events.Connected{Prefix: "nanoleaf:10.80.1.11"})
|
|
|
|
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", numbers[i]),
|
|
SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
|
|
ColorFlags: device.CFlagRGB,
|
|
State: device.State{},
|
|
})
|
|
}
|
|
|
|
time.Sleep(time.Millisecond)
|
|
|
|
bus.RunCommand(commands.ReplaceScene{
|
|
Match: "lucifer:name:Hex*",
|
|
SceneID: 7,
|
|
})
|
|
|
|
time.Sleep(time.Millisecond)
|
|
|
|
bus.RunCommand(commands.AddAlias{
|
|
Match: "nanoleaf:10.80.1.{11,7,16,5}:*",
|
|
Alias: "lucifer:tag:Magic Lamps",
|
|
})
|
|
|
|
time.Sleep(time.Millisecond)
|
|
|
|
bus.RunEvent(events.HardwareState{
|
|
ID: "nanoleaf:10.80.1.11:40e5",
|
|
InternalName: "Hexagon 6",
|
|
SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
|
|
ColorFlags: device.CFlagRGB,
|
|
State: device.State{},
|
|
})
|
|
bus.RunEvent(events.HardwareState{
|
|
ID: "nanoleaf:10.80.1.11:dead",
|
|
InternalName: "Hexagon 7",
|
|
SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
|
|
ColorFlags: device.CFlagRGB,
|
|
State: device.State{},
|
|
})
|
|
bus.RunEvent(events.HardwareState{
|
|
ID: "nanoleaf:10.80.1.11:beef",
|
|
InternalName: "Hexagon 8",
|
|
SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
|
|
ColorFlags: device.CFlagRGB,
|
|
State: device.State{},
|
|
})
|
|
|
|
time.Sleep(time.Millisecond)
|
|
|
|
bus.RunEvent(events.ExternalEvent{
|
|
Kind: "weather",
|
|
Values: map[string]string{
|
|
"location": "Brekstad",
|
|
"temperature_celsius": "21.00",
|
|
"precipitation_mm": "3.21",
|
|
},
|
|
})
|
|
|
|
time.Sleep(time.Millisecond)
|
|
|
|
bus.RunCommand(commands.Assign{
|
|
Match: "**:Hexagon *",
|
|
Effect: effects.Pattern{
|
|
States: []device.State{
|
|
{
|
|
Power: gentools.Ptr(true),
|
|
Color: gentools.Ptr(color.MustParse("rgb:#ff0000")),
|
|
Intensity: gentools.Ptr(1.0),
|
|
},
|
|
{
|
|
Power: gentools.Ptr(true),
|
|
Color: gentools.Ptr(color.MustParse("rgb:#00ff00")),
|
|
Intensity: gentools.Ptr(0.7),
|
|
},
|
|
},
|
|
ShiftMS: 1000,
|
|
},
|
|
})
|
|
|
|
time.Sleep(time.Millisecond * 100)
|
|
|
|
log.Println("Search \"**:Hexagon {1,5,6}\"")
|
|
for _, dev := range resolver.Resolve("lucifer:name:Hexagon {1,5,6}") {
|
|
log.Println("- ID:", dev.ID)
|
|
log.Println(" Aliases:", dev.Aliases)
|
|
}
|
|
|
|
time.Sleep(time.Second * 15)
|
|
}
|