diff --git a/meter/template_test.go b/meter/template_test.go index 02023cdf9..de18cf163 100644 --- a/meter/template_test.go +++ b/meter/template_test.go @@ -11,6 +11,7 @@ import ( var acceptable = []string{ "invalid plugin source: ...", "missing mqtt broker configuration", + "missing token", "mqtt not configured", "not a SunSpec device", "missing password", // Powerwall diff --git a/meter/tibber-pulse.go b/meter/tibber-pulse.go index c1820c7e5..efa85fbc1 100644 --- a/meter/tibber-pulse.go +++ b/meter/tibber-pulse.go @@ -2,6 +2,7 @@ package meter import ( "encoding/json" + "errors" "sync" "time" @@ -33,6 +34,10 @@ func NewTibberFromConfig(other map[string]interface{}) (api.Meter, error) { return nil, err } + if cc.Token == "" { + return nil, errors.New("missing token") + } + t := &Tibber{ log: util.NewLogger("pulse").Redact(cc.Token, cc.HomeID), } @@ -47,20 +52,6 @@ func NewTibberFromConfig(other map[string]interface{}) (api.Meter, error) { } } - // // get websocket uri - // var res struct { - // Viewer struct { - // WebsocketSubscriptionUrl string - // } - // } - - // ctx, cancel := context.WithTimeout(context.Background(), request.Timeout) - // defer cancel() - - // if err := qclient.Query(ctx, &res, nil); err != nil { - // return nil, err - // } - // subscription client client := graphql.NewSubscriptionClient(tibber.SubscriptionURI). WithConnectionParams(map[string]any{ diff --git a/tariff/tibber.go b/tariff/tibber.go index 0a5ec7635..898f08045 100644 --- a/tariff/tibber.go +++ b/tariff/tibber.go @@ -31,6 +31,10 @@ func NewTibber(other map[string]interface{}) (*Tibber, error) { Cheap float64 } + if cc.Token == "" { + return nil, errors.New("missing token") + } + if err := util.DecodeOther(other, &cc); err != nil { return nil, err }