Enable to set Manufacturer and Model (#1336)

from macros
This commit is contained in:
Florian authored and GitHub committed 2022-11-29 10:48:00 -06:00
1 parent 8714141630
commit 145896516d
2 files changed
+18 -8

No files matched your search

+15 -7
View File
@@ -139,12 +139,16 @@ void announceDeviceTrigger(bool use_gateway_info, char* topic, char* type, char*
JsonArray identifiers = device.createNestedArray("identifiers");
if (use_gateway_info) {
char JSONmessageBuffer[JSON_MSG_BUFFER];
serializeJson(modules, JSONmessageBuffer, sizeof(JSONmessageBuffer));
device["name"] = gateway_name;
device["model"] = JSONmessageBuffer;
device["manufacturer"] = DEVICEMANUFACTURER;
# ifndef GATEWAY_MODEL
String model = "";
serializeJson(modules, model);
device["model"] = model;
# else
device["model"] = GATEWAY_MODEL;
# endif
device["manufacturer"] = GATEWAY_MANUFACTURER;
device["sw_version"] = OMG_VERSION;
identifiers.add(getMacAddress());
@@ -301,11 +305,15 @@ void createDiscovery(const char* sensor_type,
if (gateway_entity) {
//device representing the board
device["name"] = String(gateway_name);
# ifndef GATEWAY_MODEL
String model = "";
serializeJson(modules, model);
device["name"] = String(gateway_name);
device["model"] = model;
device["manufacturer"] = DEVICEMANUFACTURER;
# else
device["model"] = GATEWAY_MODEL;
# endif
device["manufacturer"] = GATEWAY_MANUFACTURER;
device["sw_version"] = OMG_VERSION;
identifiers.add(String(getMacAddress()));
} else {
+3 -1
View File
@@ -119,7 +119,9 @@ void announceDeviceTrigger(bool use_gateway_info,
# define discovery_republish_on_reconnect false
#endif
#define DEVICEMANUFACTURER "OMG_community"
#ifndef GATEWAY_MANUFACTURER
# define GATEWAY_MANUFACTURER "OMG_community"
#endif
/*-------------- Auto discovery macros-----------------*/
// Set the line below to true so as to have autodiscovery working with OpenHAB