add rest of hue driver functionality.
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"git.aiterp.net/lucifer/new-server/app/config"
|
||||
@@ -63,8 +64,6 @@ func main() {
|
||||
devices[i].ID = i + 1
|
||||
}
|
||||
|
||||
_ = driver.Publish(context.Background(), bridge, devices)
|
||||
|
||||
ch := config.EventChannel
|
||||
go func() {
|
||||
err := driver.Run(context.Background(), bridge, ch)
|
||||
@@ -86,6 +85,11 @@ func main() {
|
||||
text, _ := reader.ReadString('\n')
|
||||
text = strings.Trim(text, "\t \r\n")
|
||||
|
||||
if text == "json" {
|
||||
j, _ := json.MarshalIndent(devices, "", " ")
|
||||
fmt.Println(string(j))
|
||||
}
|
||||
|
||||
tokens := strings.Split(text, " ")
|
||||
if len(tokens) < 4 {
|
||||
continue
|
||||
@@ -122,15 +126,15 @@ func main() {
|
||||
for _, id := range ids {
|
||||
if id == -1 || id == device.ID {
|
||||
if (color.IsKelvin() && device.HasCapability(models.DCColorKelvin)) || (color.IsHueSat() && device.HasCapability(models.DCColorHS)) {
|
||||
device.State.Color = color
|
||||
if device.HasCapability(models.DCPower) {
|
||||
device.State.Power = power
|
||||
}
|
||||
if device.HasCapability(models.DCIntensity) {
|
||||
device.State.Intensity = intensity
|
||||
}
|
||||
updatedDevices = append(updatedDevices, device)
|
||||
}
|
||||
|
||||
updatedDevices = append(updatedDevices, device)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user