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:
parent
ced0cc1bac
commit
9a0aac4745
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user