How to send a proper RESTful Body?

I have a pool controller that uses the REST URI to turn on:

http://192.168.2.164:3000/circuit/6/set/1

and turn off:

http://192.168.2.164:3000/circuit/6/set/0.

My rest switch is:

   - platform: rest
    resource: http://192.168.2.164:3000/circuit/6
     name: "Pool Switch"
     is_on_template: '{{states.sensor.poolcontroller_jsonrest.attributes.circuit["6"].status == 1}}'

I can’t figure out how to ‘turn on’ or ‘turn off’ the switch. I assume I send something in body_on and body_off, but don’t know what exactly. Can anyone assist?

Thanks.

I believe the RESTful Switch can only use POST or PUT methods to send on and off commands, so it doesn’t look like it will work for you.

However, you could use a combination of a Template Switch with RESTful Commands.

rest_command:
  pool_ctrl_on:
    url: "http://192.168.2.164:3000/circuit/6/set/1"
  pool_ctrl_off:
    url: "http://192.168.2.164:3000/circuit/6/set/0"

switch:
  - platform: template
    switches:
      pool_switch:
        friendly_name: Pool Switch
        value_template: >
          {{states.sensor.poolcontroller_jsonrest.attributes.circuit['6'].status == 1}}
        turn_on:
          service: rest_command.pool_ctrl_on
        turn_off:
          service: rest_command.pool_ctrl_off

BTW, I’m assuming you already have defined sensor.poolcontroller_jsonrest and the template you provided above properly indicates the current status of the pool controller. If not, and you’d like help with that part, just let me know.

Thanks a million for the response. It was actually much simpler than I was making it. Doing:

  - platform: command_line
    switches:   
      pool_switch:
         command_on: "/usr/bin/curl -X GET 192.168.2.164:3000/circuit/6/set/1"
         command_off: "/usr/bin/curl -X GET 192.168.2.164:3000/circuit/6/set/0"
         value_template: '{{ states.sensor.poolcontroller_jsonrest.attributes.circuit["6"].status == 1 }}'

worked like a champ.

Buckeyes1995… you appear to be doing the same thing I am attempting to do using nodejs-poolController. I am new to Home Assistant… having a heck of a time getting states to show properly. Was wondering if you could share your configuration.yaml…along with switches and sensors for your pool setup. Would be most appreciated.

You bet, here’s my pool.yaml file.

pool.yaml (6.3 KB)

Really appreciate it. Saved me a bunch of time! Working like a champ!

Thanks Again!