Looking for a way to turn a light on for x duration, where x changes depending on how many times button is pressed

So I am trying to come up with a solution to turn my front house lights on for a certain duration based on the amount of times the button is pressed. I currently have an automation to turn the lights off after 15 minutes that would probably need to be changed. I have tried searching around for a solution but honestly am not sure what to even search for. Does anyone have any ideas here?

I’d say, it depends largely on what kind of button you have.

I have a few Xiaomi WXKG11LM that register 1x, 2x, 3x, 4x pressing the button which would make it very easy to set up different durations.

Others, like the IKEA E1812 will only register single button presses, which would probably require a number helper.

And then there are buttons like the Hue TapDialSwitch that have multiple buttons on the unit itself and can register multiple actions per button (press, long press, release) and have a dial in addition to that.

I have lutron caseta and am using a pico remote. I am just falling short on how to accomplish this using an automation.

If you describe the capabilities of the devices, it will be easier for people to provide some advice.

Not everybody reading this forum will rush to find out on the internet and in product descriptions, what a ‘pico remote’ can do, if it’s even connected directly to a HA installation (e.g. via Zigbee) or if the Lutron Caseta just operates as a ‘relay’, i.e. the remote triggers the action in the switch and the switch feeds the status back to HA.

Sorry I do not understand what you mean. It uses the official Lutron Caseta integration. It is a device that I can select in the automation builder under trigger. The type is press. Would the trigger yaml help to see the capabilities?

  - platform: device
    device_id: b40a2c03c212e1156e59d3bd92e6b68d
    domain: lutron_caseta
    type: press
    subtype: "on"

I believe what @chairstacker is trying to get from you is… What currently happens when you press the button multiple times? Does the light toggle on/off? If it does, is there a way to decouple that behavior?

If the button press has no direct action on the switch, you could use something similar to this timer-based heating automation

Thank you for explaining. The Pico remotes have 5 buttons on them, when you push “On” the light turns on. If you push on again nothing happens, so in my mind the automation can check the reported light state and then set the time out for the light accordingly. This is where I am stumbling though. I will check out the timer-based heating automation. Thank you.