Script device parameter template value

Hi all,
I have prepared a simple script to open a roller shutter a certain amount. Then I considered I wanted to control that amount independently, so I created a helper number variable. The problem is I cannot use that variable on the script - is this a known limitation or am I missing something obvious?

Current, working setup:

alias: Garage vent left
sequence:
  - device_id: 3dfec9b52174ac45d611ee5be0e5a7db
    domain: cover
    entity_id: cover.sp25_2_gdl
    type: set_position
    position: 26
mode: single
icon: mdi:garage-alert

Intended script - not working (despite trying a few variations of the syntax):

alias: Garage vent left
sequence:
  - device_id: 3dfec9b52174ac45d611ee5be0e5a7db
    domain: cover
    entity_id: cover.sp25_2_gdl
    type: set_position
    position: ' {{ states("input_number.garage_vent_percentage")|int }} '
mode: single
icon: mdi:garage-alert

The error is Message malformed: value must be one of ['close', 'close_tilt', 'open', 'open_tilt', 'stop'] for dictionary value @ data['type']

Any suggestions? Is this not possible?

Thanks in advance;

It’s not possible with a Device Action because it doesn’t support the use of templates.

Service Calls support templates so use cover.set_cover_position

alias: Garage vent left
sequence:
  - service: cover.set_cover_position
    target:
      entity_id: cover.sp25_2_gdl
    data: 
      position: '{{ states("input_number.garage_vent_percentage") | int(0) }} '
mode: single
icon: mdi:garage-alert

thanks - that worked perfectly!!

1 Like