"Double-resolve" templated entity_id in action: light.turn_on

Hi all,

being able to do this would really help me declutter some of my light automations:

Within the automation (in Switch Manager, but that shouldn’t make a difference) I have a variable “last_pressed_id” that references a helper wall_switch_last_pressed. The helper then contains the name of the light which was turned on/off with the most recent button press. So it would be:

variable “last_pressed_id”: input_text.wall_switch_last_pressed
helper input_text.wall_switch_last_pressed: light.kitchen_ceiling

Now I want to use

action: light.turn_on
metadata: {}
data:
  transition: 1
  brightness_step_pct: "-{{ data.variables.step_size_step }}"
  kelvin: "{{ states('input_select.kitchen_ceiling_up_color_temp_helper') | int(0) }}"
target:
  entity_id: "{{ data.variables.last_pressed_id }}"

But obviously (?), data.variables.last_pressed_id does not reference “two levels down” to “light.kitchen_ceiling”. Is there a way this can be done?

Thanks so much in advance.