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
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -13,3 +13,4 @@ var ErrMissingToken = errors.New("driver is missing authentication information")
|
||||
var ErrIncorrectToken = errors.New("driver is not accepting authentication information")
|
||||
var ErrUnexpectedResponse = errors.New("driver api returned unexpected response (wrong driver selected?)")
|
||||
var ErrBridgeSearchFailed = errors.New("bridge search failed")
|
||||
var ErrAddressOnlyDryRunnable = errors.New("this address may only be used for a dry run")
|
||||
|
||||
Reference in New Issue
Block a user