Onne sentence trigger with variables (list possible values)?

I want to create an automation that will allow change the temperature on my thermostat. This is the sentence trigger that I have so far.

Turn {UpDown} the {HeatAC} by {Degrees} degrees

I want to make it so that Up or Down are the only two possible options for the first variable, Heat or AC are the only two possible options for the second variable and that the third variable will be a number.

Is that possible through the UI? I’ve seen documentation that I think I could use to add the option lists to the config.yaml but I’d MUCH RATHER NOT do that if I can avoid it. And I still haven’t found a way to deal with the third variable.

When I go to use it, the template will be expecting an integer.

How are you defining “up” and “down”?

In some places it’s common for people to say “Turn up the AC” and mean “set a lower temperature”, but it can also mean the opposite… which is one of the reasons this type of relative adjustment isn’t included in the built-in intent sentences.

The HassClimateSetTemperature intent already covers sentences like, “Turn up/down the temperature to 70 degrees”.

You can use Template conditions to check their value in the trigger variable.

...
conditions:
  - condition: template
    value_template: |
      {{ trigger.slots.UpDown|lower in ['up', 'down'] and
      trigger.slots.HeatAC|lower in ['heat', 'ac', 'a c', 'a see'] }}
...

Most of the time the trigger slot should return a numeral, but you can use a custom macro like this one to insure that you get an integer instead of a number name.

All that being said, I think it would be easier and more reliable to do it as a custom sentence and intent rather than a sentence-triggered automation.

I have no idea what that means. All I’ve seen or used for similar involves using sentence triggers.

I’ll see what I can find.

As far as the quest of what up/down means, I go change the temperature number up or down.

My thermostat is the type that allows me to set it to keep the temperature within a range. If the temperature drops below the range, the HEAT comes on. If the temperature rises above the range, the AC comes on.

If my sentence is “turn up the AC by 2 degrees” the AC temp will increase by 2 degrees. I understand how to use the template to make the adjustment once I know the contents of each variable.

It means doing it in configuration.yaml… which you said you don’t want to do. Forum member jackjourneyman has a nice tutorial on github.

Really, if you’re going to have those strict requirements and you want to use an automation, you might want to try multiple triggers with just the “Degrees” slot. The following is untested, because I don’t have a climate entity that use heat/cool mode:

triggers:
  - command:
      - "(turn up|raise) the heat [by] {Degrees} degree[s]"
    trigger: conversation
    variables:
      direction: 1
      action: heat
  - command:
      - "(turn up|raise) the (a c|a see|air conditioning) [by] {Degrees} degree[s]"
    trigger: conversation
    variables:
      direction: 1
      action: cool
  - command:
      - "(turn down|lower) the heat [by] {Degrees} degree[s]"
    trigger: conversation
    variables:
      direction: -1
      action: heat
  - command:
      - "(turn down|lower) the (a c|a see|air conditioning) [by] {Degrees} degree[s]"
    trigger: conversation
    variables:
      direction: -1
      action: cool
actions:
  - variables:
      target: "{{ area_entities(area_id(trigger.device_id))| select('match', 'climate') | first }}"
      adjustment: "{{ direction * trigger.slots.Degrees|int(0) }}"
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ action == 'heat' }}"
        sequence:
          - action: climate.set_temperature
            data:
              target_temp_low: "{{ state_attr(target, 'target_temp_low')  +  adjustment }}"
            target: 
              entity_id: "{{ target }}"
      - conditions:
          - condition: template
            value_template: "{{ action == 'cool' }}"
        sequence:
          - action: climate.set_temperature
            data:
              target_temp_high: "{{ state_attr(target, 'target_temp_high')  +  adjustment }}"
            target: 
              entity_id: "{{ target }}"

Ok thanks. I was just hoping to do it via the GUI – I know they’ve been making lots of headway in the area of making it possible to do things via the GUI that previously required using yaml.

I’ll tinker with this.

I’m getting closer – thanks for the assistance so far.

I used ‘Assist’ and typed in an instruction “turn down the heat by 3 degrees”. It’s throwing an error that appears to be related to the 3 being a string.

Here are screenshots of the travel data.


Use the int() filter… trigger.slots.Degrees | int(0)

That’s what I’m using.

variables:
  target: climate.t6_pro_z_wave_programmable_thermostat
  adjustment:
    adjustment: "{{ direction * trigger.slots.Degrees|int(0) }}"

It looks like a copy/paste error doubled adjustment, so instead of the integer 3 it’s getting a dictionary: adjustment: 3.

variables:
  target: climate.t6_pro_z_wave_programmable_thermostat
  adjustment: "{{ direction * trigger.slots.Degrees|int(0) }}"

Thanks that resolved that error. Now I’m getting a different error and I have no idea what it means or where to find info on what it means.

Error: some but not all values in the same group of inclusion ‘temperature’ @ data[]

This is a screenshot of the trace info.

That’s down to my unfamiliarity with heat/cool… it looks like you always need to supply both target_temp_low and target_temp_high.

...
actions:
  - variables:
      target: climate.t6_pro_z_wave_programmable_thermostat
      adjustment: "{{ direction * trigger.slots.Degrees|int(0) }}"
      high: "{{ state_attr(target, 'target_temp_high') + (adjustment if action == 'cool' else 0) }}"
      low: "{{ state_attr(target, 'target_temp_low') + (adjustment if action == 'heat' else 0) }}"
  - action: climate.set_temperature
    data:
      target_temp_high: "{{ high }}"
      target_temp_low: "{{ low }}"
    target: 
      entity_id: "{{ target }}"

Thanks for all the assistance.

For anyone interested, here’s the final version in its entirety.

alias: _Set thermostat temperature
description: ""
triggers:
  - command:
      - turn up the heat [by] {Degrees} degrees
      - turn up the heat [by] {Degrees} degree
      - Raise the heat [by] {Degrees} degrees
      - Raise the heat [by] {Degrees} degree
    trigger: conversation
    variables:
      direction: 1
      action: heat
  - command:
      - turn up the (AC|a c|a see|air conditioning) [by] {Degrees} degrees
      - turn up the (AC|a c|a see|air conditioning) [by] {Degrees} degree
      - Raise the (AC|a c|a see|air conditioning) [by] {Degrees} degrees
      - Raise the (AC|a c|a see|air conditioning) [by] {Degrees} degree
    trigger: conversation
    variables:
      direction: 1
      action: cool
  - command:
      - turn down the heat [by] {Degrees} degrees
      - turn down the heat [by] {Degrees} degree
      - Lower the heat [by] {Degrees} degrees
      - Lower the heat [by] {Degrees} degree
    trigger: conversation
    variables:
      direction: -1
      action: heat
  - command:
      - turn down the (AC|a c|a see|air conditioning) [by] {Degrees} degrees
      - turn down the (AC|a c|a see|air conditioning) [by] {Degrees} degree
      - Lower the (AC|a c|a see|air conditioning) [by] {Degrees} degrees
      - Lower the (AC|a c|a see|air conditioning) [by] {Degrees} degree
    trigger: conversation
    variables:
      direction: -1
      action: cool
conditions: []
actions:
  - variables:
      target: climate.t6_pro_z_wave_programmable_thermostat
      adjustment: "{{ direction * trigger.slots.Degrees|int(0) }}"
      high: >-
        {{ state_attr(target, 'target_temp_high') + (adjustment if action ==
        'cool' else 0) }}
      low: >-
        {{ state_attr(target, 'target_temp_low') + (adjustment if action ==
        'heat' else 0) }}
  - action: climate.set_temperature
    data:
      target_temp_high: "{{ high }}"
      target_temp_low: "{{ low }}"
    target:
      entity_id: "{{ target }}"
    enabled: true
mode: single