moonpunk
(moonpunk)
December 5, 2024, 1:56pm
1
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/
Troon
(Troon)
December 5, 2024, 2:07pm
2
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
moonpunk
(moonpunk)
December 6, 2024, 11:46am
3
Thank you Troon - that works exactly as I wanted, and you’re right there is no need for the toggle helper. Thanks again