Automating an AC with a toggle to enable/disable the automation

Hello people. I’m trying to automate my AC to turn on if my room gets too hot. I’ve also set a boolean helper where I could tell it that I don’t want it to handle the cooling automatically. My problem is if the room is already above the temperatures I’ve set before I’ve told it to handle cooling automatically, will the triggers not work anymore since they do not cross the temperature threshold? Is there any way to fix this? Thanks in advance.

alias: Turn AC on if room is too hot
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.none_indoor_temperature
    for:
      hours: 1
      minutes: 0
      seconds: 0
    above: 29
    id: room_above_29
  - platform: numeric_state
    entity_id:
      - sensor.none_indoor_temperature
    above: 32
    id: room_at_32
    for:
      hours: 0
      minutes: 0
      seconds: 0
  - platform: numeric_state
    entity_id:
      - sensor.none_outdoor_temperature
    for:
      hours: 2
      minutes: 0
      seconds: 0
    above: 32
    id: outdoor_above_32
condition:
  - condition: device
    device_id: 58e1854de54ed1c84a0d36e415595ffe
    domain: device_tracker
    entity_id: 8b04318a81843cd1c1a28ed7f404a9b7
    type: is_home
  - condition: state
    entity_id: climate.midea_ac_147334558192167
    state: "off"
  - condition: time
    after: "06:00:00"
    before: "01:00:00"
  - condition: state
    entity_id: input_boolean.allow_cooling_automatically
    state: "on"
action:
  - service: climate.set_hvac_mode
    metadata: {}
    data:
      hvac_mode: cool
    target:
      entity_id: climate.midea_ac_147334558192167
  - service: input_boolean.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: input_boolean.ac_turned_on_automatically
  - if:
      - condition: trigger
        id:
          - room_at_30
    then:
      - parallel:
          - device_id: 58e1854de54ed1c84a0d36e415595ffe
            domain: mobile_app
            type: notify
            message: Room temperature above 30°C
            title: Turned AC on
          - device_id: 2093dfc937731c28924695ec5ace0132
            domain: mobile_app
            type: notify
            message: Room temperature above 30°C
            title: Turned AC on
    else:
      - if:
          - condition: trigger
            id:
              - outdoor_above_32
        then:
          - parallel:
              - device_id: 58e1854de54ed1c84a0d36e415595ffe
                domain: mobile_app
                type: notify
                message: Outdoor temperature above 32°C
                title: Turned AC on
              - device_id: 2093dfc937731c28924695ec5ace0132
                domain: mobile_app
                type: notify
                message: Outdoor temperature above 32°C
                title: Turned AC on
        else:
          - parallel:
              - device_id: 58e1854de54ed1c84a0d36e415595ffe
                domain: mobile_app
                type: notify
                message: Room temperature too hot
                title: Turned AC on
              - device_id: 2093dfc937731c28924695ec5ace0132
                domain: mobile_app
                type: notify
                message: Room temperature too hot
                title: Turned AC on
    alias: Notify device with what triggered
mode: single

Swap your condition and triggers?

trigger when home/nothome
condition above/below temp…

Use two Generic Thermostats, one for heating, one for cooling.

You can then disable the cooling one as required.

How often would that trigger if I for example I was home all day? Would that just keep triggering until I turned the helper on? Sorry if these are pretty basic questions, I’m trying to learn how exactly the automation feature works.

I live in a tropical country so we don’t use heaters at home. Will this work if I just use it for cooling and disable it if I need it?

Yes, absolutely. Set it up as described: you just need to supply a sensor entity for temperature and a switch entity for the cooling.

You can then have automations to turn it on or off (or to different settings) based on occupancy. Here’s mine to turn my heating off if we’re away:

- alias: Climate - adjust central heating when all away

  description: >-
    Sets central heating to away mode when house is empty.

  trigger:
    - platform: state
      entity_id: zone.home
      to: '0'
      for: "00:05:00"
    - platform: homeassistant
      event: start

  condition:
    - condition: state
      entity_id: zone.home
      state: '0'
  
  action:
    - service: climate.set_preset_mode
      entity_id: climate.central_heating
      data:
        preset_mode: away

I actually have to agree to @Troon

Just use a Generic Thermostat to turn on/off the AC and set the conditions to be at home / boolean;)

I’ve made a Generic Thermostat and I’ve been playing around with it. It seems like my AC integration already functions like one except I couldn’t set my own preset temps. So for now I’ve just adjusted the original automation based on your suggestions.

So what I’ve done is added a trigger that checks if the boolean state changed to true or if the home is occupied then added a condition to check if the current temp is above what I’ve set.