Scenario: I have an automation called John’s AC. John’s AC has four separate triggers. Max, minimum lower temperature, lower temperature, upper temperature, and max upper temperature. If the room temperature is below max lower temperature or lower temperature and it warms up to either of those two triggers, the automation gets triggered and creates a log event.

Question: Is there some way to make triggers enable and disable other triggers in their conditions? What I was thinking about doing is having upper temperature and max upper temperature be the only two active triggers. If either was hit, John’s AC would then turn on and the triggers for lower temperature and max lower temperature would be enabled until one of those two triggers was hit, at which point John’s AC would turn off, and those two triggers would be disabled. until upper temperature got hit again.

Admittedly, it’s a lot of work, just to avoid a couple of log messages, but just for shits and giggles, I wonder if it’s possible.

  • SolidGrue@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    ·
    3 days ago

    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.