diff --git a/tariff/tibber.go b/tariff/tibber.go index 24af9bf8e..4b216c316 100644 --- a/tariff/tibber.go +++ b/tariff/tibber.go @@ -83,21 +83,21 @@ func NewTibberFromConfig(other map[string]interface{}) (api.Tariff, error) { func (t *Tibber) run(done chan error) { var once sync.Once + var res struct { + Viewer struct { + Home struct { + ID string + TimeZone string + CurrentSubscription tibber.Subscription + } `graphql:"home(id: $id)"` + } + } + + v := map[string]interface{}{ + "id": graphql.ID(t.homeID), + } + for ; true; <-time.NewTicker(time.Hour).C { - var res struct { - Viewer struct { - Home struct { - ID string - TimeZone string - CurrentSubscription tibber.Subscription - } `graphql:"home(id: $id)"` - } - } - - v := map[string]interface{}{ - "id": graphql.ID(t.homeID), - } - ctx, cancel := context.WithTimeout(context.Background(), request.Timeout) err := t.client.Query(ctx, &res, v) cancel()