Skip to content

Scripts and pipelines for tracking energy prices and consumption using the Tibber GraphQL API

License

Notifications You must be signed in to change notification settings

stefanes/tibber-pulse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tibber Pulse

Scripts for publishing Tibber energy prices and consumption to Grafana/Graphite.

Grafana

Installation

Note

To access the API you first must have a Tibber account (you can sign up for Tibber using the invitation code gqpkcwrn to get a €50/500 kr bonus for use in the Tibber Store).

Before manually running the scripts in found in this repo you need to first install and setup the following PowerShell modules:

See here and here for how to setup authentication.

Usage examples

Get today's and tomorrow's energy prices

Use tibber-price-json.ps1 to get today's and tomorrow's energy prices and and tibber-price-publish.ps1 to publish the data to the following Graphite series:

Graphite series Measurement Unit Resolution
tibber.hourly.price total SEK 1h
tibber.hourly.priceLevel level See below 1h
tibber.hourly.priceScore N/A See below 1h
tibber.hourly.priceAvg N/A SEK 1h
tibber.daily.priceAvg N/A SEK 1d

The tibber.hourly.priceLevel series contains the price levels as defined here, translated into the following values:

Price level Value
VERY_CHEAP 10
CHEAP 20
NORMAL 30
EXPENSIVE 40
VERY_EXPENSIVE 50

The tibber.hourly.priceScore series contains a custom price score as defined below:

Price score Value Definition
LOW -1 A price higher than average + 10%
MEDIUM 0 Average price +/- 10%
HIGH 1 A price lower than average - 10%

Get today's and tomorrow's energy prices:

PS> .\tibber-price-json.ps1 -Path 'C:\tibber'
...
Energy price (W. Europe Standard Time):
    0.7542 SEK at 2022-09-23 00:00:00 [level = 10] [score = 1]
    0.7113 SEK at 2022-09-23 01:00:00 [level = 10] [score = 1]
    ...
    1.0319 SEK at 2022-09-23 22:00:00 [level = 10] [score = 1]
    0.8517 SEK at 2022-09-23 23:00:00 [level = 10] [score = 1]

Energy price (W. Europe Standard Time):
    0.7041 SEK at 2022-09-24 00:00:00 [level = 10] [score = 1]
    0.7333 SEK at 2022-09-24 01:00:00 [level = 10] [score = 1]
    ...
    1.0208 SEK at 2022-09-24 22:00:00 [level = 10] [score = 1]
    0.9851 SEK at 2022-09-24 23:00:00 [level = 10] [score = 1]

Publish today's and tomorrow's energy prices to Graphite:

PS> .\tibber-price-publish.ps1 -Path 'C:\tibber'
Status |  Published Invalid
------ -  --------- -------
   200 OK 144       0

Get hourly/daily energy consumption

Use tibber-consumption.ps1 to get the billed consumption and publish the data (if the -Publish switch is provided) to the following Graphite series:

Graphite series Measurement Unit Resolution
tibber.hourly.consumption consumption Wh 1h
tibber.hourly.cost cost SEK 1h
tibber.daily.consumption consumption Wh 1d
tibber.daily.cost cost SEK 1d

Today's hourly energy consumption (last 24 hours):

PS> .\tibber-consumption.ps1
...
Hourly consumption (W. Europe Standard Time)...
From 2022-09-23 02:00:00 to 2022-09-23 03:00:00 (W. Europe Standard Time):
    3489 W
    2,49 SEK
...
From 2022-09-23 09:00:00 to 2022-09-23 10:00:00 (W. Europe Standard Time):
    177 W
    0,91 SEK

Yesterday's total energy consumption:

PS> .\tibber-consumption.ps1 -Daily
...
Daily consumption from 2022-09-22 00:00:00 to 2022-09-23 00:00:00 (W. Europe Standard Time):
    29451 W
    81,12 SEK

Get hourly/daily energy production

Use tibber-production.ps1 to get the billed production and publish the data (if the -Publish switch is provided) to the following Graphite series:

Graphite series Measurement Unit Resolution
tibber.hourly.production production Wh 1h
tibber.hourly.profit profit SEK 1h
tibber.daily.production production Wh 1d
tibber.daily.profit profit SEK 1d

Today's hourly energy production (last 24 hours):

PS> .\tibber-production.ps1
...
Hourly production (W. Europe Standard Time)...
From 2022-09-23 02:00:00 to 2022-09-23 03:00:00 (W. Europe Standard Time):
    3489 W
    2,49 SEK
...
From 2022-09-23 09:00:00 to 2022-09-23 10:00:00 (W. Europe Standard Time):
    177 W
    0,91 SEK

Yesterday's total energy production:

PS> .\tibber-production.ps1 -Daily
...
Daily production from 2022-09-22 00:00:00 to 2022-09-23 00:00:00 (W. Europe Standard Time):
    29451 W
    81,12 SEK

Get live measurements

Use tibber-live.ps1 to get live measurements and publish the data (if the -Publish switch is provided) to the following Graphite series:

Graphite series Measurement Unit Resolution
tibber.live.power power W 10s
tibber.live.powerProduction powerProduction W 10s
tibber.live.voltagePhase1 voltagePhase1 V 10s
tibber.live.voltagePhase2 voltagePhase2 V 10s
tibber.live.voltagePhase3 voltagePhase3 V 10s
tibber.live.currentL1 currentL1 A 10s
tibber.live.currentL2 currentL2 A 10s
tibber.live.currentL3 currentL3 A 10s
tibber.live.signalStrength signalStrength dB/% 2m

Read live measurements until a given time:

PS> .\tibber-live.ps1 -Until '2022-09-23 11:02'
...
New GraphQL subscription created: 9d1860e8-4625-4cf9-b865-6737e2dcde9e
Reading metrics until 2022-09-23 11:02 (W. Europe Standard Time)...
Live metrics at 2022-09-23 10:49:48 (W. Europe Standard Time):
    power: 0
    powerProduction: 480
...
Live metrics at 2022-09-23 11:02:08 (W. Europe Standard Time):
    power: 0
    powerProduction: 484
Read 75 package(s) in 743.2731528 seconds
GraphQL subscription stopped: 9d1860e8-4625-4cf9-b865-6737e2dcde9e

Graphite storage-schemas.conf

Recommended storage-schemas.conf settings:

[tibber.daily]
  pattern    = ^tibber\.daily\..*
  retentions = 1d:2y
[tibber.hourly]
  pattern    = ^tibber\.hourly\..*
  retentions = 1h:2y

[tibber.live.signalStrength]
  pattern    = ^tibber\.live\.signalStrength$
  retentions = 2m:8w4d
[tibber.live]
  pattern    = ^tibber\.live\..*
  retentions = 10s:1w1d

See here for how to change the storage schemas using the config API.

Time zones

Running these scripts on e.g. Azure Pipelines agent will by default log UTC times. To change this behaviour provide a time zone using the -TimeZone parameter:

PS> .\tibber-price-json.ps1 -Path 'C:\tibber' -TimeZone 'India Standard Time'
...
Energy price (India Standard Time):
    0.7542 SEK at 2022-09-23 03:30:00 [level = 10] [score = 1]
    0.7113 SEK at 2022-09-23 04:30:00 [level = 10] [score = 1]
    ...
    1.0319 SEK at 2022-09-24 01:30:00 [level = 10] [score = 1]
    0.8517 SEK at 2022-09-24 02:30:00 [level = 10] [score = 1]
...

List all available time zones:

Write-Host "Available time zone Ids:"
[TimeZoneInfo]::GetSystemTimeZones() | ForEach-Object {
    Write-Host $_.Id -ForegroundColor White
    Write-Host "Offset: $($_.BaseUtcOffset.ToString())"
}

Note: This will not impact the timestamp sent to Graphite.

About

Scripts and pipelines for tracking energy prices and consumption using the Tibber GraphQL API

Topics

Resources

License

Stars

Watchers

Forks