When I turn on a light, I’m trying to directly poll the state of another light, and send it a turn_on command if it’s currently turned off.
http_request:
useragent: esphome/device
timeout: 10s
id: http_request_data
sensor:
- platform: template
id: remote_state
...
light:
- platform: binary
name: "Foyer Light"
output: relay1
id: light1
on_turn_on:
- http_request.get:
url: http://192.168.0.21/light/foyer_light
on_response:
then:
- lambda: |-
json::parse_json(id(http_request).get_string(), [](JsonObject root) {
id(remote_state).publish_state(root["state"]);
});
- if:
condition:
text_sensor.state:
id: remote_state
state: 'OFF'
then:
- http_request.post: "http://192.168.0.21/light/foyer_light/turn_on"
This throws an error Unable to find condition with the name 'text_sensor.state'.
I think I might be missing something terribly obvious with my indenting - is there a cleaner way to do this?