Tibber - Schedul prices upcoming 24 hours prices!

I tried it and addad this

  • platform: rest to the yaml configuration

Then I have changed the tibber token and restarted HA.

Afterwards I used the apex card which then complains that the sensor is missing
image

What is wrong ?

SOLVED:
thanks to Ingo’s reply the solution was easy.
I put the previously mentioned -platform: rest code
under “sensor:”

and now the sensor appears with all the data and the apex chart is happy too.

image

2 Likes

Same issue here and your demo delivered the answer that the -platform: rest has to be in the configuration.yaml below
sensor:

THANKS A LOT !

1 Like

thanks @ingo.niehues now it works. great job, I like your dashboard

1 Like

Hi Donny, that sounds great right. Would you share the code? That would be really great.
Yours sincerely, Matthias

Can you please post the code for the uptime card? I can’t get it to work and I can’t find any real help in the documentation to set it up successfully. Many thanks in advance!

Sure. Here is the yaml-code for the Uptime-Card.

type: custom:uptime-card
entity: sensor.tibber_price_level_deutsch
ok:
  - günstig
  - sehr günstig
ko:
  - teuer
  - sehr teuer
  - normal
ok_icon: mdi:thumb-up
ko_icon: mdi:thumb-down
none_icon: mdi:thumbs-up-down
color:
  ok: green
  ko: red
  none: grey
hours_to_show: 24
title_adaptive_color: false
status_adaptive_color: true
icon_adaptive_color: true
tooltip_adaptive_color: true
bar:
  height: 30
  round: 5
  amount: 24
show:
  header: true
  title: true
  icon: true
  status: true
  timeline: true
  footer: true
  average: false
tooltip:
  hour24: true
card_mod:
  style: |
    ha-card {
      padding: 0px !important;
      border: none;
      box-shadow: none;
    }         

For that i have setup a sensor that has the price-level in german language:

sensor:
  - platform: rest
    unique_id: tibber_price_level_german
    name: Tibber Price Level Deutsch
    resource: https://api.tibber.com/v1-beta/gql
    method: POST
    payload: '{ "query": "{ viewer { homes { currentSubscription { status priceInfo { current { level } today { level } tomorrow { level } } } } } }" }'
    json_attributes_path: "$.data.viewer.homes[0].currentSubscription.priceInfo"
    json_attributes:
      - today
      - tomorrow
    value_template: >
      {% if value_json.data.viewer.homes[0].currentSubscription.priceInfo.current.level == "NORMAL" %}
        normal
      {% elif value_json.data.viewer.homes[0].currentSubscription.priceInfo.current.level == "CHEAP" %}
        günstig
      {% elif value_json.data.viewer.homes[0].currentSubscription.priceInfo.current.level == "VERY_CHEAP" %}
        sehr günstig  
      {% elif value_json.data.viewer.homes[0].currentSubscription.priceInfo.current.level == "EXPENSIVE" %}
        teuer
      {% elif value_json.data.viewer.homes[0].currentSubscription.priceInfo.current.level == "VERY_EXPENSIVE" %}
        sehr teuer
      {% endif %}  
    scan_interval: 30
    headers:
      Authorization: !secret tibber_token
      Content-Type: application/json
      User-Agent: REST
2 Likes

Hello,

I’m still fairly new to Home Assistant and will soon be switching to Tibber. That’s why I was looking for a dashboard to display the prices in Home Assistant. I found this one very interesting and tried to add it. I’m currently having difficulties creating the utility meters. Could you tell me which sensor I need to use for consumption and costs? I would also like to use the solar_restproduktion_heute sensor as well.
@ingo.niehues could you share your code?

greeting

Hi,

I’ve been working my way through your setup, but I’ve got stuck on creating daily sensors for tibber cost and consumption. My integration only provides monthly totals. How would I create a sensor for daily consumption logging for the apex chart?

Thanks!

@ingo.niehues
I have a question about your card with the cost display.

image

In the file YAML-Code for Tibber-Card.txt I find the following reference to sensors:

...
series:
     - entity: sensor.tibber_kosten_daily
       color: var(--google-red)
       name: Kosten
     - entity: sensor.tibber_kosten_je_kwh_daily
       color: var(--google-red)
       name: Kosten je kWh
       float_precision: 1
       show:
           in_chart: false
...

Where exactly do the sensors come from? I can’t find sensor names in German either in the Tibber API or in the Tibber integration.

Background: I don’t have a Tibber Pulse. But my inverter supplies the necessary data. I just need to know how you built the sensors, then I can customise the card to my environment.

This is my exact question. Very much appreciate you work @ingo.niehues, but seems we are both struggling to get past this point. Though I do have a timber pulse in my system…

Got a problem:

image

Looks alright in both Yaml files.
Stole the code from typxxiwolf

Any tip you guys can give me?

Do you find the sensor ‘sensor.tibber_prices_haze’ in developer toold > states ?
Didi you restart after you created the rest-sensor?

Yes, the sensor can be seen in developer tool > states …and it has values that seems correct. Yes I did restart HA.
So the card is wrong or?

---- configuration.yaml ------------
  - platform: rest
    name: Tibber Prices
    unique_id: tibber_prices_haze
    resource: https://api.tibber.com/v1-beta/gql
    method: POST
    payload: '{ "query": "{ viewer { homes { currentSubscription { status priceInfo { current { total } today { total } tomorrow { total } } } } } }" }'
    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: <tibber code, not shown here>
      Content-Type: application/json
      User-Agent: REST
    unit_of_measurement: SKR/kWh

----- my card ------

type: custom:apexcharts-card
experimental:
  color_threshold: true
all_series_config:
  unit: Cent/kWh
apex_config:
  grid:
    show: true
    borderColor: '#E0E0E0'
  chart:
    height: 250px
  tooltip:
    enabled: true
    followCursor: false
    x:
      show: false
    fixed:
      enabled: true
header:
  show: true
  title: Electricity
  show_states: true
  colorize_states: true
  standard_format: false
graph_span: 48h
now:
  show: true
  color: 9E9E9E
span:
  start: day
series:
  - entity: sensor.tibber_prices_haze
    show:
      in_header: before_now
      name_in_header: false
    color_threshold:
      - value: 0
        color: 4DD0E1
      - value: 10
        color: 26A69A
      - value: 15
        color: 4CAF50
      - value: 20
        color: 7CB342
      - value: 25
        color: FBC02D
      - value: 30
        color: EF6C00
      - value: 40
        color: B71C1C
    type: line
    curve: stepline
    extend_to: false
    stroke_width: 4
    float_precision: 2
    data_generator: |
      const noon = new Date()
      noon.setHours(0, 0, 0, 0)
      const prices = entity.attributes.today.concat(entity.attributes.tomorrow);
      const data = [];
      for(let i = 0; i < prices.length; i++) {
        data.push([noon.getTime() + i * 1000 * 3600, prices[i].total * 100])
      }
      return data;

Ohhh this is strange:

sensor.tibber_prices_haze did not take

Anyway it works
image

image

image

Have the threshold set manually but I would love to it colored by the data_generator…so it would color the cheapast 4h of the day as green.
This is boring:
image

Anyway, thanks for all your help!

First of all, thank you for presenting your solution and for your support @ingo.niehues
I have also tried to install this in my system, but I can’t really get to grips with it. I’m also quite new to Home Assistant and sometimes don’t know which code has to go in which file.
I assume that everything has to be in the config. Right?
Unfortunately, I don’t see any of the graphics. When I look in the homeassistent.log, I find this error:
ValueError: could not convert string to float: '{“1707811200”:0.00025509999999999997,"…

So the retrieval works. However, the system doesn’t seem to be able to translate the epoch and the price into values.
What am I doing wrong?

Where do i have to include this?

Hi Ingo,

do you know how to get the yellow bars in the uptime-card?
I want to have the „normal“ in yellow and not in red. Teuer etc in red and günstig in green, of course.

Regards

use the color_threshold to select any color you like…if you remove the color threshold it all becomes orange I guess. I have changed it a little bit:

    color_threshold:
      - value: 50
        color: green
      - value: 80
        color: yellow
      - value: 120
        color: orange
      - value: 140
        color: red

Does anyone now how I can use the values from the data_generator to make to make some kind of coloring?
What I want to to do is to color by the cheapest hours not use the static values in the color_threshold … this would be nice:
color_threshold:
- value: myVariable1
color: green