Wait for choose trigger and loop

hi, I am trying to do something with this logic in just one automation:

there is an ikea simple switch dissimulated under the table far activating the cinema scene and disactivate it.
and I want to pause/play with the same button

but I can’t find a way to wait and chose between two trigger

with two automation its weird but possible:

alias: mode cine
description: ''
trigger:
  - device_id: 37400a17e99c50753d77625f481737e2
    domain: zha
    platform: device
    type: remote_button_long_press
    subtype: dim_up
condition: []
action:
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.cine_mode
  - service: scene.create
    data:
      scene_id: before_cine
      snapshot_entities:
        - light.cuisine_1
        - light.cuisine_2
        - light.grosse
        - light.petite
        - switch.lampe_noir
        - switch.tour
        - light.85888273500291bb2103
        - light.cote_salon
        - light.cote_cuisine
  - scene: scene.mode_cine
  - repeat:
      while:
        - condition: state
          entity_id: input_boolean.cine_mode
          state: 'on'
      sequence:
        - wait_for_trigger:
            - device_id: 37400a17e99c50753d77625f481737e2
              domain: zha
              platform: device
              type: remote_button_short_press
              subtype: turn_off
            - device_id: 37400a17e99c50753d77625f481737e2
              domain: zha
              platform: device
              type: remote_button_short_press
              subtype: turn_on
        - service: media_player.media_play_pause
          target:
            entity_id: media_player.cascanone
  - scene: scene.before_cine
mode: single

and for stoping

alias: stop mode cine
description: ''
trigger:
  - device_id: 37400a17e99c50753d77625f481737e2
    domain: zha
    platform: device
    type: remote_button_long_press
    subtype: dim_down
condition: []
action:
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.cine_mode
mode: single

but its a bit clunky because the second automation do not directly stop and I have to trigger to loop to terminate

You don’t have to loop. The transposition from your logic to HA is a bit too literal.

You have already 2 modes, based upon input_boolean.cine_mode. Just handle the remote events based upon those modes.

Something like (untested):

- alias: mode cine supervisor
  description: ''
  trigger:
  - device_id: 37400a17e99c50753d77625f481737e2
    domain: zha
    platform: device
    type: remote_button_long_press
    subtype: dim_up
  condition: []
  action:
    - choose:
      - conditions:
        - condition: state
          entity_id: input_boolean.cine_mode
          state: off
        sequence:
        - service: input_boolean.turn_on
          target:
            entity_id: input_boolean.cine_mode
        - service: scene.create
          data:
            scene_id: before_cine
            snapshot_entities:
              - light.cuisine_1
              - light.cuisine_2
              - light.grosse
              - light.petite
              - switch.lampe_noir
              - switch.tour
              - light.85888273500291bb2103
              - light.cote_salon
              - light.cote_cuisine
        - scene: scene.mode_cine
      default:
      - service: input_boolean.turn_off
        target:
          entity_id: input_boolean.cine_mode
      - scene: scene.before_cine

and

- alias: mode cine
  description: ''
  trigger:
  - device_id: 37400a17e99c50753d77625f481737e2
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: turn_off
  - device_id: 37400a17e99c50753d77625f481737e2
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: turn_on
  condition:
  - condition: state
    entity_id: inpinput_boolean.cine_mode
    state: on
  action:
  - service: media_player.media_play_pause
    target:
      entity_id: media_player.cascanone

that is not a bad solution.
it still is in two separate automation, but it gave me some idea. :
I do not need to have two different button to start and stop the cine mode
in fact, I realize that its possible that i will want to pause event if I did not start the cine mode so two separate automation is not necessary a bad thing.
I do wish we could group automation together tough. because I will have like 4 automation by button

Consolidating multiple related automations into a single automation sometimes results in a simpler, easier to maintain automation, and sometimes into something more convoluted and complicated.

In this case, it’s possible to create a single automation that handles all button events. However, the automation’s action grows in complexity because now it requires a choose to determine which one of the many button events triggered the automation. In addition, the automation can no longer use a simple condition statement (like the one in koying’s second example) because it would now have to apply to all button events. It may require moving that conditional logic into the choose.

that is a bit what i was going for, but I didn’t found a way to put the " choose to determine which one of the many button events triggered the automation." part in the automation.
thats why I was looking for a choose trigger thing.
the ikea round five button have 2 event by button, that’s 10 automation >< if I have one by action

You can save yourself some time and use this Blueprint (or copy its code to create your own single automation):

1 Like

oh yeah I had forgot that I had save that 3 month ago when I was ordering my zigbee kit :stuck_out_tongue:
thanks