Check current_position of covers form script

hi, i’m tring to move the windows blind to position 15 and then (when reached the position) move to 10 so it will tilt the slat, i can achive that with a delay of 1 minute, but is not so smooth…

example_script:
  sequence:
  - data:
      entity_id: cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_3
      position: 15
    service: cover.set_cover_position
  - timeout: 00:00:10
    wait_template: "{{ state.cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_3.current_position == '15' }}"
  - data:
      entity_id: cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_3
      position: 10
    service: cover.set_cover_position

Thank you for any advice.

So I assume the script you show here is your attempt to automatically detect the blind has gotten to position 15 and then change it to 10. Is that right? And if so, that’s it’s not working, right?

At a minimum, in your wait_template, “state.” should be “states.”. And more than likely you need “attributes.” before “current_position”. It would help if you entered the following in the template editor and shared the output:

{{ states.cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_3 }}

With that information I should be able to tell you exactly what to do. In the meantime, my guess is:

wait_template: "{{ state_attr('cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_3', 'current_position')|int == 15 }}"

Yes, your assumptions were correct, it works like a charm. Thanks

Here the working script.

example_script:
  alias: Schermatura studio
  sequence:
  - service: cover.set_cover_position
    data:
      entity_id: cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_3
      position: 15
  - wait_template: "{{ state_attr('cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_3', 'current_position')|int == 15 }}"
    timeout: 00:00:10
  - service: cover.set_cover_position
    data:
      entity_id: cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_3
      position: 10
  - service: notify.notify
    data:
      message: Tapparella studio DX Posizionata
1 Like