Tibber electricity price threshold trigger

For Tibber users.

Perform actions when Tibber electricity prices go above or below a selected threshold.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

  name: Tibber price control
  description: Perform actions when electricity prices go above or below a selected threshold.
  domain: automation
      name: Tibber price sensor
          domain: sensor
      name: Threshold
      description: When to consider prices low.
      default: "CHEAP"
            - label: Very expensive
              value: VERY_EXPENSIVE
            - label: Expensive
              value: EXPENSIVE
            - label: Normal
              value: NORMAL
            - label: Cheap
              value: CHEAP
            - label: Very cheap
              value: VERY_CHEAP
      name: Low prices
      description: Actions to perform when prices become low.
      default: []
        action: {}
      name: High prices
      description: Actions to perform when prices become high.
      default: []
        action: {}
mode: restart
max_exceeded: silent
  - platform: state
    entity_id: !input tibber_price_sensor
    attribute: price_level
- variables:
    old_level: "{{ trigger.from_state.attributes.price_level }}"
    new_level: "{{ trigger.to_state.attributes.price_level }}"
    threshold: !input threshold
- choose:
  - conditions:
    - "{{ levels.index(new_level) <=  levels.index(threshold) and levels.index(old_level) >  levels.index(threshold)}}"
    sequence: !input below_actions
  - conditions:
    - "{{ levels.index(old_level) <=  levels.index(threshold) and levels.index(new_level) >  levels.index(threshold)}}"
    sequence: !input above_actions

See also: Tibber price and thermostat control

Hey nice work!!

I think you did your import button wrong because it’s not working to import. I think you need to add the link to this post in the URL for the button not to the github gist.

Thanks! Button fixed.

1 Like

This blueprint is just what I’m looking for if only I can get it to work!

The thing is that I can’t seem to get my automations working. My tibber price sensor is sensor.electricity_price_house. (wich is my senor that hold all the attributes and check the actual price).`

What am I missing?

Hi @magpet!

In what way does it not work?

Test with a simple configuration like:

alias: Tibber price control
description: ""
  path: komakino/tibber-electricity-price-threshold-trigger.yaml
    tibber_price_sensor: sensor.electricity_price_house
      - service: notify.tibber
          message: Cheap!
      - service: notify.tibber
          message: Expensive!

And then go to Developer Tools > States, find your tibber sensor and manually change the state attribute(price_level) to VERY_CHEAP and then to VERY_EXPENSIVE. Do the notifications not trigger? (The attribute will revert back to the actual value in a couple of seconds.)

This is excactly what im lookibg for ! Thanks! Unfortunately I can’t get it to work . I am no expert, but I was able to find out , it looks like it passes right by the action part, even though it’s triggered? I will try to change the threshold and a few other things to see if I can get it working . I would be very glad if you could have a look at the screenshot, maybe it’s a very obvious mistake?

Hej! Snyggt jobb!

Vad är det som styr vad som är billigt och dyrt?
Alltså vad kostar elen när man har på “normal” är det ett uträknat genomsnitt per vecka typ? Mvh

Thanks, exactly what I’m looking for. Though I get an error as shown below - any ideas?

Edit: OK, sorry about this - as a newbie I triggered the automation from the UI which apparently doesn’t attach the trigger… Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘to_state’ - Configuration - Home Assistant Community (home-assistant.io)

I am new to Home Assistant and I am trying to get my water heater to turn off when the price is normal and high, based on Tibber price.
The attributes used here are based on a 3 day average, which can mean a day can go by without hot water if the average price that day is “expensive” after 3 days with cheap prices.
So my question is, can’t this instead use PriceRatingLevel instead? That way, if I read Tibber developer correctly, the price will vary between low, normal and high every day.

Or am I misunderstanding? As I said, I am very new to HA and “programming”.

Hej Emil. Det styrs av Tibbers “PriceLevel”.

Hi, PriceRatingLevel is not available in the current implementation of the Tibber price sensor in Home Assistant AFAIK.

Hello and thank you for a nice blueprint. I just have probleme with it and it’s because it takes the prices for the last three days and uses that as a reference. So the problem is that when I want the water heatup at least once a day it won’t trigger if the prices got very high the last days. I therfore try to use a template for calculate the “level” last 24 hours. But the value from the template is not a attribute but a “state” How can I modiy you blueprint som it reads states and not attributes or how can I remodel the template so it changes the “attribute” and not the state. I would be very thankfull for you help.

    - name: Electricity price - Price level (1-day)
      icon: mdi:currency-usd
      state: >-
        {% set price_cur = states('sensor.electricity_price') | float(0) %}
        {% set price_avg = state_attr('sensor.electricity_price', 'avg_price') | float(0) %}
        {% if price_cur == 0 or price_avg == 0 %}
        {% else %}
          {% set price_ratio = (price_cur / price_avg) %}
          {% if price_ratio >= 1.4 %}
          {% elif price_ratio >= 1.15 %}
          {% elif price_ratio <= 0.6 %}
          {% elif price_ratio <= 0.9 %}
          {% else %}
          {% endif %}
        {% endif %}

Sorry @Christer84 but what is that screenshot? Is a visual representation of the automation?

Hi, I’m a beginner trying to figure out how this works as I want to control my water heater and boiler using Tibber’s price levels. I wonder if anyone has the answer why I also get the error:

Error: UndefinedError: ‘dict object’ has no attribute ‘from_state’

when I use the above blueprint in automation.

Would be very grateful if I could get this started. hope for your answers

Hi Niclas. As mentioned above, you can’t manually trigger this automation from the UI. If you want to trigger it manually you can play with the price level attribute in the Tibber entity.