haarts
September 17, 2024, 7:27pm
1
I’m a bit at a loss here. I want to create a binary sensor that changes state based on what a HTTP GET request returns. But what should that (JSON) response body be? {"state":"on"}
is definitely not it. Here’s the relevant configuration.yaml
snippet:
binary_sensor:
- platform: rest
name: living_room_lights
device_class: light
resource: http://192.168.178.191:8000/lights
scan_interval: 300
Must I use a value_template
?
Often you don’t control what is returned by the rest call, which is when value_template
is needed to convert the returned value to on or off.
If you do control what is returned, according to the documentation , you can return anything like the following:
The JSON messages can contain different values like 1
, "1"
, TRUE
, true
, on
, or open
If you want to return something else, use value_template
to turn it into one of the above.
haarts
October 1, 2024, 1:40pm
3
I didn’t consider these values to be bare values. But they are. I guess I would have worded it differently. Thanks!