Automation help - restoring previously saved state

I have an automation that saves the current state of the hvac system in an input_text.saved_hvac_mode variable. It works great.
` action:

  • service: input_text.set_value
    data:
    value: ‘{{states.climate.lyric_03c32b.state}}’
    target:
    entity_id: input_text.saved_hvac_mode
  • device_id: 94a97da7bf6e4112a36b4584feab3d8a
    domain: climate
    entity_id: climate.lyric_03c32b
    hvac_mode: ‘off’
    type: set_hvac_mode
    I am having more trouble than it should be to restore the previously saved state to the climate device.
    This is code from the automation that works. hvac_mode ‘cool’ matches one of the available states.

` action:

  • device_id: 94a97da7bf6e4112a36b4584feab3d8a
    domain: climate
    entity_id: climate.lyric_03c32b
    hvac_mode: cool
    type: set_hvac_mode`

All I want to do is replace the hvac_mode string with the results from this template.
{{ states('input_text.saved_hvac_mode') }}
It just doesn’t seem to work in real life. What is wrong here?
I’ve tried
` action:

  • device_id: 94a97da7bf6e4112a36b4584feab3d8a
    domain: climate
    entity_id: climate.lyric_03c32b
    hvac_mode: {{ states(‘input_text.saved_hvac_mode’) }}
    type: set_hvac_mode`
    but that does not seem to be the way to do it.