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.
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.
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.
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
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.