mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-07 13:15:19 -06:00
DRY duration parsing
This commit is contained in:
@@ -2,10 +2,10 @@ package gomeassistant
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/golang-module/carbon"
|
||||
"github.com/saml-dev/gome-assistant/internal"
|
||||
ws "github.com/saml-dev/gome-assistant/internal/websocket"
|
||||
)
|
||||
|
||||
@@ -72,10 +72,7 @@ func (b eventListenerBuilder3) OnlyBefore(end string) eventListenerBuilder3 {
|
||||
}
|
||||
|
||||
func (b eventListenerBuilder3) Throttle(s DurationString) eventListenerBuilder3 {
|
||||
d, err := time.ParseDuration(string(s))
|
||||
if err != nil {
|
||||
log.Fatalf("Couldn't parse string duration passed to Throttle(): \"%s\" see https://pkg.go.dev/time#ParseDuration for valid time units", s)
|
||||
}
|
||||
d := internal.ParseDuration(string(s))
|
||||
b.eventListener.throttle = d
|
||||
return b
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user