After reading watching many postings and videos on the web, i have created a Rest_Command that can set the position of my Switchbot Blind tllt. It is patterned after the work of Speak-to-the-geek from July 2023. However it will only works the first time after restarting HA. Subsequent tries result in 401 error. Further Web Searches point to the nonce value as the problem. All of STTG’s work have a nonce set to “”. The API docs do not discuss the nonce, but various language examples set nonce to some values.
I’ve tried setting nonce to “{{ (range(32) | map(‘random’) | join | string) }}”. This also only worked the first time. What am I doing wrong?
Here is the full rest_command …
rest_command:
set_blind_tilt:
url: https://api.switch-bot.com/v1.1/devices/E55774AB65CE/commands
method: POST
headers:
Authorization: "{{ states('input_text.switchbot_token') }}"
sign: "{{ states('sensor.switchbot_sign') }}"
t: "{{ state_attr('sensor.switchbot_sign','t') }}"
Content-Type: "application/json"
nonce: ""
payload: '{"commandType": "command","command": "setPosition","parameter": "{{ tilt_position }}"}'
content_type: 'application/json; charset=utf-8'`Preformatted text`