Bluelink: fix error if length of stamps is 0
Some checks failed
Release / call-build-workflow (push) Has been cancelled
Release / Publish Docker :release (push) Has been cancelled
Release / Github & APT (push) Has been cancelled
Release / Hassio Addon (push) Has been cancelled

This commit is contained in:
andig 2022-11-12 17:54:13 +01:00
parent 8e489460cf
commit 2c96276c9a

View file

@ -1,6 +1,7 @@
package bluelink
import (
"errors"
"fmt"
"sync"
"time"
@ -55,6 +56,10 @@ func (c *stampCollection) Get() (string, error) {
position = int(time.Since(c.Generated).Milliseconds()) / c.Frequency
}
if len(c.Stamps) == 0 {
return "", errors.New("no stamps available")
}
if position >= len(c.Stamps) {
position = len(c.Stamps) - 1
}