I am trying to extract a line from a list (where I have done a match and replace) using REGEX and use the string as a variable. This is to set the media player to be the one I am asking from via HA voice PE albeit _2 for the music assistant entity. I have it working however it is by luck it works as what I have done tries the whole list of strings and fails until it finds the only string in the list that is valid .
The following is added to the trigger and the variable “voice_assistant_device” returns true instead of the string that it matches.
I now can play music via any HA voice PE device through one automation without duplication of actions etc (it targets the device I am talking/ requesting from).
I seem to have to add the lines below for each trigger_id unless there is a way to do this once for the entire automation?
You seem to be describing what are sometimes called “trigger-attached” variables. Those are generally meant for cases where each trigger needs it’s own distinct conditional logic. There are a number of places you can set up variables in an automation depending on how you need to use them. For your described use I would suggest creating a general variables block at the same level as triggers, conditions, and actions.