Nest Thermostat - Boost Mode Script & Automation

So I have a Nest Thermostat, which was purchased before the Works with Nest API was shutdown.
As it is still working well with Home Assistant and it looks good, i’m happy to keep it for now, however, one think that has always bugged me was the fact that there was no “Boost Mode” which would turn the heating on for a certain period of time.

So I decided to make one in Home Assistant, and after using it for most of the winter, I thought I would share it with you all.

Boost

Here is my YAML which makes up the components:

nest:
  client_id: !secret nest_id
  client_secret: !secret nest_secret

input_boolean:
  boost_active:
    name: Boost Active
    icon: mdi:fire

input_number:
  boost_target:
    name: Boost Target Temperature
    min: 16.0
    max: 25.0
    step: 0.5
    unit_of_measurement: '°C'
    mode: box

  previous_target:
    name: Previous Target Temperature
    min: 16.0
    max: 25.0
    step: 0.5
    unit_of_measurement: '°C'
    mode: box

  boost_duration:
    name: Boost Duration
    min: 20
    max: 90
    step: 5
    unit_of_measurement: 'mins'

My script (should hopefully be quite self explanatory with the comments) works as follows:

  • Takes the current Nest target temp and saves it in an input_number
  • Creates a Boost target temp based on the current temperature + 1 (this is so if the turn off automation fails, it doesn’t cook us alive) and saves it in another input_number
  • Sets the Nest thermostat to the new Boost target temp
  • Waits until the Nest thermostat and the Boost target temp match (cancels after 30 secs if this fails)
  • Turns on an input_boolean which indicates that the Boost mode is active
  • Waits for a set amount of time before the script will finish
## SCRIPTS ##
script:

  # Heating Boost Script
  heating_boost:
    alias: 'Heating Boost'
    sequence:
    # Save the current target temperature as previous target temperature
    - service: input_number.set_value
      data_template:
        entity_id: input_number.previous_target
        value: "{{ states('sensor.living_room_thermostat_target') }}"
    # Save the new target as boost target temperature
    - service: input_number.set_value
      data_template:
        entity_id: input_number.boost_target
        value: "{{ states('sensor.living_room_thermostat_temperature') | float + 1 }}"
    # Set the thermostat to match boost target
    - service: climate.set_temperature
      data_template:
        entity_id: climate.living_room
        hvac_mode: heat
        temperature: "{{ states('input_number.boost_target') }}"
    # Wait until thermostat and boost targets match - if it fails, cancel after 30 seconds
    - wait_template: "{{ (states('sensor.living_room_thermostat_target')) == (states('input_number.boost_target')) }}"
      timeout: '00:00:30'
      continue_on_timeout: 'false'
    # Turn on boost active boolean
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.boost_active
    # Wait for 30 minutes
    - delay:
        minutes: "{{ states('input_number.boost_duration') | int }}"

And then I have two automations that will complete the Boost Mode:

  1. First one is triggered by the script being turned off (either manually or by finishing) which will set the thermostat back to the previous target temp
  2. Second one is triggered by the thermostat being changed (either by schedule or manually) which will cancel the heating boost and leave the target temperature alone so as not to override the schedule or someone adjusting the thermostat themselves.
## AUTOMATIONS ##
automation:

# Reset thermostat when Heating Boost script finishes
- alias: Heating Boost Finish
  trigger:
  # When script is turned off
  - platform: state
    entity_id: script.heating_boost
    from: 'on'
    to: 'off'
  condition:
  # If the boost active boolean is on
  - condition: state
    entity_id: input_boolean.boost_active
    state: 'on'
  action:
  # Set the thermostat to previous target temp
  - service: climate.set_temperature
    data_template:
      entity_id: climate.living_room
      hvac_mode: heat
      temperature: "{{ states('input_number.previous_target') }}"
  # Wait 2 seconds
  - delay: '00:00:02'
  # Turn off Boost boolean
  - service: input_boolean.turn_off
    data:
      entity_id: input_boolean.boost_active

# Cancel Heating Boost when Nest schedule takes control or thermostat manually changed
- alias: Heating Boost Overridden
  trigger:
  # When thermostat is changed
  - platform: state
    entity_id: sensor.living_room_thermostat_target
  condition:
  # If boost active boolean is on
  - condition: state
    entity_id: input_boolean.boost_active
    state: 'on'
  action:
  # Then cancel the script
  - service: script.turn_off
    data:
      entity_id: script.heating_boost
  # Wait 2 seconds
  - delay: '00:00:02'
  # and then turn off the boost active boolean
  - service: input_boolean.turn_off
    data:
      entity_id: input_boolean.boost_active

Overall it has been pretty solid.
Added the script to Alexa and my wife happily asks her to “Turn on heating boost” while i’m out and i’ve also added a easy access button on the main page of HA.

Boost2

Hope someone finds this useful!

EDIT: Changed some of the YAML to improve the templating.

5 Likes

Precisely what i was just looking for. Thanks.

I’m happy to help if you let me know where you get stuck. My guide assumes you know Home Assistant fairly well already.
There are plenty of resources on here and YouTube to help you get started with Home Assistant :slightly_smiling_face:

Cool!! Couple of questions

  1. Sometimes my wife wants the reverse - a quick easy ‘heating depress’ button! Should that be done like the above but basically in reverse?
  2. What exactly does your heating boost button do on the main page of HA? What does it link to?

thanks! Will be implementing this!

Yes exactly, just make the boost target -1 rather than +1 that should work.

It is just an button card (used to be a custom component but now use the stock Lovelace one) which toggles the script.

Quick one, would you mind posting the YAML raw config for your lovelace button? I’m trying to do something similar and ohmygod is it hard if you’re not really au fait with lovelace. I tried creating a horizontal stack in order to give my custom button card a size and everything just disappeared. I’m used to CSS and HTML for creating buttons - this makes my brain hurt! Thank you!

I have changed it since and it is just a standard button card now, but I luckily still have my old lovelace file so this is the yaml for the original post.

    ### THERMOSTAT ###
      - type: vertical-stack
        cards:
          - type: thermostat
            entity: climate.living_room
          - type: "custom:button-card"
            entity: script.heating_boost
            layout: icon_label
            icon: mdi:fire
            show_label: true
            show_name: false
            label: >
              [[[
                if (entity.state == 'off')
                  return "Heating Boost";
                else
                  return "Cancel Boost";
              ]]]
            styles:
              card:
                - height: 82px

Should hopefully still work!

Can you please make an app for this :joy:

How do I use this with our NEST? Our new boiler came with a Learning Thermostat 3, and I hate it. I absolutely hate it.

I work from home some days, other days I’m working away - the time is irregular. The Nest bounces the temperature all over the place. It has a mind of its own… I would sooner turn all the smart stuff off and just boost it when we need heat.

I find the thing extremely irritating. I hate it. I’m close to smashing the thing with a lump hammer.

I too am trying to use it with Nest. It works well to come on at current +1.
However I would like it to continue to plus 1 until the time elapses. So far it sets +1 and when reaches that switches off regardless of how long i set the boost for.

I only put the value as +1 as a fail safe incase HA lost connection to the thermostat and didn’t turn the boost off.

You can put that value as anything you want.

Perhaps the simplest way is to change the value based on boost time (so if it’s a 30 min boost use +1, if 1hr then +3 etc, what ever works for you)

1 Like

Apologies for resurrecting an old thread but I was hoping I could get some help implementing this as we’re really frustrated not having a boost function (which we had when we had Hive in our previous property).

I’m having a few issues:

  • I am trying to do this without the Works with Nest API as this has been discontinued as stated in the original posting. Instead, I have connected Nest to HA using the instructions within HA and the integration works - I can see the temperature and control the thermostat
  • From what I can see, _target is no longer available but I could well be wrong here (I can read the value of the current temperature with sensor.hallway_temperature). As we’d only be using the boost when the heating is effectively off, then I’d be happy to hardcode the previous_target to 9. However, if I change the script from
    value: "{{ states('sensor.hallway_target') }}"
    to
    value: 9
    (or “9”), the script doesn’t seem to fire. This shows my lack of knowledge of HA and scripting but I assume this would be easy to fix.
  • Further to the above, the thermostat module on the homepage shows the target temperature so that data point must be available somehow!
  • I can successfully set the boost temperature and the thermostat updates
  • I assume with the new Nest integration the client_id and secret in the posted YAML for the components is not required?
  • I haven’t even begun to debug the automations to set the temperature back once the boost period has finished. I think this is where I’ll get unstuck without the _target being available as the automation won’t know whether the schedule has kicked in or not.

I hope the above makes some sense and any help gratefully received!

Many thanks in advance.

I think I’ve managed to solve this although I still need to test further. Here’s an outline of the changes i had to make (obviously my device names are different) to the orignally posted code

Script
value: "{{ states('sensor.living_room_thermostat_target') }}"
to
value: "{{ state_attr('climate.hallway', 'temperature') }}"

The script was also failing on the check to see if the thermostat and boost target matched. I suspect the new state_attr returns a text datatype (maybe?) so I changed
- wait_template: "{{ (states('sensor.living_room_thermostat_target')) == (states('input_number.boost_target')) }}"
to
- wait_template: "{{ (state_attr('climate.hallway', 'temperature') | float) == (states('input_number.boost_target') | float) }}"

Automation

 #When thermostat is changed
  - platform: state
    entity_id: sensor.living_room_thermostat_target

to

 #When thermostat is changed
  - platform: state
    entity_id: climate.hallway
    attribute: temperature

In the second automation (which detects a change to the thermostat and turns off boost but leaves target temperature as it is), I had to move the code to turn off the boost_active above the code to turn the script off.

Hope this helps anyone trying to implement this.

Apologies for waking this up again and showing my inexperience. I don’t know where I should be saving the YAML code for the custom entity solution?

Could someone (preferably @antlane) give me a bit of a guide on how to integrate this and get it to work with the current Works with Nest API.

It would be much appreciated. Thank you.