Nest Thermostat config utilizing the new climate rewrite

Hi All,

I wanted to share my Nest config for everyone. Seems some people are having some issues with the new methods that the climate component uses, and hopefully this helps someone out or gives them some ideas.

Let me know if you have any questions, improvements, etc to this.

## Nest package - Includes base Nest thermostat configuration, away mode switch and sensor,
## Runtime for the day and month, and manual fan control.

nest:
  # Set Client ID
  client_id: !secret nest_client_id
  client_secret: !secret nest_secret
  # Define Binary Sensor Options
  binary_sensors:
    monitored_conditions:
    - 'fan'
    - 'target'
    - 'has_leaf'
    - 'online'
    - 'is_using_emergency_heat'
    - 'eta'

sensor:
  # Nest Away Mode sensor. This is optional, but useful.
  - platform: template
    sensors:
      nest_thermostat_away_mode:
        friendly_name: "Nest Thermostat Away Mode"
        value_template: >
          {% if is_state_attr('climate.nest', 'preset_mode', 'away') %}
            Away
          {% else %}
            Home
          {% endif %}
  # HVAC Run Time Today Senson. This utilizes the 
  - platform: history_stats
    name: HVAC Run Time Today
    entity_id: binary_sensor.nest_fan
    state: 'on'
    type: time
    start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
    end: '{{ now() }}'
  # HVAC Run Time This Month Sensor
  - platform: history_stats
    name: HVAC Run Time This Month
    entity_id: binary_sensor.nest_fan
    state: 'on'
    type: time
    start: '{{ now().replace(month=now().month).replace(day=1).replace(hour=0).replace(minute=0).replace(second=0) }}'
    end: '{{ now() }}'

switch:
  # Switch to control Nest Away Mode. This utilizes the new climate implimentation to set away mode.
  - platform: template
    switches:
      nest_away_mode:
        friendly_name: "Nest Away Mode"
        value_template: "{{ is_state_attr('climate.nest', 'preset_mode', 'away') }}"
        icon_template: >-
          {% if is_state_attr('climate.nest', 'preset_mode', 'away') %}
            mdi:walk
          {% else %}
            mdi:home
          {% endif %}
        turn_on:
          service: climate.set_preset_mode
          data:
            entity_id: climate.nest
            preset_mode: away
        turn_off:
          service: climate.set_preset_mode
          data:
            entity_id: climate.nest
            preset_mode: none
# This switch can also be defined using the nest.set_away_mode functionality.
#  - platform: template
#    switches:
#      nest_away_mode:
#        friendly_name: "Nest Away Mode"
#        value_template: "{{ is_state_attr('climate.nest', 'preset_mode', 'away') }}"
#        icon_template: >-
#          {% if is_state_attr('climate.nest', 'preset_mode', 'away') %}
#            mdi:walk
#          {% else %}
#            mdi:home
#          {% endif %}
#        turn_on:
#          service: nest.set_away_mode
#          data:
#            away_mode: away
#        turn_off:
#          service: nest.set_away_mode
#          data:
#            away_mode: home


fan:
  # Creates a template fan to be able to control the HVAC fan independently of heating and cooling.
  - platform: template
    fans:
      nest_fan:
        friendly_name: "Central Air Fan"
        value_template: "{{ states('binary_sensor.nest_fan') }}"
        turn_on:
          service: script.turn_on
          data:
            entity_id: script.nest_fan_on
        turn_off:
          service: script.turn_on
          data:
            entity_id: script.nest_fan_off

script:
  # HVAC fan on script for template fan
  nest_fan_on:
    alias: Nest Fan On
    sequence:
      - service: climate.set_fan_mode
        entity_id: climate.nest
        data:
          fan_mode: 'on'
  # HVAC fan on script for template fan
  nest_fan_off:
    alias: Nest Fan Off
    sequence:
      - service: climate.set_fan_mode
        entity_id: climate.nest
        data:
          fan_mode: 'auto'

3 Likes

This is cool but its not working for me … I placed in a Yaml file inside the packages folder but nothing keeps giving me errors…

Any ideas ?

What errors are you seeing?

Did you make sure to set the secrets in secrets.yaml?
Did you make sure to change the climate.nest to whatever your thermostat entity name ID is as well?

Inedententions are fine ?

What is the reason of binary_sensors ?

Thanks for sharing this! Have you found that that when you come back from “Away” mode that your HVAC mode always changes to “Heat and Cool” regardless of whatever mode it was previously in (i.e. “Heat” or “Cool”)?

The Binary sensors are created from the Nest component itself. The Fan sensor is a requirement at a minimum. The others I use for monitoring and are optional.

I have not noticed this as I leave my thermostat in heat/cool mode year round. I will play with this a bit tonight when I get home and see if I can work it out.

You may want to try the alternate method of using the nest.set_away_mode for the template switch and see if that helps out.