Command Line Switch track state

I’m using a Broadlink device to send RF/IR commands using HTTP. Most of the devices don’t have a dedicated ON and OFF buttons (single command to toggle power). I wanted to use the command line switch to keep track of the On/Off state. I’ve come across other posts requesting a similar application but I cannot figure out how to do this.

For example, I send a state ON command to Home Assistant. HA send a cURL command to my device and changes the state to ON. It remains ‘On’ and does not respond to additional On commands. Then, I can send an OFF command to change the state to ‘Off’ and send the same cURL command.

Does anyone have a working example I can use and customize? Thanks!

I’m also wondering this.

The following config almost works for me (command_state doesn’t quite return right)

switch:
  platform: command_line
  switches:
    port_2_wiolink_1_d1:
      command_on: "/usr/bin/curl -X POST https://us.wio.seeed.io/v1/node/GroveRelayD1/onoff/1?access_token=xxxxx"
      command_off: "/usr/bin/curl -X POST https://us.wio.seeed.io/v1/node/GroveRelayD1/onoff/0?access_token=xxxxx"
      command_state: "/usr/bin/curl -k -X GET https://us.wio.seeed.io/v1/node/GroveRelayD1/onoff_status?access_token=xxxx"
      value_template: '{{ value_json.onoff == "1" }}'

did you manage this?