Putting your Nest Thermostat in/out of "eco" or Vacation mode

When we are going to be away for a few days or more I like to put my Nest into Away/Eco mode to save money. However, I’ll often forget to take it out of Eco mode before getting home so I end up walking into a house that is too cold or hot.

To fix this, I a created an input_datetime variable to put the Nest back into normal operation before we arrive home.

My configurations and automations are below:

In your configuration.yaml file add this:

sensor:
  # Used for the time trigger comparison 
  - platform: time_date
    display_options:
      - 'date_time'

input_datetime:
  # The date/time to end away mode
  nest_away_end:
    name: End Nest away mode at
    has_date: true
    has_time: true

input_text:
  # A variable to store Nest's current mode - used when we restore from away mode
  nest_mode:
    name: Heating/Cooling Mode

Putting Nest into Eco mode
The trigger I use to switch Nest into Eco mode is when my house enters an “away” mode I created (this isn’t related to Nest’s built-in away mode) - but you can change the trigger to anything. The following automation will only trigger if input_datetime.nest_away_end is set and is a future date from now() so it is safe to have this automation always fire when you leave the house.

If you wanted to get fancy, you could create a “start” input_datetime that puts Nest into Eco mode at a specific time. However, I find it simpler to set the nest_away_end input the morning of before we leave so the next time our house enters away mode the Nest automaton triggers.

- id: nest_away_start
      # Set Nest into away (eco) mode when away mode is activated and if nest_away_end is set and a future time
      alias: Boolean- Turn On Nest Away Mode
      initial_state: 'on'
      trigger:
        - platform: state
          entity_id: input_boolean.away_mode
          to: 'on'
      condition:
        - condition: template
          value_template: '{{ ( as_timestamp( now() ) | int ) < ( states.input_datetime.nest_away_end.attributes.timestamp | default(0) | int ) }}'
      action:
        # Save the current mode for Nest so we can restore it later
        - service: input_text.set_value
          data_template:
            entity_id: input_text.nest_mode
            value: '{{ states.climate.house_nest.attributes.operation_mode }}'
        # Set Nest to Eco mode
        - service: climate.set_operation_mode
          data:
            entity_id: climate.house_nest
            operation_mode: 'eco'

The automation to take Nest out of Eco mode is based on the date/time set in the input variable

- id: turn_off_nest_away_mode
  alias: Timer- Turn Off Nest Away Mode
  initial_state: 'on'
  trigger:
    - platform: template
      value_template: '{{ ( states.input_datetime.nest_away_end.attributes.timestamp | default(0) | int | timestamp_custom("%Y-%m-%d, %H:%M", True) ) == states.sensor.date__time.state }}'
  condition:
    condition: and
    conditions:
      # House is currently in eco mode
      - condition: template
        value_template: '{{ is_state_attr("climate.house_nest", "operation_mode", "eco") }}'
      # The last state was successfully saved/set
      - condition: template
        value_template: '{{ states.input_text.nest_mode.state != "unknown" }}'
  action:
    # Restore Nest to the orgional mode
    - service: climate.set_operation_mode
      data_template:
        entity_id: climate.house_nest
        operation_mode: '{{ states.input_text.nest_mode.state }}'

Make sure to rename climate.house_nest to whatever the entity name of your Nest is called.

4 Likes

4 years late, but thank you for this post! I’m new to HA and had this idea but no idea how to accomplish it, and your guide got me there.

I’m not sure if it’s just changes in HA, or Nest, or whatever, but some of your code didn’t work with my implementation. Ultimately I realized that I don’t need the “nest_mode” variable. In my system, if I set one of my tstats to Eco, it’s using a “preset mode” rather than the “hvac mode,” and so I can change the “preset mode” either to “eco” or to “off” and it will toggle the tstat in and out of Eco, but return it to whatever hvac mode (heat/cool) it was in before.

So here’s my code to put the tstat into Eco mode when I toggle my vacation mode toggle:

- id: '1657729710101'
  alias: Sun Room Vacation Start
  description: ''
  trigger:
  - platform: state
    entity_id:
    - input_boolean.vacation_mode
    to: 'on'
  condition:
  - condition: template
    value_template: '{{ ( as_timestamp( now() ) | int ) < ( states.input_datetime.nest_vacation_end.attributes.timestamp
      | default(0) | int ) }}'
  action:
  - device_id: XXXX
    domain: climate
    entity_id: climate.nest_sun_room_tstat
    type: set_preset_mode
    preset_mode: eco
  mode: single

And here’s the code to take it out of Eco mode when my return date/time is reached:

- id: '1657729735029'
  alias: Timer- Turn Off Nest Vacation Mode
  description: ''
  trigger:
  - platform: template
    value_template: '{{ ( states.input_datetime.nest_vacation_end.attributes.timestamp
      | default(0) | int | timestamp_custom("%Y-%m-%d, %H:%M", True) ) == states.sensor.date_time.state
      }}'
  condition:
  - condition: template
    value_template: '{{ is_state_attr("climate.nest_sun_room_tstat", "preset_mode",
      "eco") }}'
  action:
  - device_id: XXXX
    domain: climate
    entity_id: climate.nest_sun_room_tstat
    type: set_preset_mode
    preset_mode: none
  mode: single

Hope that helps anyone trying to do the same. But thanks, again, Will, for the starter tutorial.
jtf

1 Like

I confirm, this code made it possible to turn Eco Mode ON whenever needed! Thanks!

Hello, I was looking for an automation to put my Nest tstat into ECO mode when nobody (person.X AND person.Y AND person.Z} is home (zone). Of course when someone arrives home, the tstat should go out of the ECO mode to whatever temperature is scheduled in the NEST scheduler.
This could be useful, however I don’t understand how you enter the date and time to programmatically get out of the ECO mode (before someone arrives home).
Can you provide a screenshot of how that is shown on the dashboard?

@RogerNL , you’ll need two things: first, for the states.sensor.date_time.state part, follow the instructions at the page below to configure the date_time sensor.

For the states.input_datetime.nest_away_end part, follow the instructions below to create a datetime helper called “Next Away End” (or whatever). Then just add a card for that new input field so you can set it via the normal UI.

@will thanks a ton for this super helpful suggestion, and for others adding variants. This is just what I was searching for today and works great. (Well except the ECO mode didn’t turn off when I tried firing that event just now, and instead made my Nest go “offline” / “unavailable”, which had me pretty nervous for a few min. Maybe wait until you’re actually home before you all test this on your own gear.)

Thanks!
Will do some testing shortly.

Just found this post and you saved my sanity! Thank you!

I was trying to change the state of the thermostat to and from eco, but it wouldn’t work. Changed to calling a service and VOILA!!

Thank you again