You can use trigger IDs and conditional execution to accomplish this. Not precisely your use case, but I have an automation that manages two ornamental lamps via two smart buttons: one lamp and one button on each nightstand to either side of the bed in our main bedroom.
A single click of either button toggles the lamp on that nightstand. A double click on either button turns off both lamps, and a long press on either button calls a script that turns off all the lights inside and outside the house, by area.
I use trigger IDs to tag the button events, and then use that ID in conditional action logic to toggle the lamps, turn them off, or call the shutdown service.
You can probably use trigger IDs for your upper and lower bounds to conditionally execute your air conditioner functions.
Here's the YAML, if you'd like to see how I use it.
alias: "QoL: Bedroom Smart Button Features"
description: |-
Short press toggle local ornamental lamp (amethyst, salt)
Long press turn off both ornamental lamps
Double press call Shutdown Everything automation
triggers:
- device_id: b11766b6ab9a7ae6f752e70514562f18
domain: zha
type: remote_button_short_press
subtype: button_1
trigger: device
id: bedroom_button_short_press_right
- device_id: b11766b6ab9a7ae6f752e70514562f18
domain: zha
type: remote_button_double_press
subtype: button_1
trigger: device
id: bedroom_button_double_press_right
- device_id: b11766b6ab9a7ae6f752e70514562f18
domain: zha
type: remote_button_long_press
subtype: button_1
trigger: device
id: bedroom_button_long_press
- device_id: 2a9e9c869c5e611e791232491169da77
domain: zha
type: remote_button_short_press
subtype: button_1
trigger: device
id: bedroom_button_short_press_left
- device_id: 2a9e9c869c5e611e791232491169da77
domain: zha
type: remote_button_double_press
subtype: button_1
trigger: device
id: bedroom_button_double_press_left
- device_id: 2a9e9c869c5e611e791232491169da77
domain: zha
type: remote_button_long_press
subtype: button_1
trigger: device
id: bedroom_button_long_press
conditions: []
actions:
- if:
- condition: or
conditions:
- condition: trigger
id:
- bedroom_button_short_press_right
then:
- action: light.toggle
metadata: {}
data: {}
target:
entity_id: light.salt_lamp_switch
- if:
- condition: or
conditions:
- condition: trigger
id:
- bedroom_button_short_press_left
then:
- action: light.toggle
metadata: {}
data: {}
target:
entity_id:
- light.amethyst_lamp
- if:
- condition: or
conditions:
- condition: trigger
id:
- bedroom_button_long_press
then:
- action: light.toggle
metadata: {}
data: {}
target:
entity_id:
- light.salt_lamp_switch
- light.amethyst_lamp
- if:
- condition: trigger
id:
- bedroom_button_double_press_right
- bedroom_button_double_press_left
then:
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.amethyst_lamp
- light.salt_lamp_switch
mode: restart
Another idea, you could use a wait_for action in the turn_on action to wait for a lower bound trigger to execute your turn_off action. I've used that for actions that turn on a light when motion is detected, and then wait for motion to clear before turning off the light.
Really, you could peel.it a bunch of different ways, but these are trucks I've used in my automations.