aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorBen Burwell <ben@benburwell.com>2018-05-24 23:19:26 -0400
committerBen Burwell <ben@benburwell.com>2018-05-24 23:19:26 -0400
commit65b8fb514db9fc5125494b3393699bf666ed9cb2 (patch)
tree1403327124796b215ebdb1982af135943732e6cd /main.go
parenta3786c8698f8b7c85d09e241cf09dc0e8ced9da2 (diff)
Get lat/long from config file
Diffstat (limited to 'main.go')
-rw-r--r--main.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/main.go b/main.go
index 76f5838..6253cbb 100644
--- a/main.go
+++ b/main.go
@@ -11,12 +11,16 @@ import (
const username = "phlux"
func main() {
+ var config PhluxConfig
+ config.Read()
+ log.Println("Config:", config)
+
bridges, err := hue.FindBridges()
if err != nil {
log.Fatalf("Error finding bridges: %s\n", err.Error())
}
log.Printf("Found %d bridge(s)\n", len(bridges))
- desiredColorTemp := getDesiredColorTemperature(time.Now())
+ desiredColorTemp := getDesiredColorTemperature(time.Now(), config.Latitude, config.Longitude)
for _, bridge := range bridges {
log.Printf("Bridge: %s\n", bridge.IPAddress)
updateBridge(bridge, desiredColorTemp)
@@ -31,9 +35,17 @@ func updateBridge(bridge hue.Bridge, ct ColorTemperature) {
//fmt.Printf("Made user %s for bridge %s\n", username, bridge.IPAddress)
err := bridge.Login(os.Getenv("HUE_LOGIN"))
if err != nil {
- log.Fatalf("Could not log in to bridge: %s", err.Error())
+ log.Fatalf("Could not log in to bridge: %s\n", err.Error())
}
log.Println("Logged in to bridge")
+
+ config, err := bridge.GetConfig()
+ if err != nil {
+ log.Fatalf("Could not get bridge info: %s\n", err.Error())
+ }
+ log.Printf("Bridge name: %s\n", config.Name)
+ log.Printf("Bridge ID: %s\n", config.BridgeID)
+
lights, err := bridge.GetAllLights()
if err != nil {
log.Fatalf("Error getting lights: %s\n", err.Error())