Rest_command problem

Hi there, i am quite new to REST commands and am struggling to get something working.
I am in a beta testing group for Slide a controller for curtains (great by the way, not sponsored :wink: )

I am trying to set up a rest_command so i can use their local API but have been struggling for quite some time.

When i use Postman i can control the curtains, this is what the code looks like:
curl --location --request POST '192.168.68.208/rpc/Slide.SetPos' \ --header 'Authorization: Digest username="user", realm="iim", nonce="undefined", uri="/rpc/Slide.SetPos", algorithm="MD5", response="1eb8e0084bd3717c98bd9a668d73264d"' \ --header 'Content-Type: application/json' \ --data-raw '{ "pos": 0.1 }'
In my configuration.yaml i put following, tried i don’t know how many different setups but keep getting: Error. Url: http://192.168.68.208/rpc/Slide.SetPos. Status code 401.
This is an authentication failure…

rest_command: setcurtainpos: url: 'http://192.168.68.208/rpc/Slide.SetPos' method: POST headers: Content-Type: 'application/json' Authorization: 'Digest username="user:jRD85b2H", realm="iim", nonce="undefined", uri="/rpc/Slide.SetPos", algorithm="MD5", response="1eb8e0084bd3717c98bd9a668d73264d"' content_type: 'application/json' payload: '{"pos": 0.0"}'

Does anybody have a clue of what (probably stupid) thing i am doing wrong?

Many thanks!

The rest_command you posted is not formatted thereby making it difficult to check for syntax errors. Hopefully I’ve interpreted it correctly.

Based on the example in the documentation, the options are arranged in a slightly different hierarchy and use different spelling.

Try this version and see if it improves anything:

rest_command:
  setcurtainpos:
    url: 'http://192.168.68.208/rpc/Slide.SetPos'
    method: POST
    headers:
      authorization: 'Digest username="user:jRD85b2H", realm="iim", nonce="undefined", uri="/rpc/Slide.SetPos", algorithm="MD5", response="1eb8e0084bd3717c98bd9a668d73264d"'
    content_type: 'application/json'
    payload: '{"pos": 0.0"}'

Update for anyone interested: the rest_command does not support digest authentication. A workaround is to use a shell_command like this:

shell_command:
  slide_setpos: >-
      curl -X POST http://<IP ADRESS>/rpc/Slide.SetPos -H 'Content-Type: application/json' -H 'cache-control: no-cache' -d '{"pos":{{position | float / 100 }}}' --digest -u user:<DEVICE CODE>
  slide_stop: >-
      curl -X POST http://<IP ADRESS>/rpc/Slide.Stop -H 'Content-Type: application/json' -H 'cache-control: no-cache' --digest -u user:<DEVICE CODE>

sensor:
  - platform: rest
    name: slide_bedroom_position
    resource: http://<IP ADRESS>/rpc/Slide.GetInfo
    method: POST
    authentication: digest
    value_template: "{{ value_json.pos * 100 }}"
    json_attributes:
      - zone_name
      - device_name
      - curtain_type
      - touch_go
      - calib_time
      - slide_id
      - board_rev
      - mac
      - pos
    username: user
    password: <DEVICE CODE>
    headers:
      Content-Type: application/json
      User-Agent: Home Assistant REST sensor
      cache-control: "no-cache"

cover:
  - platform: template
    covers:
      slide_bedroom:
        device_class: curtain
        friendly_name: "Curtains bedroom"
        position_template: "{{ states('sensor.slide_bedroom_position') }}"
        set_cover_position:
          service: shell_command.slide_setpos
          data_template:
            position: "{{position}}"
        stop_cover:
          service: shell_command.slide_stop
        availability_template:  "{{ states('binary_sensor.ping_slide')}}"

binary_sensor:
  - platform: ping
    name: Ping Slide
    host: <IP ADRESS>
    count: 5
    scan_interval: 300

Note that the ‘position’ in the shell command is divided by 100. The Slide API uses a float between 0-1, while Home Assistant uses a value between 0-100. Same is done for the position sensor, where the value from the API is multiplied by 100.