Add IP Address to JsonInfo (#1912)

* Add IP Address to JsonInfo

The value is added to the JSON only if the device is connected to the network, and uses the JSON key `"sip"` to match [wled00/xml.cpp](wled00/xml.cpp#L249). The overarching goal of this is to expose the IP Address to the Home Assistant WLED Integration, so that Home Assistant can provide a link to the WLED device (either directly through the Integration/Device page 🤞 or *ad hoc* in Lovelace).

* IP in JSON info

Empty string if not connected

Co-authored-by: Aircoookie <cschwinne@gmail.com>
This commit is contained in:
acshef 2021-04-24 17:37:16 -06:00 committed by GitHub
parent ced0cc1bac
commit 9a0aac4745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -549,6 +549,13 @@ void serializeInfo(JsonObject root)
root[F("brand")] = "WLED";
root[F("product")] = F("FOSS");
root["mac"] = escapedMac;
char s[16] = "";
if (Network.isConnected())
{
IPAddress localIP = Network.localIP();
sprintf(s, "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]);
}
root["ip"] = s;
}
void setPaletteColors(JsonArray json, CRGBPalette16 palette)