From 00968ed0cae76aec58eb6fe69d75032932ddbb6e Mon Sep 17 00:00:00 2001 From: SiddyP Date: Sat, 10 Jan 2026 20:08:35 +0100 Subject: [PATCH 1/4] add support for quarterly prices --- .gitignore | 4 +++- examples/queryPrice.go | 4 +++- tibber/queries.go | 53 +++++++++++++++++++++++++----------------- 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 55a49fa..4ca13ab 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,6 @@ # Go workspace file go.work -*.DS_Store \ No newline at end of file +*.DS_Store + +.direnv/ \ No newline at end of file diff --git a/examples/queryPrice.go b/examples/queryPrice.go index d43c3df..7abb284 100644 --- a/examples/queryPrice.go +++ b/examples/queryPrice.go @@ -21,7 +21,9 @@ func queryPriceExample() { Logger: slog.Default(), } - p := t.QueryPrice(ctx, &tibber.Price{}) + p := t.QueryPrice(ctx, &tibber.Price{ + Resolution: tibber.PriceInfoResolutionQuarterHourly, + }) fmt.Printf("Price: %v\n", p.Viewer.Homes) } diff --git a/tibber/queries.go b/tibber/queries.go index 6b0b68b..f3b2a8f 100644 --- a/tibber/queries.go +++ b/tibber/queries.go @@ -16,7 +16,15 @@ type Consumption struct { Last int } +type PriceInfoResolution string + +const ( + PriceInfoResolutionHourly PriceInfoResolution = "HOURLY" + PriceInfoResolutionQuarterHourly PriceInfoResolution = "QUARTER_HOURLY" +) + type Price struct { + Resolution PriceInfoResolution } type WebsocketSubscriptionUrl struct { @@ -88,35 +96,38 @@ func (q *Consumption) query(ctx context.Context, t *Client) HomeConsumptionRespo func (p *Price) query(ctx context.Context, t *Client) PriceResponse { req := graphql.NewRequest(` - query { - viewer { + query ($resolution: PriceInfoResolution) { + viewer { homes { currentSubscription{ - priceInfo{ - current{ - total - energy - tax - startsAt - } - today { - total - energy - tax - startsAt - } - tomorrow { - total - energy - tax - startsAt + priceInfo(resolution: $resolution){ + current{ + total + energy + tax + startsAt + } + today { + total + energy + tax + startsAt + } + tomorrow { + total + energy + tax + startsAt + } } } - } } } } `) + if p.Resolution != "" { + req.Var("resolution", p.Resolution) + } var price PriceResponse if err := t.APIClient.Run(ctx, req, &price); err != nil { log.Fatal(err) From ba5ab042db83510e23bb4631e630b076665e097b Mon Sep 17 00:00:00 2001 From: SiddyP Date: Sun, 25 Jan 2026 12:55:41 +0100 Subject: [PATCH 2/4] go1.24 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 2f90647..769eae4 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/SiddyP/gotibber -go 1.22.11 +go 1.24.0 require ( github.com/google/uuid v1.5.0 From 67000bf5890e797facb10f23043f7c745b008e02 Mon Sep 17 00:00:00 2001 From: SiddyP Date: Sun, 25 Jan 2026 12:56:06 +0100 Subject: [PATCH 3/4] go1.24 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 43294f2..76aacb3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: [ '1.22.x' ] + go-version: [ '1.24.x' ] steps: - uses: actions/checkout@v4 From 89faca87f68380a7222c5b9112e062d9da5c359c Mon Sep 17 00:00:00 2001 From: SiddyP Date: Sun, 25 Jan 2026 12:57:57 +0100 Subject: [PATCH 4/4] bump to v0.4.0 --- tibber/websocket.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tibber/websocket.go b/tibber/websocket.go index 480495b..d38a619 100644 --- a/tibber/websocket.go +++ b/tibber/websocket.go @@ -163,7 +163,7 @@ func socketConnection(sctx context.Context, t *Client) { h := http.Header{} h.Set("Authorization", "Bearer "+t.WebsocketClient.Config.Token) - h.Set("User-Agent", "REST github.com/SiddyP/gotibber/v0.3.0") + h.Set("User-Agent", "REST github.com/SiddyP/gotibber/v0.4.0") h.Set("Sec-Websocket-Protocol", "graphql-transport-ws") h.Set("Accept-Encoding", "gzip, deflate, br")