RESTful Switch - multiple resource URLs

Hi all

I am setting up a RESTful switch for altering a Hue sensor config.

I can successfully create the switch to work according to documentation,

switch:
 - platform: rest
   resource: http://huesensor/ENDPOINT/config

but problem is that in order to read the sensor’s is_on_template state, the sensor has to be queried on a different ENDPOINT, namely
resource: http://huesensor/ENDPOINT/ which is different from the original resource. Any idea how to trick the RESTful switch to read the state from a different endpoint?

3 Likes

I’m currently having the same issue when trying to add a WLED controlled relay using the Multi Relay user mod.

Would be great if someone had an idea how to add this relay having two endpoints for querying the state and setting the state as a single switch.

What I’m having so far:

switch:
  - platform: rest
    resource: http://host/json
    body_on: '{"MultiRelay":{"relay":0,"on":true}}'
    body_off: '{"MultiRelay":{"relay":0,"on":false}}'
    is_on_template: "{{ value_json['0'] }}"
    headers:
      Content-Type: application/json