When calling cover.set_cover_position opens to position then closes

I have my blinds configured as covers. They open and close and report their position correctly. I can even set the position from the dashboard without any problems. When I try to set the position from a script or scene they will open to the position, then 15 seconds later close. Currently to get around this I’m opening, delaying 7 seconds, then stopping but I have no idea why the set position doesn’t work properly.

If the blinds are open before running the script then it works fine but if the blinds are closed then I have this problem.

Example script that opens then closes.

test:
  alias: Test
  sequence:
  - service: cover.set_cover_position
    data:
      position: 20
    entity_id: cover.shutter_living_window
  mode: single

Sounds like you are not getting position state feedback for your cover in a timely manner.

Can you show your cover config?

This can usually be solved by using the homeassistant.update_entity service.

I use a REST gateway to talk to the blinds. The gateway registers various functionality as separate entities with ids. So 1 id is for positioning and another id is for the basic open/close/stop but its all the same device.

shell_command:
  shutter_up:        "curl http://127.0.0.1:8181/rollingshutter/v2/open/{{ device_id }}"
  shutter_down:      "curl http://127.0.0.1:8181/rollingshutter/v2/close/{{ device_id }}"
  shutter_stop:      "curl http://127.0.0.1:8181/rollingshutter/v2/stop/{{ device_id }}"
  shutter_position:  "curl http://127.0.0.1:8181/rollingshutter/v2/setposition/{{ device_id }}/{{ position }}"

sensor:
  - platform: command_line
    name: shutter_position_living_window
    command: "curl http://127.0.0.1:8181/rollingshutter/v2/getposition/6960"
    unit_of_measurement: "%"
    scan_interval: 5

cover:
  - platform: template
    covers:
      shutter_living_window:
        friendly_name: "Shutter - Living Room (window)"
        device_class: shutter
        position_template: "{{ states('sensor.shutter_position_living_window') }}"
        open_cover:
          service: shell_command.shutter_up
          data: 
            device_id: 9343
        close_cover:
          service: shell_command.shutter_down
          data: 
            device_id: 9343
        stop_cover:
          service: shell_command.shutter_stop
          data: 
            device_id: 9343
        set_cover_position:
          service: shell_command.shutter_position
          data_template: 
            device_id: 6960
            position: "{{ position }}"
 

Hmm. Ok, that scan interval of 5 seconds precludes the problem I was thinking of.

This turns out to be a bug in the gateway software. The company says they are working on a fix.