Skip to content

Commit

Permalink
Enable to set Manufacturer and Model (#1336)
Browse files Browse the repository at this point in the history
from macros
  • Loading branch information
1technophile authored Nov 29, 2022
1 parent 8714141 commit 1458965
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
22 changes: 15 additions & 7 deletions main/ZmqttDiscovery.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion main/config_mqttDiscovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1458965

Please sign in to comment.