Automation not launching

I am testing a simple automation that should detect if one AC unit has been in cooling mode for more that 2 minutes before 9:45 PM. If so, I want the automation to turn off the AC unit. Here is the automation:

alias: Turn AC Off If Running Before 9:45 PM
description: Before 9:45 PM
trigger:
  - platform: state
    entity_id: climate.family_room
    to: cool
    attribute: hvac_modes
    for: '00:02:00'
    id: '1'
condition:
  - condition: time
    before: '21:45:00'
action:
  - service: climate.turn_off
    data: {}
    target:
      entity_id:
        - climate.family_room
mode: single

Any ideas why it is not running at all?

trigger:
  - platform: state
    entity_id: climate.family_room
    to: cool
    for: '00:02:00'

Try removing the attribute of hvac_mode. The hvac mode just displays the available mode that your climate entity has - thus it does not change. You want state change trigger.

See your climate entity in Developer Tools like below. Notice that when it is in cool mode, it is reflected in the state of the entity-

1 Like

If you want to turn it off if it is in the process of actually cooling (i.e. “running”) then you will need to change the trigger.

trigger:
  - platform: state
    entity_id: climate.family_room
    to: 'cooling'
    attribute: hvac_action
    for: '00:02:00'

Your current trigger turns it off if it is simply in cool mode but not necessarily cooling.

Thank you. That worked!

If you want to detect if the AC is switched ON from OFF (cool, dry, auto, heat_cool, fan_only), you can use this-

trigger:
  - platform: template
    value_template: >-
      {{ states('climate.family_room') != 'off' }}
1 Like