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.

blueprint:
  name: Tibber price control
  description: Perform actions when electricity prices go above or below a selected threshold.
  domain: automation
  input:
    tibber_price_sensor:
      name: Tibber price sensor
      selector:
        entity:
          domain: sensor
    threshold:
      name: Threshold
      description: When to consider prices low.
      default: "CHEAP"
      selector:
        select:
          options:
            - label: Very expensive
              value: VERY_EXPENSIVE
            - label: Expensive
              value: EXPENSIVE
            - label: Normal
              value: NORMAL
            - label: Cheap
              value: CHEAP
            - label: Very cheap
              value: VERY_CHEAP
    below_actions:
      name: Low prices
      description: Actions to perform when prices become low.
      default: []
      selector:
        action: {}
    above_actions:
      name: High prices
      description: Actions to perform when prices become high.
      default: []
      selector:
        action: {}
mode: restart
max_exceeded: silent
trigger:
  - platform: state
    entity_id: !input tibber_price_sensor
    attribute: price_level
action:
- variables:
    levels: "{{ ['VERY_CHEAP','CHEAP','NORMAL','EXPENSIVE','VERY_EXPENSIVE'] }}"
    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
2 Likes

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: ""
use_blueprint:
  path: komakino/tibber-electricity-price-threshold-trigger.yaml
  input:
    tibber_price_sensor: sensor.electricity_price_house
    below_actions:
      - service: notify.tibber
        data:
          message: Cheap!
    above_actions:
      - service: notify.tibber
        data:
          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”.