Tibber - Schedul prices upcoming 24 hours prices!

Hi hklages,

I’m new to HA and not a coder. Nethertheless I’ve managed to get the tibber price chart working yesterday. :slight_smile:

But the numbers didn’t update. According to your post this must be scheduled via a “flow”. Unfortunately I don’t know how to implement it. Could you please give me a short hint?

Regards,
Jogi

Hi Jogi.

How to you get the data - via the home assistant integration or via a Node-RED node “http request”?.

I use the “http- request” node with my username/bearer and fetch the price data from the Tibber server. That “flow” is scheduled for every day at 13:15 because tibber updates the data at 13:00 about.

Do you have username/bearer for direct http / graphQL requests?

Thank you, it works. It was an error of understanding on my side…

you have to remove the option:

color: var(–etc)

Hallo. Wie kann man sich den Chart für die Preisübersicht als Bild per Telegram schicken?

Hallo
a very good work of all in this discussion. But it is varry hard for me to find the last files “rest” and “cards”
Is it possible to have the last solution for all with a link to the last example in this discussio somewhere.

Thanks, it would be great

Step by step and with trial and error I have ralised the most function. But I have two question else:

The uptime-card shows the pricelevel only to now. But I want to see the price-lecel till tomorrow. Is there a chance to see price-level for the future?

Second I want to see the next cheapest-time only as sensor. The reason is, most electric devices (washingmachine etc) must be start manuel.
I saw here a solution with the calendar-card. But it is not really explained.

did you find out how to configure the utility meters?

Hello Ingo, where exactly do I have to insert this code? Greetings Alex

{% set jahreskosten = namespace(wert=0) %}
{% set jahresverbrauch = namespace(wert=0) %}
{% set monatskosten = namespace(wert=0) %}
{% set monatsverbrauch = namespace(wert=0) %}
{% set tageskosten = namespace(wert=0) %}
{% set tagesverbrauch = namespace(wert=0) %}

{% for entry in states.sensor.tibber_monthly_cost.attributes.nodes %}
  {% if as_timestamp(entry.from) | timestamp_custom('%Y') == as_timestamp(now()) | timestamp_custom('%Y') %}
    {% set kosten_je_tag = states("input_number.tibber_messtellengebuhr_je_tag") | float(default=0) + states("input_number.tibber_netznutzungsgebuhr_je_tag") | float(default=0) %}
    {% set cost_kwh = entry.unitPrice | float(default=0) - entry.unitPriceVAT | float(default=0) %}
    {% set consumption_cost = cost_kwh | float(default=0) * entry.consumption | float(default=0) %}
    {% set monatstage = (as_datetime(as_timestamp(entry.from)).replace(month=as_datetime(as_timestamp(entry.from)).month % 12 + 1, day=1) - timedelta(days=1)).day | int(default=0) %}
    {% set month_cost = (consumption_cost | float(default=0) + (states("input_number.tibber_grundpreis_je_monat") | float(default=0) ) + (kosten_je_tag | float(default=0) * monatstage | float(default=0))) * (states("input_number.tibber_mehrwertsteuersatz") | float(default=0) + 1) %}
    {% set jahreskosten.wert = jahreskosten.wert | float(default=0) + month_cost | float(default=0) %}
    {% set jahresverbrauch.wert = jahresverbrauch.wert | float(default=0) + entry.consumption | float(default=0) %}
  {% endif %}
{% endfor %}

{% for entry in states.sensor.tibber_daily_cost.attributes.nodes %}
  {% if as_timestamp(entry.from) | timestamp_custom('%Y-%m') == as_timestamp(now()) | timestamp_custom('%Y-%m') %}
    {% set kosten_je_tag = states("input_number.tibber_messtellengebuhr_je_tag") | float(default=0) + states("input_number.tibber_netznutzungsgebuhr_je_tag") | float(default=0) %}
    {% set cost_kwh = entry.unitPrice | float(default=0) - entry.unitPriceVAT | float(default=0) %}
    {% set consumption_cost = cost_kwh | float(default=0) * entry.consumption | float(default=0) %}
    {% set monatstage = (now().replace(month=now().month % 12 + 1, day=1) - timedelta(days=1)).day | int(default=0) %}
    {% set day_cost = (consumption_cost | float(default=0) + (states("input_number.tibber_grundpreis_je_monat") | float(default=0) / monatstage | float(default=0)) + kosten_je_tag | float(default=0)) * (states("input_number.tibber_mehrwertsteuersatz") | float(default=0) + 1) %}
    {% set monatskosten.wert = monatskosten.wert | float(default=0) + day_cost | float(default=0) %}
    {% set monatsverbrauch.wert = monatsverbrauch.wert | float(default=0) + entry.consumption | float(default=0) %}
  {% endif %}
{% endfor %}

{% for entry in states.sensor.tibber_hourly_cost.attributes.nodes %}
  {% if as_timestamp(entry.from) | timestamp_custom('%Y-%m-%d') == as_timestamp(now()) | timestamp_custom('%Y-%m-%d') %}
    {% set kosten_je_tag = states("input_number.tibber_messtellengebuhr_je_tag") | float(default=0) + states("input_number.tibber_netznutzungsgebuhr_je_tag") | float(default=0) %}
    {% set cost_kwh = entry.unitPrice | float(default=0) - entry.unitPriceVAT | float(default=0) %}
    {% set consumption_cost = cost_kwh| float(default=0) * entry.consumption | float(default=0) %}
    {% set monatstage = (now().replace(month=now().month % 12 + 1, day=1) - timedelta(days=1)).day | int(default=0) %}
    {% set hour_cost = (consumption_cost| float(default=0) + ((states("input_number.tibber_grundpreis_je_monat")| float(default=0) / monatstage| float(default=0)) + kosten_je_tag| float(default=0)) / 24) * (states("input_number.tibber_mehrwertsteuersatz")| float(default=0) + 1) %}
    {% set tageskosten.wert = tageskosten.wert + hour_cost| float(default=0) %}
    {% set tagesverbrauch.wert = tagesverbrauch.wert + entry.consumption| float(default=0) %}
  {% endif %}
{% endfor %}

{{ (jahreskosten.wert + monatskosten.wert + tageskosten.wert) | round(2) }}```

You can create a helper template Sensor via UI. You will find a Box where you can Paste that code

Hi,

can someone please give me a tip…

how can I

{% set battlevel_ist = float(states('sensor.delta_2_max_battery_level' )) | default(0) %}

set to a default value if

sensor.delta_2_max_battery_level

is not available/valid?

Thanks Ingo
BG Alex

Hi Ingo
I have another problem with your code.

I have 2 errors in my log

HA scraper # tibber_strompreisentwicklung_website_text # tibber_price_preview_text_summary # Unable to extract data from HTML

I have commented out this code

#          - name: tibber_price_preview_text_background_4
#            select: "#app-root > div.jsx-850a60188453b536.app-container >

The other error is

Platform rest does not generate unique IDs. ID tibber_price_level already exists - ignoring sensor.tibber_price_level
Platform rest does not generate unique IDs. ID tibber_price_level_german already exists - ignoring sensor.tibber_price_level_deutsch

I have your code in my sensor.yaml

# Tibber Preislevel Deutsch
- 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

But without

tibber sensors.txt
 "tibber sensors.txt" wird angezeigt.

Please help, what is my error.

Scraper error is normal since the format is changing every day on tibbers site.

The id errors occur, regarding a not unique config. Double check if you have those configured a second time, search for those entries in configuration.yaml and every config file you linked.

Thanks for the quick answer.

I needed a long time, than I see, that the entity-id was “price_level_german”. In the card is used “price_level_deutsch”.

So I changed the entity-id in “_deutsch”. After two restarts the error is gone.

Thank you so mutch.

@ingo.niehues

Hello Ingo, have you switched your Senec Cloud power card to Tibber?
Greetings Alex

Thanks for all your code! This gives me a great starting point to make my automation. I was wondering, in constructing the message payload with price and time, you construct the time for every array record. But they all already have a time, only it’s utc + [timezone deviation]. Is there a reason for not using the provided time? Does HA not handle that notation well in converting it to local time? Does JS not have the ability to make it an absolute local time (or whatever the term is for 12:00:00 instead of 10:00:00+02:00:00)?

Hey guys,
I have a question.
I got to set up the sensor and everything work.
For some automations i want to get all values on an own sensor.

With the Templates i got to ask for my values {{ states.sensor.tibber_prices_2.attributes.today[0] }}
My Problem ist, that i got this as an answer: {‘total’: 0.2931}

How do i seperate the number from the rest?

@ingo.niehues Hello Ingo, first of all thank you so much for your great cards! Everything works perfect except for the multiscrape card which shows some fields with none. Could you maybe have a look ?

Oh my god you guys are awesome…
But I’m still overloaded with information. I came accross this post because I’m searching for a solution to display the next cheap price slots on my e ink open paper price tags.

So I can place those tags next to the dishwasher or washingmaschine.