3 Commits
Author SHA1 Message Date
gisle d5cf30ea4b sensitize periodic light refresh in hue2 again.
continuous-integration/drone/push Build is passing
2022-02-19 20:43:38 +01:00
gisle 582bf3f46b decrease sensitivity in hue2 (should fix double press, regular check over-updating and massive update storms when regular checks find a lot of incongruences), and fix rare race condition
continuous-integration/drone/push Build is passing
2022-02-19 10:06:40 +01:00
gisle c72a7c3f43 fix xy color conversion using srgb instead of rgb.
continuous-integration/drone/push Build is passing
2022-02-18 17:01:37 +01:00
2 changed files with 16 additions and 2 deletions
+15 -1
View File
@@ -55,6 +55,7 @@ func (b *Bridge) Run(ctx context.Context, eventCh chan<- models.Event) error {
absences := make(map[int]time.Time)
lastPress := make(map[string]time.Time)
lastUpdate := time.Now()
needFull := false
for {
@@ -62,6 +63,10 @@ func (b *Bridge) Run(ctx context.Context, eventCh chan<- models.Event) error {
case <-ctx.Done():
return ctx.Err()
case <-lightRefreshTimer.C:
if time.Since(lastUpdate) < time.Second*2 {
continue
}
if needFull {
err := b.RefreshAll(ctx)
if err != nil {
@@ -79,9 +84,16 @@ func (b *Bridge) Run(ctx context.Context, eventCh chan<- models.Event) error {
return err
}
if updated > 0 {
// Force this to cool for 30 seconds unless a manual update occurs.
if updated > 10 {
lastUpdate = time.Now().Add(time.Second * 15)
}
log.Println(fmt.Sprintf("[Bridge %d]", b.externalID), "Updated", updated, "hue services (regular check)")
}
case <-b.needsUpdate:
lastUpdate = time.Now()
updated, err := b.MakeCongruent(ctx)
if err != nil {
return err
@@ -125,9 +137,11 @@ func (b *Bridge) Run(ctx context.Context, eventCh chan<- models.Event) error {
continue
}
b.mu.Lock()
if b.resources[patch.Owner.ID] == nil {
needFull = true
}
b.mu.Unlock()
device, deviceOK := b.devices[patch.Owner.ID]
if !deviceOK || device.ID == 0 {
@@ -141,7 +155,7 @@ func (b *Bridge) Run(ctx context.Context, eventCh chan<- models.Event) error {
} else if patch.Button.LastEvent == "long_release" {
valid = false
} else {
valid = lastPress[patch.ID].Unix() != data.CreationTime.Unix()
valid = data.CreationTime.Sub(lastPress[patch.ID]) >= time.Second*2
}
if valid {
+1 -1
View File
@@ -177,7 +177,7 @@ func hsToXY(hue, sat float64) ColorXY {
green := float64(green255) / 255.0
blue := float64(blue255) / 255.0
return screenRGBToXY(red, green, blue)
return rgbToXY(red, green, blue)
}
func rgbToXY(red float64, green float64, blue float64) ColorXY {