I imagine there are multitude of ways to accomplish this, but I’m looking for the simplest one.
I have 12 switches and I only want one to be on at any given time. So if any switch is on and I turn on a different switch, I want to make sure all other switches are off. I started down the path of creating an automation that when any switch changed state from off to on the automation would turn off all switches, then turn on the switch that initially triggered the automation. I couldn’t figure out how to know which switch changed state, which is why I started this question. As I was typing this, it occurred to me that that probably wouldn’t work anyway because the final step of turning the switch on would likely trigger the automation again, and get stuck in a loop.
The kind of brute force way would be to create a unique automation per switch that would turn off all other switches, but defining 12 automations seems like a clumsy solution.
trigger.entity_id contains the entity_id of the switch that triggered the automation’s State Trigger. So your switch.turn_off action will use a template to identify which switch to turn off.
Thank you, this gave me some key info. Using what you gave me mostly works. By that I mean since this the automation is triggered by a switch changing state to on, turning all switches off and then turning the switch that initially changed state to on again is not perfect, but I’m going to see if I can figure that our on my own.