Best way to reset an input_boolean after it’s been triggered?

Hello! Still relatively new to all of this, so the plating is something I haven’t really understood yet. I’m trying to set up some input booleans that reset to an “off” state after an “on” trigger, and a period of a few seconds. Ideally I could set up a suffix like _r to the entity name and use that glob for the automation trigger. So thinking out loud, here’s what I want it to do:

id: boolean_reset
alias: Input boolean reset after 5 seconds
description: ''
trigger:
  - platform: state
    entity_id: input_boolean.*_r
    to: 'on'
condition: []
action:
  - delay: '5'
  - service: input_boolean.turn_off
    data: {}
    entity_id: { TRIGGERING ENTITY }
mode: single

As you can see above, I have no idea how to actually reference the input boolean that triggered the automation.

What’s the best way to do this?

If you’re wondering what my use case is:
I use HomeKit and have Apple HomePods throughout the house. It’s possible using HomeKit to activate specific music via automation but it’s a little dumb how you have to do it—in that you have to call a specific album, playlist, etc. So I wanted to be able to set up album or playlist specific input booleans, to then trigger a HomeKit automation to play it.

I don’t use this functionality, but I believe the you’re looking for:

entity_id: "{{ trigger.entity_id }}"

Awesome thanks!

Separately do you know if using the * to identify the trigger will work?

That’s not a syntax I’ve ever used, but I don’t think that is supported.

This automation will do what you want. You need to set the mode to parallel so that the automation can run again if it’s already running. And you have to use templates to extract the trigger data.

id: boolean_reset
alias: Input boolean reset after 5 seconds
description: ''
trigger:
  - platform: state
    entity_id:
    - input_boolean.x
    - input_boolean.y
    - input_boolean.z
    to: 'on'
condition: []
action:
  - delay:
      seconds: 5
  - service: input_boolean.turn_off
    data:
      entity_id: "{{ trigger.to_state.entity_id }}"
mode: parallel
1 Like

This is super helpful, thank you. Definitely answers the latter part of the question.

But do you know if there’s any way to not be required to explicitly enter every unique entity ID? I’d love to be able to have it triggered based on a really dumb string match.

Nope, unfortunately you have to long hand write it out.

Ah got it. So perhaps there’s another route then…my biggest concern with enumerating each in that reset automation is that I might forget one. So what if when I make the individual automations to trigger HomeKit, I then need to call an automation trigger?

Is there a way then to do this:

  • Turn on specific input boolean
  • On state is recognized by HomeKit, but also triggers a reset automation
  • Reset automation looks at triggering input boolean, waits 5 seconds, turns off.

So in all of this, I’m wondering if there’s a way to pass the input boolean entity ID into another automation…

You can pass it to a script but not another automation. Or you could make a custom event automation and trigger the custom event passing the input_boolean entity_id.