I found myself repeating the same automation a few times, made a Blueprint for it, and I guess there’s no harm in sharing it.
For this Blueprint to work, you need to create a Timer helper with whatever timer you want to put on the switch — at which point if you turn a light or plug on, it will turn off when the timer triggers (if it wasn’t already turned off.)
I use this for air fresheners and lights alike, just with different timers.
blueprint:
name: Switch Bounce On A Timer
domain: automation
input:
switch_entity:
name: "Switch"
selector:
entity:
filter:
- domain: switch
- domain: light
timer_entity:
name: "Timer"
selector:
entity:
domain: timer
mode: single
variables:
switch_entity: !input switch_entity
timer_entity: !input timer_entity
trigger:
- id: switch_on
platform: state
entity_id: !input switch_entity
to: "on"
- id: switch_off
platform: state
entity_id: !input switch_entity
to: "off"
- id: timer_trigger
platform: event
event_type: timer.finished
event_data:
entity_id: !input timer_entity
action:
- choose:
- conditions:
- condition: trigger
id: 'switch_on'
sequence:
- service: timer.start
target:
entity_id: !input timer_entity
- conditions:
- condition: trigger
id: 'switch_off'
sequence:
- service: timer.cancel
target:
entity_id: !input timer_entity
- conditions:
- condition: trigger
id: 'timer_trigger'
sequence:
- service: switch.turn_off
target:
entity_id: !input switch_entity
- service: light.turn_off
target:
entity_id: !input switch_entity