I am trying to make 2 esphome devices “communicate”. There is one toggle light (sonoff mini set up as toggle light) which has the following json payload when perfoming the http_request.get: {"id":"light-licht_kche","state":"OFF"}
I want to read the sate with another esphome device and when this other device is activated it shall
Hello. I also have two esphome devices communicating and aplying logic completely without home assistant. For one device I publish values with web_server: component. It publishes json state. I then read it with other esphome device with this lambda:
in esphome: component:
id(reading_http)=true; //avoid conflict if any other component is just using http
HTTPClient http2;
IPAddress serverIp = MDNS.queryHost("blinds-cs1"); //this section looks up for IP address
int i = 5;
while ((serverIp.toString() == "0.0.0.0") && (i > 0)) {
delay(250);
i--;
serverIp = MDNS.queryHost("blinds-cs1"); //##################### Change server for color
}
if (i > 0) {
http2.useHTTP10(true);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
}
http2.begin("http://"+serverIp.toString()+"/sensor/color_nr");
if (http2.GET() == 200) {
id(cs1_available) = true;
DynamicJsonBuffer doc(200);
JsonObject& root = doc.parseObject(http2.getStream());
int color = atoi(root["value"].as<char*>());
http2.end();
id(reading_http)=false;
return color;
}
else {
id(cs1_available) = false;
ESP_LOGD("main", "################### CS1 not available!");
http2.end();
id(reading_http)=false;
return -1;
}
}
else {
id(cs1_available) = false;
ESP_LOGD("main", "################### CS1 not available, mDNS error!");
http2.end();
id(reading_http)=false;
return -1;
}