How to configure a "first press"?

Hi,
I have a button that triggers an automation that cycles through 3 different scenes (using a dropdown helper): scene A, B and C.

Right now every time I press this button it the automation goes to the next helper dropdown value and activates the next scene. For example from A to B.
If 3 hours later I trigger the automation, then it goes to the next (B to C).

What I want to do is:
If the automation hadn’t run for at least one hour, then activate scene A, and the next one should be scene B (unless nect press is on hour later, and in that case its going to be scene A again).

This is what is called “first press” on philips hue switches and I can’t seem to find a way to achieve.

Any ideas?
Thanks!

Can we see the automation configuration please?

Sure, this is the automation YAML:

alias: Auto Estu Desk Toggle Whites
description: Pasa de una escena a otra
trigger:
  - platform: device
    domain: mqtt
    device_id: 65e03f450f4982e72b8801010f43c5f7
    type: button_short_press
    subtype: Button2
    discovery_id: midi-mixer Button2
condition: []
action:
  - service: input_select.select_next
    data:
      cycle: true
    target:
      entity_id: input_select.escenas_estudio
  - service: scene.turn_on
    target:
      entity_id: "{{ states('input_select.escenas_estudio')}}"
mode: single

Also attaching screengrabs of the front end helper and automation.
Thanks for looking at this.


Currently you are using input_select.select_next to move to the next section (A, B, or C) depending on what the current value is. If you create a separate automation to reset the input select back to the beginning (input_select.select_first) after a time has expired then the next selection will always be the second one.
Maybe this will give you some ideas, good luck.

alias: Auto Estu Desk Toggle Whites
description: Pasa de una escena a otra
trigger:
  - platform: device
    domain: mqtt
    device_id: 65e03f450f4982e72b8801010f43c5f7
    type: button_short_press
    subtype: Button2
    discovery_id: midi-mixer Button2
condition: []
action:
  - choose:
      - conditions:
          - "{{ now() >= this.attributes.last_triggered + timedelta(minutes=5) }}"
        sequence:
          - service: input_select.select_first
            target:
              entity_id: input_select.escenas_estudio
    default:
      - service: input_select.select_next
        data:
          cycle: true
        target:
          entity_id: input_select.escenas_estudio
  - service: scene.turn_on
    target:
      entity_id: "{{ states('input_select.escenas_estudio')}}"
mode: single

If you aren’t actually trying to target the first option, you can use input_select.select_option service to specify an option.

I’ve tried using this but it doesn’t seem to be working.

I guess that this means “if the automation hadn’t been triggered during the last 5 minutes”, right?
- "{{ now() >= this.attributes.last_triggered + timedelta(minutes=5) }}"

I’ve tried with minutes=1 and the helper never gets reset to the first, it always select the next scene.
Any ideas on what should be happening?

Sounds like a great idea. I guess its the same that was suggested but on a separate automation.
I’ve tried to do this and failed spectacularly. Is this something that should be coded in YAML or it might be done from the front end?
Thanks for the help.

Yes, that is what it means. I have tried, but I can’t replicate an issue with a 1 minute interval. Even setting the time delta to 15 seconds work without issues for me.