Automation event toggle

Hello,
i’ got an automation which receives an event keypress, fires a scene which starts closing my shutters, then waits 5 sec and then stops the shutters so that they are half closed. (because they don’t support position value).

That works fine so far.

But what i want now is when firing the event keypress from roku again, it should fire another scene which opens the shutters.

can anyone please help me out with that?

Thx, Marco

alias: Kino Rolladenbeschattung
description: cinema
trigger:
  - event_data:
      key: Home
      source_name: Home Assistant ROKU
      type: keypress
    event_type: roku_command
    platform: event
condition: []
action:
  - scene: scene.dr7bdcmnkrsnmbj4
  - delay: '5'
  - scene: scene.lnl5wkxkpazyb9it
mode: single
max: 2

Just make an input_boolean helper so you can store the current state of the shutters. For example:

description: cinema
trigger:
  - event_data:
      key: Home
      source_name: Home Assistant ROKU
      type: keypress
    event_type: roku_command
    platform: event
condition: []
action:
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.cutains_closed
  - scene: scene.dr7bdcmnkrsnmbj4
  - delay: '5'
  - scene: scene.lnl5wkxkpazyb9it
mode: single
max: 2

Now you have something you can check to see if you need to do something else. This can be done with a chooser:

alias: Kino Rolladenbeschattung
description: cinema
trigger:
  - event_data:
      key: Home
      source_name: Home Assistant ROKU
      type: keypress
    event_type: roku_command
    platform: event
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.cutains_closed
            state: 'off'
        sequence:
          - service: input_boolean.turn_on
            target:
              entity_id: input_boolean.cutains_closed
          - scene: scene.dr7bdcmnkrsnmbj4
          - delay: '5'
          - scene: scene.lnl5wkxkpazyb9it
    default: []
mode: single
max: 2

In the default case you can specify what you want to do when they are closed.

i got it, needed to create the boolean under helper tools first.

alias: Kino Rolladenbeschattung
description: cinema
trigger:
  - event_data:
      key: Home
      source_name: Home Assistant ROKU INT
      type: keypress
    event_type: roku_command
    platform: event
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.curtain_closed
            state: 'off'
        sequence:
          - service: input_boolean.turn_on
            entity_id: input_boolean.curtain_closed
          - scene: scene.dr7bdcmnkrsnmbj4
          - delay: '7'
          - scene: scene.lnl5wkxkpazyb9it
    default:
      - scene: scene.d3wr5upux1wmz4ev
      - service: input_boolean.turn_off
        data: {}
        entity_id: input_boolean.curtain_closed
mode: single
max: 2

and set the boolean to turn off in default.

Works perfect now, thanks!