Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@
# Go workspace file
go.work

*.DS_Store
*.DS_Store

.direnv/
4 changes: 3 additions & 1 deletion examples/queryPrice.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
53 changes: 32 additions & 21 deletions tibber/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tibber/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down