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
5 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