Is the ability to refer to items in the for_each mechanism broken?

I’ve been banging my head against this for hours, and I can’t figure it out. Finally, I just tried some example code, and that doesn’t work, so now I’m wondering if I’ve hit a bug.

I’m trying to write an automation that loops over the lights in a group of lights and, if the light is turned on, adjusts the color temp. I’m using repeat/for_each to construct the loop, but when I try to refer to the “repeat.item” variable in the sequence block, I get a “‘repeat’ is undefined” error.

I have the following in the Template Editor to try and debug it:

repeat:
  for_each:
    - "living_room"
    - "kitchen"
    - "office"
  sequence:
    - action: light.turn_off
      target:
        entity_id: "light.{{repeat.item}}"

The result window is reporting that “‘repeat’ is undefined” error. It looks like a scope error, but that’s verbatim from the documentation, and the indentation suggests to me that the “repeat” variable ought to be in scope. I can’t find anything to suggest that this has been deprecated, and that structure is used all over the place.

I feel like there must be something I don’t understand here, because if this functionality was broken, well, I imagine all hell would break loose across many different systems. But at the same time, I’ve broken it down to a very simple piece of example code, and that doesn’t work.

Anyone have any insight?

There’s the problem.
You can’t use actions in template editor.
You need to use the automation or script editor.

I am going to scream.

Thank you.