But using your example you can create different automations to control different lights and counts by running the same script with different variables sent to it.
count: "{{ count|int * 2 - 1 }}"
I’m not sure why you are using that code to set the count. Is that code important? It seems you might have just copied that code from an example somwhere?
but basically it means take the variable count (3 in your case) multiply it by 2 and subtract 1 from it so the result is 5.
IMO, if you want a count of 5 just use 5 as the value of “count” instead of 3. Then just use the variable without the math.
It would help if you included the actual error. But it looks like you have your count in the wrong place and you dont need an until if you just want to loop for a count of three times. Try this:
before i start the automation, the state of media_player.living_room_speaker is idle, after i start the automation, it showed playing, then it will show idle again. So, there is no repeat at all.
I would have thought that the way you had it originally would have been the one to work, but if you feel like humouring me try the script.turn_on service. Or if you can’t be bothered just go back to your delay that works.