fixed hue updating too often, and change logic for fetchbyreference to support multiple tags, ids or bridges.

This commit is contained in:
2021-09-20 22:09:41 +02:00
parent 56a0525b9d
commit 2f9bd3c007
4 changed files with 44 additions and 19 deletions
+4 -4
View File
@@ -35,8 +35,8 @@ func StartEventHandler() {
for range time.NewTicker(time.Minute).C {
config.EventChannel <- models.Event{Name: "TimeChanged", Payload: map[string]string{
"weekdayName": time.Now().In(loc).Format("Monday"),
"month": time.Now().In(loc).Format("01"),
"year": time.Now().In(loc).Format("2006"),
"month": time.Now().In(loc).Format("01"),
"year": time.Now().In(loc).Format("2006"),
}}
}
}()
@@ -49,7 +49,7 @@ func handleEvent(event models.Event) (responses []models.Event) {
startTime := time.Now()
defer func() {
duration := time.Since(startTime)
if duration > time.Millisecond * 250 {
if duration > time.Millisecond*250 {
log.Println(event.Name, "took long to handle:", duration)
}
}()
@@ -134,7 +134,7 @@ func handleEvent(event models.Event) (responses []models.Event) {
if action.SetIntensity != nil {
newState.Intensity = action.SetIntensity
} else if action.AddIntensity != nil {
newIntensity := math.Max(0, math.Min(1, device.State.Intensity + *action.AddIntensity))
newIntensity := math.Max(0, math.Min(1, device.State.Intensity+*action.AddIntensity))
newState.Intensity = &newIntensity
}