Skip to content

Commit

Permalink
Be less verbose about interval changes
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanwichmann committed Mar 21, 2017
1 parent 5eb328d commit edd8cac
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
4 changes: 1 addition & 3 deletions day.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ func (day *Day) updateCyclic(configuration Configuration, location Geolocation,
currentInterval, err := day.currentInterval(time.Now())
if err != nil {
// should only happen when day has ended
log.Println("NEW DAY?", err.Error())
day.updateForDay(time.Now(), configuration, location)
} else {
channel <- currentInterval
timeLeftInInterval := currentInterval.End.Time.Sub(time.Now())
log.Printf("DAY - Time left in interval %v - %v: %v\n", currentInterval.Start.Time.Format("15:04"), currentInterval.End.Time.Format("15:04"), timeLeftInInterval)
time.Sleep(timeLeftInInterval + (1 * time.Second))
}
}
Expand Down Expand Up @@ -87,7 +85,7 @@ func (day *Day) updateForDay(date time.Time, configuration Configuration, locati
func (day *Day) currentInterval(timestamp time.Time) (Interval, error) {
// check if timestamp respresents the current day
if timestamp.After(day.endOfDay) {
return Interval{TimeStamp{time.Now(), 0, 0}, TimeStamp{time.Now(), 0, 0}}, errors.New("DAY - No current interval as the requested timestamp respresents a different day")
return Interval{TimeStamp{time.Now(), 0, 0}, TimeStamp{time.Now(), 0, 0}}, errors.New("No current interval as the requested timestamp respresents a different day")
}

// if we are between todays sunrise and sunset, return daylight interval
Expand Down
3 changes: 1 addition & 2 deletions interval.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Interval struct {
const lightStateUpdateIntervalInMinutes = 1

func (interval *Interval) updateCyclic(channel chan<- LightState) {
log.Printf("INTERVAL - Managing light state for interval %v to %v\n", interval.Start.Time.Format("15:04"), interval.End.Time.Format("15:04"))
log.Printf("Managing lights for interval %v to %v\n", interval.Start.Time.Format("15:04"), interval.End.Time.Format("15:04"))

// Now that we are responsible for the correct light states, send out the initial valid state
currentLightState := interval.calculateLightStateInInterval(time.Now())
Expand All @@ -55,7 +55,6 @@ func (interval *Interval) updateCyclic(channel chan<- LightState) {

// check if the interval ended
if time.Now().After(interval.End.Time) {
log.Printf("INTERVAL - Interval %v - %v ended. ", interval.Start.Time.Format("15:04"), interval.End.Time.Format("15:04"))
intervalEnded = true
}
}
Expand Down
5 changes: 2 additions & 3 deletions kelvin.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import "os"
var applicationVersion = "development"

func main() {
log.Printf("🚀 Kelvin %v starting up...\n", applicationVersion)
log.Printf("Kelvin %v starting up... 🚀\n", applicationVersion)
go CheckForUpdate(applicationVersion)
go handleSIGHUP()

Expand Down Expand Up @@ -78,7 +78,7 @@ func main() {
// Ignore devices that don't support dimming and colors
// TODO Move to bridge.go
if !hueLight.dimmable && !hueLight.supportsXYColor && !hueLight.supportsColorTemperature {
log.Printf("Device %v doesn't support any functionality we use. Exlude it from unnessesary polling.\n", hueLight.name)
log.Printf("Device %v doesn't support any functionality we use. Exlude it from unnessesary polling.\n", hueLight.name)
continue
}
lightChannel := make(chan LightState, 1)
Expand All @@ -103,7 +103,6 @@ func main() {
light <- state
}
case interval := <-intervalChannel:
log.Printf("⌘ - New interval received: %v - %v\n", interval.Start.Time.Format("15:04"), interval.End.Time.Format("15:04"))
go interval.updateCyclic(lightStateChannel)
}
}
Expand Down

0 comments on commit edd8cac

Please sign in to comment.