Tibber - Schedul prices upcoming 24 hours prices!

Hello Ingo,
i am following your entries the last month because your work is excelent and gladly you share it with us!
One question. Right now i am useing a NodeRed logic that is quite well working. Has some issues not loading my battery fully, but it is ok. It’s for sonnenbatteries.

This logic calculates the battery charged energy price and prevents from discharging when tibber is cheaper.
Is this possible with your logic too?

Also very prommissig looks this plugin but i couldn’t bring it to work.

Hello
I like this card. But now I have a problem. Since this month my Tibber is active. But in “Verbrauch & Kosten” I have Problems. It is the first month with tibber, an I did not know the real “Gebühren” . So I set them to 100 and 90.

But the footer shows 0 Eur. And I think the coöour is not correct.

Also the “Preis” is 0.
grafik

What do you must see to help?

I reloaded all sensors from this post

But my problem goes on.
Than I reloaded 1 sensor with an action and after that I see in the logs

Template variable error: list object has no element 0 when rendering '{{ value_json.data.viewer.homes[0].consumption.nodes[0].consumption | float (default=0) }}'
Template variable error: list object has no element 0 when rendering '{{ value_json.data.viewer.homes[0].consumption.nodes[0].cost | float (default=0) }}'

This the template-sensor

  # Tibber Monthly Consumption Sensor
  - platform: rest
    unique_id: tibber_monthly_consumption
    name: Tibber Monthly Consumption
    resource: https://api.tibber.com/v1-beta/gql
    method: POST
    payload: '{ "query": "{ viewer { homes { consumption(resolution: MONTHLY, last: 12) { nodes { consumption cost unitPrice unitPriceVAT from to } } } } }" }'
    json_attributes_path: "$.data.viewer.homes[0].consumption"
    json_attributes:
      - nodes
    value_template: "{{ value_json.data.viewer.homes[0].consumption.nodes[0].consumption | float (default=0) }}"
    scan_interval: 300
    headers:
      Authorization: !secret tibber_token
      Content-Type: application/json
    unit_of_measurement: kWh
    state_class: total

Can somebody help?

You add your Tibber Token in /homeassistant/secrets.yaml ?

My solution
I changed my former card to the card from thecem

Than I found from Ingo [quote=“ingo.niehues, post:202, topic:391565”]
Tibber Actual Month Cost-Sensor[/quote]
and deleted the Rest-Sensor.

Than I changed for “Gesamt” opacity and stroke_width to 0.1 and 1.

At least I have in 24-Stunden a Problem. This values are zero. In 30 Tage they are o.k.
grafik

So I hope for a last help by the zero-values.

For some reason I don’t get data via the data_generator. Tried with this solution as well as other and always get stuck in “Loading…”. Any advice?

PS: Missed to add the REST sensor. Sorry for the noise.

seeing the complete code might help…

so for me the code in the screenshot is cut off…

You won’t be able to generate a curve with this data_generator: code!

In your screenshot above, the code goes up to line 18 but is unfortunately cut off on the right!

Hi @KlausB and @ingo.niehues , same question/issue:

  • sensor.tibber_verbrauch_daily/weekly/monthly/yearly are these 4 created utility meters with the total consumption set (one for daily, one for weekly, one for monthly and one for yearly)?

  • how can I create the daily, weekly, monthly and yearly costs per kwh?
    When I try toss-up a template helper sensor and put in the code:

{{ (states(“sensor.tibber_kosten_daily”) | float(default=0) / states(“sensor.tibber_verbrauch_daily”) | float(default=0) * 100) | float(default=0) }}

where can I retrieve the “sensor.tibber_kosten_daily” (I added the tibber example prices tibber_prices rest api to my configuration.yaml)?

Thanks so much for the code, unfortunately I spend way too many hours trying to make it work (each restart take times), but the entity always stay at “Unknown”


I did add the code in configuration.yaml, like so

sensor:

  • platform: rest
    unique_id: tibber_prices
    name: Tibber Prices
    resource: https://api.tibber.com/v1-beta/gql
    method: POST
    payload: ‘{ “query”: “{ viewer { homes { currentSubscription { status priceInfo { current { total level } today { total level } tomorrow { total level } } } } } }” }’
    json_attributes_path: “$.data.viewer.homes[0].currentSubscription.priceInfo”
    json_attributes:
    • today
    • tomorrow
      value_template: “{{ value_json.data.viewer.homes[0].currentSubscription.priceInfo.current.total | float }}”
      scan_interval: 30
      headers:
      Authorization: !secret tibber_token
      Content-Type: application/json
      User-Agent: REST
      unit_of_measurement: EUR/kWh

and I did add the tibber_token: in secrets.yaml

In the logs I have:

Logger: homeassistant.components.rest.data
Source: components/rest/data.py:114
integration: RESTful (documentation, issues)
First occurred: 6 May 2025 at 20:16:53 (7 occurrences)
Last logged: 08:15:53

Timeout while fetching data: https://api.tibber.com/v1-beta/gql

Logger: homeassistant.components.rest.util
Source: components/rest/util.py:18
integration: RESTful (documentation, issues)
First occurred: 6 May 2025 at 20:16:53 (7 occurrences)
Last logged: 08:15:53

Empty reply found when expecting JSON data

Logger: homeassistant.components.rest.util
Source: components/rest/util.py:37
integration: RESTful (documentation, issues)
First occurred: 6 May 2025 at 15:51:41 (253 occurrences)
Last logged: 10:44:43

REST result could not be parsed as JSON

Logger: homeassistant.components.rest.util
Source: components/rest/util.py:33
integration: RESTful (documentation, issues)
First occurred: 6 May 2025 at 15:51:41 (6727 occurrences)
Last logged: 11:15:43

JSON result was not a dictionary or list with 0th element a dictionary

This tibber code is the only thing in my HA trying to use rest.

Otherwise the official Tibber integration is working and fetching the data, I could even successfully get manually the forecast with the action tibber.get_prices

Could someone please help? It would be so amazing and saving me money, if I could have the forecast in HA

Hello everyone,
Tibber has just announced that it will switch to quarter-hourly pricing starting in June.
How does this affect the data query and the code used to display the price curves?

2 Likes

Hi,

I got the basics working but 3 sensors are missing:

  • sensor.tibber_aktueller_Prijs_ist_tageshochstPrijs
  • sensor.tibber_kosten_daily
  • sensor.tibber_kosten_je_kwh_daily

Anyone got ay ideas how to create them?

Hi Ingo! Danke erstmal für deine tolle card.

I have two Questions: How did you manage to calculate the daily, monthly, weekly and yearly costs from Tibber? My Tibber integration has no Sensor i could use as an Input for the utility meter, because the Tibber entitys always reset. Which entity did you used as the source?

Sencond Question:
How are the icons called for “Tibber Preisspanne Heute” and “Tibber aktueller Preis ist Tageshochstpreis”? I scrolled like 15 minutes the endless icon dropdown list and searched every keyword. Could not find it :frowning:

Based on Ingos Charts, i created a chart for a 15 min Interval

type: custom:apexcharts-card
experimental:
  color_threshold: true
all_series_config:
  unit: Cent/kWh
apex_config:
  grid:
    show: true
    borderColor: "#E0E0E0"
  chart:
    height: 200px
    offsetY: -20
  tooltip:
    enabled: true
    followCursor: false
    x:
      show: false
    fixed:
      enabled: true
  xaxis:
    type: datetime
    labels:
      format: HH:mm
      datetimeFormatter:
        hour: HH:mm
        day: HH:mm
    tickAmount: 8
    tooltip:
      enabled: false
header:
  show: true
  show_states: true
  colorize_states: true
  standard_format: false
graph_span: 48h
now:
  show: true
  color: 9E9E9E
  label: jetzt
span:
  start: day
series:
  - entity: sensor.fredenbeck_strompreis
    attribute: min_price
    unit: Cent
    transform: return x * 100;
    show:
      in_header: true
      name_in_header: true
      in_chart: false
    name: Min.
    color: grey
  - entity: sensor.tibber_prices_quarterly
    unit: Cent
    show:
      in_header: before_now
      name_in_header: true
      header_color_threshold: true
    name: Preis
    color_threshold:
      - value: 0
        color: lime
      - value: 15
        color: green
      - value: 20
        color: Khaki
      - value: 25
        color: Gold
      - value: 30
        color: darkorange
      - value: 35
        color: orangered
      - value: 40
        color: red
    type: line
    curve: stepline
    extend_to: false
    stroke_width: 1.5
    float_precision: 2
    data_generator: |
      // Stellt sicher, dass fehlende Attribute zu leeren Arrays werden
      const today = entity.attributes.today || [];
      const tomorrow = entity.attributes.tomorrow || []; 
      const prices = today.concat(tomorrow);

      const noon = new Date();
      noon.setHours(0, 0, 0, 0); 

      const data = [];
      const interval_seconds = 900; // 15 Minuten

      for(let i = 0; i < prices.length; i++) {
        data.push([noon.getTime() + i * 1000 * interval_seconds, prices[i].total * 100])
      }
      return data;
  - entity: sensor.fredenbeck_strompreis
    attribute: max_price
    unit: Cent
    transform: return x * 100;
    show:
      in_header: true
      name_in_header: true
      in_chart: false
    name: Max.
    color: grey

  # Tibber Vorschaupreise 15 Minuten
  - platform: rest
    unique_id: Tibber Prices Quarterly
    name: Tibber Prices Quarterly
    resource: https://api.tibber.com/v1-beta/gql
    method: POST

    payload: '{ "query": "{ viewer { homes { currentSubscription { status priceInfo(resolution: QUARTER_HOURLY) { current { total level } today { total level } tomorrow { total level } } } } } }" }'
    json_attributes_path: "$.data.viewer.homes[0].currentSubscription.priceInfo" 
    json_attributes:
      - today
      - tomorrow
    value_template: "{{ value_json.data.viewer.homes[0].currentSubscription.priceInfo.current.total | float }}"
    scan_interval: 30
    headers:
      Authorization: !secret tibber_token
      Content-Type: application/json
      User-Agent: REST
    unit_of_measurement: EUR/kWh
1 Like

Does this make sense? The prices change a 0:00 from today->tomorrow and we get tomorrow’s prices by 13:00. I would not poll prices every 30 seconds! (even every 3600 seconds=hourly is overkill)

Hey, I did use code from here since years. Now I was looking to have a small bar, like in the tibber app and found this:

This is super easy and has both a bar and a graph. Tough not as customizable as a custom integration…

2 Likes

Hello i’m trying te get some nodes working in node red with the tibber query node. but i got stuck. i don’t understand where to fill in the query to get it al to work.

what do i need to do so that this works.