Skip to content

Commit

Permalink
Wait for bridge on startup (fixes #61)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanwichmann committed Apr 9, 2019
1 parent ec2dd2d commit 4bf0952
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ func (bridge *HueBridge) discover(ip string) error {
// we have a known IP address. Validate if it points to a reachable bridge
bridge.BridgeIP = ip
err := bridge.validateBridge()
if err == nil {
return nil
if err != nil {
return err
}
return nil
}
log.Debugf("⌘ Starting bridge discovery")
bridges, err := hue.DiscoverBridges(false)
Expand Down
12 changes: 9 additions & 3 deletions kelvin.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ func main() {
go startInterface()

// Find Hue bridge
err = bridge.InitializeBridge(configuration)
if err != nil {
log.Warning(err)
log.Printf("🤖 Initializing bridge connection...")
for {
err = bridge.InitializeBridge(configuration)
if err != nil {
log.Errorf("Could not initialze bridge: %v - Retrying...", err)
time.Sleep(10 * time.Second)
} else {
break
}
}

// Find geo location
Expand Down

0 comments on commit 4bf0952

Please sign in to comment.