Tibber price and thermostat control

For Tibber users.

Trigger actions (e.g. toggle HVAC) depending on temperature and electricity price. Actions are triggered intelligently when price, temperature or thermostat setting change.

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

blueprint:
  name: Tibber price and thermostat control
  description: >
    Trigger actions (e.g. toggle HVAC) depending on temperature and electricity price. Actions are triggered *intelligently* when price, temperature or thermostat setting change.


    First create a numeric helper as a thermostat control to set the temperature threshold.
  domain: automation
  input:
    tibber_price_sensor:
      name: Tibber price sensor
      selector:
        entity:
          domain: sensor
    temperature_sensor:
      name: Thermostat sensor
      description: Temperature sensor.
      selector:
        entity:
          domain: sensor
          device_class: temperature
    thermostat:
      name: Thermostat setting
      description: Numeric helper entity.
      selector:
        entity:
          domain: input_number
    price_threshold:
      name: Electricity price threshold
      description: When to consider prices low. (Tibber price level)
      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 and temperature below thermostat setting
      description: Actions to perform.
      default: []
      selector:
        action: {}
    above_actions:
      name: High prices or temperature above thermostat setting
      description: Actions to perform.
      default: []
      selector:
        action: {}
mode: restart
max_exceeded: silent
trigger:
- platform: state
  alias: price
  entity_id: !input tibber_price_sensor
  attribute: price_level
- platform: state
  alias: thermostat
  entity_id: !input thermostat
- platform: state
  alias: temperature
  entity_id: !input temperature_sensor
action:
- variables:
    levels: "{{ ['VERY_CHEAP','CHEAP','NORMAL','EXPENSIVE','VERY_EXPENSIVE'] }}"
    price: !input tibber_price_sensor
    price_threshold: !input price_threshold
    price_changed: "{{ trigger.alias == 'price' }}"
    price_level: "{{ state_attr(price,'price_level') }}"
    price_is_low: "{{ price_level in levels and levels.index(price_level) <= levels.index(price_threshold) }}"
    thermostat: !input thermostat
    thermostat_changed: "{{ trigger.alias == 'thermostat' }}"
    temperature: !input temperature_sensor
    temperature_changed: "{{ trigger.alias == 'temperature' }}"
    temperature_is_low: "{{ states(temperature)|float < states(thermostat)|float }}"
- choose:
  - conditions:
    - condition: or
      conditions: 
      - condition: and
        conditions: 
        - "{{ price_changed }}"
        - "{{ levels.index(trigger.to_state.attributes.price_level) <= levels.index(price_threshold) }}"
        - "{{ levels.index(trigger.from_state.attributes.price_level) > levels.index(price_threshold) }}"
        - "{{ temperature_is_low }}"
      - condition: and
        conditions:
        - "{{ temperature_changed }}"
        - "{{ trigger.to_state.state|float < states(thermostat)|float }}"
        - "{{ trigger.from_state.state|float >= states(thermostat)|float }}"
        - "{{ price_is_low }}"
      - condition: and
        conditions:
        - "{{ thermostat_changed }}"
        - "{{ trigger.to_state.state|float > states(temperature)|float }}"
        - "{{ trigger.from_state.state|float <= states(temperature)|float }}"
        - "{{ price_is_low }}"
    sequence: !input below_actions
  - conditions:
    - condition: or
      conditions: 
      - condition: and
        conditions: 
        - "{{ price_changed }}"
        - "{{ levels.index(trigger.to_state.attributes.price_level) > levels.index(price_threshold) }}"
        - "{{ levels.index(trigger.from_state.attributes.price_level) <= levels.index(price_threshold) }}"
        - "{{ temperature_is_low }}"
      - condition: and
        conditions:
        - "{{ temperature_changed }}"
        - "{{ trigger.to_state.state|float >= states(thermostat)|float }}"
        - "{{ trigger.from_state.state|float < states(thermostat)|float }}"
        - "{{ price_is_low }}"
      - condition: and
        conditions:
        - "{{ thermostat_changed }}"
        - "{{ trigger.to_state.state|float <= states(temperature)|float }}"
        - "{{ trigger.from_state.state|float > states(temperature) |float}}"
        - "{{ price_is_low }}"
    sequence: !input above_actions
6 Likes

See also: Tibber electricity price threshold trigger

Fixed import button.

Great idea!
Is there any way to use the built in temp sensor in an heat pump? I have a Qlima pump that is connected to HA via Tuya and I get “No matching entities found” on Temperature sensor in this blueprint.

The Entity ID of the pump is climate.hall_qlima_wms_s_sc52_ab_af

Hi @hhammarstrand,

Yes, assuming the temperature is in an attribute(like current_temperature) for that entity you could create a template sensor like:

template:
  - sensor:
      - name: "Qlima temperature"
        unit_of_measurement: "°C"
        device_class: temperature
        state: "{{ state_attr('climate.hall_qlima_wms_s_sc52_ab_af','current_temperature') }}"

Great, thank you!

Hello this is a great blueprint, but i got into a problem.
We have had very cheap prices in our area for the time beeing 1øre or -3øre etc
Today tibber managed to call 2øre very expensive and therefore all my thermostats turned off.
Is it possible to rewrite this to also use the price (a øre/kr) setpoint instead of the very_expensive, expensive etc? Thank you

Hi, im really new to home assistant as i am to migrate from homey. i have husdata as mqtt integration. i have done a numreric helper but what do that do? should the helper just be there or should i do something with it?

Hi, I would like to find the avarage day cost per kwh, and turn my heater off when the price is over avarage cost. Have anyone done this?

Thank you for this great blueprint! :blue_heart:

I just have some questions regarding how to best implement this. As for now I have two scripts that the automation triggers. One to increase the temperature and one to decrease the temperature, each adjusts the temperature by 1 degree.

But I would also like to increase the temperature even more if let’s say the price drops even more, is negative or it’s between certain times during the night when my network cost is even lower.

I get how to repeat the script to increase temperature but I can’t figure out a smart way of decreasing it back to normal levels when the price increases again.

Any input would be greatful!

Something similar. I created an automation that trigger on the Tibber electricity price sensor and compares it with the Tibber elecricity price average sensor. I set my condition to 1.15 and that starts a scene that reduces my target temperature and notifies my mobile. Here is what the automation looks like. Hope it helps.

alias: Väremreglering Sänker värmen vid högt elpris
description: Sänker värmekurvan -5 när elpriset är över dagssnittet samt över 2 kr/KWh
trigger:
  - platform: time_pattern
    minutes: "1"
condition:
  - condition: numeric_state
    entity_id: sensor.electricity_price_xxgatan_00
    attribute: max_price
    above: 2
  - condition: template
    value_template: >-
      {{ float(states('sensor.electricity_price_xxgatan_00')) > 1.15 *
      float(state_attr('sensor.electricity_price_xxgatan_00', 'avg_price'))
      }}
action:
  - service: scene.turn_on
    target:
      entity_id: scene.reduce_heat
    metadata: {}
  - service: notify.mobile_app_pixel_6
    data:
      message: Elpriset är över dagens snittpris
    enabled: true
mode: single
1 Like