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.
49 lines
1.1 KiB
49 lines
1.1 KiB
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"git.aiterp.net/lucifer/new-server/internal/drivers/hue2"
|
|
"git.aiterp.net/lucifer/new-server/models"
|
|
"log"
|
|
)
|
|
|
|
func main() {
|
|
client := hue2.NewClient("10.80.8.8", "o2XKGgmVUGNBghYFdLUCVuinOTMxFH4pHV9PuTbU")
|
|
bridge := hue2.NewBridge(client)
|
|
|
|
err := bridge.RefreshAll(context.Background())
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
j, _ := json.Marshal(bridge.GenerateDevices())
|
|
fmt.Println(string(j))
|
|
|
|
ch := make(chan models.Event)
|
|
go func() {
|
|
for event := range ch {
|
|
log.Println("EVENT", event.Name, event.Payload)
|
|
}
|
|
}()
|
|
|
|
for i, dev := range bridge.GenerateDevices() {
|
|
device := dev
|
|
switch device.InternalID {
|
|
case "6d5a45b0-ec69-4417-8588-717358b05086":
|
|
c, _ := models.ParseColorValue("xy:0.22,0.18")
|
|
device.State.Color = c
|
|
device.State.Intensity = 0.3
|
|
case "a71128f4-5295-4ae4-9fbc-5541abc8739b":
|
|
c, _ := models.ParseColorValue("k:6500")
|
|
device.State.Color = c
|
|
device.State.Intensity = 0.2
|
|
}
|
|
|
|
device.ID = i + 1
|
|
bridge.Update(device)
|
|
}
|
|
|
|
err = bridge.Run(context.Background(), ch)
|
|
log.Println(err)
|
|
}
|