Allow product information to be specified at build time

This allow people who make custom builds of WLED (Ex: QuinLED) to specify the details about the product at build time rather than having it hardcoded.
The default values of WLED are unchanged.
This commit is contained in:
Christophe Gagnier 2023-10-13 23:37:58 -04:00
parent 3847bfc41a
commit 426417a5c8
5 changed files with 21 additions and 8 deletions

View File

@ -98,8 +98,8 @@ private:
JsonObject device = doc.createNestedObject(F("device")); // attach the sensor to the same device
device[F("name")] = serverDescription;
device[F("identifiers")] = "wled-sensor-" + String(mqttClientID);
device[F("manufacturer")] = F("WLED");
device[F("model")] = F("FOSS");
device[F("manufacturer")] = WLED_BRAND;
device[F("model")] = WLED_PRODUCT_NAME;
device[F("sw_version")] = versionString;
String temp;

View File

@ -160,8 +160,8 @@ private:
JsonObject device = doc.createNestedObject(F("device")); // attach the sensor to the same device
device[F("name")] = serverDescription;
device[F("identifiers")] = "wled-sensor-" + String(mqttClientID);
device[F("manufacturer")] = F("WLED");
device[F("model")] = F("FOSS");
device[F("manufacturer")] = WLED_BRAND;
device[F("model")] = WLED_PRODUCT_NAME;
device[F("sw_version")] = versionString;
String temp;

View File

@ -299,8 +299,8 @@ void PIRsensorSwitch::publishHomeAssistantAutodiscovery()
JsonObject device = doc.createNestedObject(F("device")); // attach the sensor to the same device
device[F("name")] = serverDescription;
device[F("ids")] = String(F("wled-sensor-")) + mqttClientID;
device[F("mf")] = "WLED";
device[F("mdl")] = F("FOSS");
device[F("mf")] = WLED_BRAND;
device[F("mdl")] = WLED_PRODUCT_NAME;
device[F("sw")] = versionString;
sprintf_P(buf, PSTR("homeassistant/binary_sensor/%s/config"), uid);

View File

@ -785,8 +785,8 @@ void serializeInfo(JsonObject root)
#endif
root[F("opt")] = os;
root[F("brand")] = "WLED";
root[F("product")] = F("FOSS");
root[F("brand")] = WLED_BRAND;
root[F("product")] = WLED_PRODUCT_NAME;
root["mac"] = escapedMac;
char s[16] = "";
if (Network.isConnected())

View File

@ -10,6 +10,19 @@
// version code in format yymmddb (b = daily build)
#define VERSION 2310130
// You can define custom product info from build flags.
// This is useful to allow API consumer to identify what type of WLED version
// they are interacting with.
// Use like this:
// -D WLED_BRAND="F(\"Custom Brand\")"
// -D WLED_PRODUCT_NAME="F(\"Custom Product\")"
#ifndef WLED_BRAND
#define WLED_BRAND F("WLED")
#endif
#ifndef WLED_PRODUCT_NAME
#define WLED_PRODUCT_NAME F("FOSS")
#endif
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG