Hi,
I would like to read a specific parameter from an api and create an action on the result being true.
Api json output:
Current esphome config, which I modified based on somebody else’s idea…
sensor:
- platform: wifi_signal
name: "WiFi Signal $devicename"
update_interval: 60s
- platform: template
name: "Gesloten"
id: gesloten
http_request:
useragent: esphome/device
timeout: 4s
time:
- platform: sntp
on_time:
- seconds: /10
then:
- lambda: |-
HTTPClient http;
http.begin("https://testapi.local/api/1/toggle-variable?api_key=SECRET");
http.GET();
DynamicJsonBuffer doc(12000);
JsonObject& root = doc.parseObject(http.getStream());
float ip = atof(root["date"]["toggle-variable"][1]["state"].as<char*>());
id(gesloten).publish_state(ip);
But the sensor is not returning anything.
What I would like to do is perform an action (light.turn_on) when id: d4544d56-8a77-40e8-84bd-8be7e2a58ea3 has state: true
and turn it off when id: d4544d56-8a77-40e8-84bd-8be7e2a58ea3 state: false
I am not a coder, so this is quit hard for me.
Anyone that could help me out?
Cheers,
Michel