Tibber - Schedul prices upcoming 24 hours prices!

@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

Hi kannst du mir helfen, ich weiß nicht wo und wie ich das mit den “Authorization: !secret tibber_token” erstellen muss…

Hi @KlausB and @ingo.niehues
how did you create the utility meters for daily, monthly and yearly costs? Which entitie(s) did you use and with wich settings?
I could create the utility meters for daily, monthly and yearly consumption, but I’m struggling with the same for costs.

@Alexander-Wehner
Du fügst in deiner secrets.yaml einen Eintrag hinzu: tibber_token: “token”

Ok, hat funktioniert, danke

Jetzt fehlen mir noch ein paar Sensoren, woher beziehe ich die?

sensor.tibber_aktueller_preis_ist_tageshochstpreis

states(“sensor.tibber_strompreisentwicklung_kw”)

states(“sensor.tibber_strompreisentwicklung_short”)
7
state_attr(“sensor.tibber_strompreisentwicklung_preise”,“text_eins”)

states(“sensor.tibber_strompreisentwicklung_fazit”)

Danke

@Alexander-Wehner

Hi Alexander,
these sensors are “multiscraped”

You need Multiscrape-Integration (HACS)

And this YAML-Code Multiscrape-Sensors for price forecast

like @ingo.niehues wrote above on Jan 5
Regards
Jörg

Would it perhaps be possible for someone to put all the required code into a tibber.yaml and then simply call it from the configuration.yaml?

Hi, so this configuration is working for me now…

…and thanks to everyone for the great support!

Important:
After inserting the code, restart Home Assistant and not just reload the YAML configuration!

Code for /homeassistant/configuration.yaml:

sensor:            
  - platform: rest
    name: Tibber Prices
    unique_id: tibber_prices_level
    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: !secret tibber_token
        Content-Type: application/json
        User-Agent: REST
        unit_of_measurement: EUR/kWh

Code for /homeassistant/secrets.yaml

tibber_token: abcdefghijklmnopqrstuvwxyz_1234567890  #Enter here your Tibber Access Token

ApexCharts-Kartenkonfiguration

type: custom:apexcharts-card
experimental:
  color_threshold: true
all_series_config:
  unit: Cent/kWh
apex_config:
  grid:
    show: true
    borderColor: '#E0E0E0'
  chart:
    height: 150px
  tooltip:
    enabled: true
    followCursor: false
    x:
      show: false
    fixed:
      enabled: true
header:
  show: true
  title: Strompreis
  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
    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;
1 Like

Hi,

i have two questions about ApexChart configuration:

  1. Is it possible to display the time in the price?
    If you operate the curve by touch, the lower display is somehow inconveniently placed.

image
image

  1. Is it possible to display the values on the curve in a way that doesn’t obscure them?

image