add state restore after Nanoleaf controller reboots.
This commit is contained in:
@@ -207,15 +207,29 @@ func (b *bridge) Run(ctx context.Context, info models.Bridge, ch chan<- models.E
|
||||
|
||||
go func() {
|
||||
ticker := time.NewTicker(time.Second * 5)
|
||||
hadErrors := false
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
case <-ctx2.Done():
|
||||
}
|
||||
|
||||
err := b.updateEffect(ctx)
|
||||
reqTimeout, cancel := context.WithTimeout(ctx2, time.Second*4)
|
||||
err := b.updateEffect(reqTimeout)
|
||||
cancel()
|
||||
if err != nil {
|
||||
log.Println("Failed to update effects:", err, "This error is non-fatal, and it will be retried shortly.")
|
||||
hadErrors = true
|
||||
} else if hadErrors {
|
||||
b.mu.Lock()
|
||||
for _, panel := range b.panels {
|
||||
panel.Stale = true
|
||||
panel.SlowUpdates = 3
|
||||
panel.TicksUntilSlowUpdate = 10
|
||||
}
|
||||
b.mu.Unlock()
|
||||
|
||||
hadErrors = false
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user