Variables in a state

is there a way to retrieve states by copying a variable together with a fixed value

I want to control all my shutters with one script

this should work like this i call the script and give it an argument shutter_back_right

the script should then retrieve different values based on the argument Open Position Temperature etc.
here I have generated helper

with cover.{{shutter }} it works

but how can I address the helpers?

my code:

> alias: Open shutter
> fields:
>   shutter:
>     description: The content
>     example: shutter_back_right
>     required: true
> variables:
>   openpos: "{{ states('input_number.[{{ shutter }}]_open_pos') }}"
> sequence:
>   - if:
>       - condition: or
>         conditions:
>           - condition: and
>             conditions:
>               - condition: time
>                 after: input_datetime.roller_shutter_back_right_full_up
>               - condition: numeric_state
>                 entity_id: sensor.sun_azimuth
>                 above: input_number.shutter_back_right_azimuth_in
>               - condition: numeric_state
>                 entity_id: sensor.sun_elevation
>                 above: input_number.shutter_back_right_elevation_in
>           - condition: time
>             after: input_datetime.shutter_shutter_back_right_spat_up
>     then:
>       - service: cover.set_cover_position
>         data:
>           position: "{{ openpos }}"
>         target:
>           entity_id: cover.{{ shutter }}
>   - service: telegram_bot.send_message
>     data:
>       message: >-
>         {{ openpos }} {{ states('input_number.''[{{ shutter }}]''_open_pos')
>         }} {{ shutter }} cover.[{{ shutter }}] [{{ shutter }}]
> mode: single
> icon: mdi:window-shutter-open

=> how can I replace shutter_back_right with the {{ shutter }} argument?


"{{ states('input_number.' ~ shutter ~ '_open_pos') }}"

should do it.

thank you yes that’s exactly how it works but now I still have the same problem with

 condition: time
after: input_datetime.roller_shutter_back_right_full_up

do i have to work with tamplate here, does anyone have an example for me? would be great :slight_smile:

I have tested something, and if you know why it is like with everything very simple

and for those who have the same problem => here is the solution

condition: template
value_template: >-
  {{states('sensor.time') > (states('input_datetime.'~ shutter ~'_full_up'))}}