Catching high/low nest temperature set as an automation trigger

Kids at home refuse to turn on / off the nest thermostats properly. Because it’s fun they turn the wheel to one side’s maximum. I can’t blame them as that’s probably what I’d do if I were their age :slight_smile: However I’d like to catch it (for obvious reasons), wait a minute or so and then set it to a pre-determined reasonable value.

Home Assistant knows the target temperature per nest device and it shows it in the device’s card, I couldn’t access it from any automation trigger though. The rest of the automation is obvious to code.

Any pointers on how to access changes in target temperature in a nest thermostat to be used as a trigger in an automation?

According to the documentation for the Climate integration, the temperature attribute represents the target temperature if the climate entity is not in heat_cool mode (i.e. the automatic mode-switching). If it is in heat_cool mode, then you use the target_temp_high and target_temp_low attributes.

Example using a Numeric State Trigger

trigger:
  - platform: numeric_state
    entity_id: climate.your_thermostat
    attribute: temperature
    above: 28
    below: 16
    for:
      seconds: 3
1 Like

Thanks so much. It’s also in the visual editor - if I choose numeric state as trigger and choose a nest thermostat as an entity it gives exactly what you described above. That’s the starting point I needed, let me work it out and I’ll post the working copy here.

Worked well, here’s the resulting script with a few added tweaks:

alias: Catch high or low AC set
description: ""
trigger:
  - platform: numeric_state
    entity_id: climate.nest1
    for:
      hours: 0
      minutes: 0
      seconds: 3
    attribute: temperature
    below: 23
  - platform: numeric_state
    entity_id: climate.nest1
    for:
      hours: 0
      minutes: 0
      seconds: 3
    attribute: temperature
    above: 28
  - platform: numeric_state
    entity_id: climate.nest2
    for:
      hours: 0
      minutes: 0
      seconds: 3
    attribute: temperature
    below: 23
  - platform: numeric_state
    entity_id: climate.nest2
    for:
      hours: 0
      minutes: 0
      seconds: 3
    attribute: temperature
    above: 28
condition: []
action:
  - variables:
      v_new_temperature: >
        {% if trigger.below is not none %}
          {{ trigger.below }}
        {% else %}
          {{ trigger.above }}
        {% endif %}
      v_above_below: >
        {% if trigger.below is not none %}
          below
        {% else %}
          above
        {% endif %}
      v_high_low: >
        {% if trigger.below is not none %}
          Low
        {% else %}
          High
        {% endif %}
  - device_id: XXX
    domain: mobile_app
    type: notify
    message: >-
      {{ state_attr(trigger.to_state.entity_id, 'friendly_name') }} set
      to {{ v_above_below }} {{ v_new_temperature }} C, blocking and limiting to {{ v_new_temperature }} in 30 seconds
    title: {{ v_high_low }} AC value set
    enabled: true
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
  - service: climate.set_temperature
    data:
      temperature: "{{ v_new_temperature }}"
    target:
      entity_id: "{{ trigger.to_state.entity_id }}"
mode: parallel
max: 10

You can consolidate the four Numeric State Triggers.

  - platform: numeric_state
    entity_id:
      - climate.nest1
      - climate.nest2
    for:
      seconds: 3
    attribute: temperature
    below: 23
    above: 28
1 Like

Thanks so much, I combined the entity_ids and this made it super neat.

There is one thing though, homeassistant doesn’t allow below and above temperature attributes together saying something like “a temperate cannot be above X and below Y at the same time”. I thought this would be an “or” but apparently the code assumes it’s an “and”.