Combine two Automations

Can I consolidate these two automatons into one?

alias: HVAC Cool
description: Over 70
trigger:
  - platform: numeric_state
    entity_id: weather.home
    attribute: temperature
    above: 70
condition: []
action:
  - service: climate.set_hvac_mode
    data:
      hvac_mode: cool
    target:
      entity_id: climate.living_room
mode: single
alias: HVAC Heat
description: Under 55
trigger:
  - platform: numeric_state
    entity_id: weather.home
    attribute: temperature
    below: 55
condition: []
action:
  - service: climate.set_hvac_mode
    data:
      hvac_mode: heat
    target:
      entity_id: climate.living_room
mode: single

Sure. Give your triggers each an id and use a choose action based on a trigger condition.

You can employ trigger.id directly in hvac_mode.

alias: HVAC Cool
description: Over 70
trigger:
  - id: 'cool'
    platform: numeric_state
    entity_id: weather.home
    attribute: temperature
    above: 70
  - id: 'heat'
    platform: numeric_state
    entity_id: weather.home
    attribute: temperature
    below: 55
condition: []
action:
  - service: climate.set_hvac_mode
    data:
      hvac_mode: '{{ trigger.id }}'
    target:
      entity_id: climate.living_room
mode: single
2 Likes

Very elegant… Thanks!!

So, the trigger id value becomes the mode value that is passed in hvac_mode… Have I got that right?

Yes, that’s correct.

If you needed to pass more than one value, you can use trigger variables instead of id.