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
78 lines
2.3 KiB
package main
|
|
|
|
import (
|
|
lucifer3 "git.aiterp.net/lucifer3/server"
|
|
"git.aiterp.net/lucifer3/server/commands"
|
|
"git.aiterp.net/lucifer3/server/device"
|
|
"git.aiterp.net/lucifer3/server/events"
|
|
"git.aiterp.net/lucifer3/server/internal/color"
|
|
"git.aiterp.net/lucifer3/server/internal/gentools"
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
bus := lucifer3.EventBus{}
|
|
|
|
bus.JoinCallback(func(event lucifer3.Event) bool {
|
|
switch event := event.(type) {
|
|
case events.Connected:
|
|
log.Println("Callback got connect event for", event.Prefix)
|
|
}
|
|
|
|
return true
|
|
})
|
|
|
|
bus.RunEvent(events.Connected{Prefix: "nanoleaf:10.80.1.11"})
|
|
|
|
time.Sleep(time.Second / 2)
|
|
|
|
for _, id := range []string{"e28c", "67db", "f744", "d057", "73c1"} {
|
|
bus.RunEvent(events.HardwareState{
|
|
DeviceID: "nanoleaf:10.80.1.11:" + id,
|
|
SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
|
|
ColorFlags: device.CFlagRGB,
|
|
State: device.State{},
|
|
})
|
|
}
|
|
|
|
bus.RunCommand(commands.ReplaceScene{
|
|
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"},
|
|
SceneID: 7,
|
|
})
|
|
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"} {
|
|
bus.RunCommand(commands.SetState{
|
|
ID: id,
|
|
State: device.State{
|
|
Power: gentools.Ptr(true),
|
|
Intensity: gentools.Ptr(0.75),
|
|
Color: gentools.Ptr(color.MustParse("xy:0.3209,0.1542")),
|
|
},
|
|
})
|
|
}
|
|
|
|
time.Sleep(time.Second / 2)
|
|
|
|
bus.RunEvent(events.HardwareState{
|
|
DeviceID: "nanoleaf:10.80.1.11:40e5",
|
|
SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
|
|
ColorFlags: device.CFlagRGB,
|
|
State: device.State{},
|
|
})
|
|
bus.RunCommand(commands.ReplaceScene{
|
|
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"},
|
|
SceneID: 7,
|
|
})
|
|
bus.RunCommand(commands.SetState{
|
|
ID: "nanoleaf:10.80.1.11:40e5",
|
|
State: device.State{
|
|
Power: gentools.Ptr(true),
|
|
Intensity: gentools.Ptr(0.75),
|
|
Color: gentools.Ptr(color.MustParse("xy:0.3209,0.1542")),
|
|
},
|
|
})
|
|
|
|
time.Sleep(time.Second / 4)
|
|
|
|
time.Sleep(time.Second * 4)
|
|
}
|