Bounce Switch On A Timer

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

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

Thank you very much, works very well, a question; how can a add a call service when the timer is finished, as I use it for my yogurt maker

Could you add -domain: input_boolean to the selection filter? I edited my local version of the blueprint and it works as expected.

There might be a better way to do this (?) But I’ve got a ‘software’ switch (an input_boolean helper) on a dashboard that I want to turn off after a set time (timer helper).

This is great! Thanks!

My wishes would be to add domain automation to the selection and possibility to revert action (turn on after timer).

These are simple to do by taking control, but maybe nice additions.