Combine command_switch and status from binary sensor

Hello,
I’m struggling showing the status.
I’m using command_on and command_off for my window blinds (it sends GPIO to relais which then sends via remote control).

  command_on: "/usr/local/bin/gpio mode 21 out ; /bin/sleep 2; /usr/local/bin/gpio mode 21 in"
  command_off: "/usr/local/bin/gpio mode 23 out ; /bin/sleep 2; /usr/local/bin/gpio mode 23 in"

For the status of the blinds, I have a HomeMatic sensor (binary_sensor.neq1234567_state which can be on or off). It shows “on” when the blind is opened and “off” when it’s closed.

How do I combine the binary sensor with the command line switch?
As a result, I want a on/off switch for the blinds which shows the reverse status. The switch should be off when the blind is opened (binary_sensor.neq1234567_state == “on”).

I am absolutely not sure on how to achieve this and tried-and-errored for the last couple of hours.
Thanks!

Hi,
I would use an input_boolean managed by automations, then in the frontend you expose the input boolean only.

Use a restful api call for the state command to get the state of the binary sensor. Then use the value template to extract the state.

command_state: curl -X GET http://127.0.0.1:8123/api/states/binary_sensor.your_sensor
value_template: '{{ value_json.state == "on" }}'  #replace "on" with the value the call returns for state. 

Run the command in terminal or browser to test.