Extract value from JSON response and set switch on/off

Hi all - realtive newbie here. I have a URL which I call and it returns me the following JSON: -

{
“success”: “SUCCESS”,
“deviceID”: “HFA0F0384FE8”,
“status”: “ON”
}

I want to be able to poll the URL and extract the “status” value from the returning JSON and in turn set the value of a Toggle helper. I’m really struggling to do this - can someone point me in the right direction and help me please?

Thank you in advance/

RESTful binary sensor:

binary_sensor:
  - platform: rest
    resource: http://YOUR_URL
    scan_interval: 60
    name: "My sensor"
    value_template: "{{ value_json['status'] == 'ON' }}"

then an automation:

triggers:
  - trigger: state
    entity_id: binary_sensor.my_sensor
actions:
  - action: input_boolean.turn_{{ trigger.to_state.state }}
    target:
      entity_id: input_boolean.my_toggle_helper

…although you may not need the toggle helper once you have the binary sensor.

1 Like

Thank you Troon - that works exactly as I wanted, and you’re right there is no need for the toggle helper. Thanks again