MQTT-MAC-IP-mDNS (#1245)
This commit is contained in:
1 parent
1c62d74e56
commit
c4300a002f
21 files changed
+100
-100
No files matched your search
+7
-7
@@ -50,7 +50,7 @@
|
||||
*/
|
||||
/*-------------DEFINE GATEWAY NAME BELOW IT CAN ALSO BE DEFINED IN platformio.ini----------------*/
|
||||
|
||||
// Uncomment to use the mac address in the format of 112233445566 as the gateway name
|
||||
// Uncomment to use the MAC address in the format of 112233445566 as the gateway name
|
||||
// Any definition of Gateway_Name will be ignored. The Gateway_Short_name _ MAC will be used as the access point name.
|
||||
//#define USE_MAC_AS_GATEWAY_NAME
|
||||
#ifndef Gateway_Name
|
||||
@@ -69,7 +69,7 @@
|
||||
//#define NetworkAdvancedSetup true //uncomment if you want to set advanced network parameters, not uncommented you can set the IP and mac only
|
||||
#ifdef NetworkAdvancedSetup
|
||||
# if defined(ESP8266) || defined(ESP32)
|
||||
const byte ip[] = {192, 168, 1, 99}; //ip adress of the gateway, already defined for arduino below
|
||||
const byte ip[] = {192, 168, 1, 99}; //IP address of the gateway, already defined for arduino below
|
||||
# endif
|
||||
const byte gateway[] = {0, 0, 0, 0};
|
||||
const byte Dns[] = {0, 0, 0, 0};
|
||||
@@ -80,7 +80,7 @@ const byte subnet[] = {255, 255, 255, 0};
|
||||
//# define ESPWifiManualSetup true //uncomment you don't want to use wifimanager for your credential settings on ESP
|
||||
#else // for arduino boards
|
||||
const byte ip[] = {192, 168, 1, 99};
|
||||
const byte mac[] = {0xDE, 0xED, 0xBA, 0xFE, 0x54, 0x95}; //W5100 ethernet shield mac adress
|
||||
const byte mac[] = {0xDE, 0xED, 0xBA, 0xFE, 0x54, 0x95}; //W5100 ethernet shield MAC address
|
||||
#endif
|
||||
|
||||
//#define ESP32_ETHERNET=true // Uncomment to use Ethernet module on ESP32 Ethernet gateway and adapt the settings to your board below, the default parameter are for OLIMEX ESP32 Gateway
|
||||
@@ -132,10 +132,10 @@ const byte mac[] = {0xDE, 0xED, 0xBA, 0xFE, 0x54, 0x95}; //W5100 ethernet shield
|
||||
//#define WIFIMNG_HIDE_MQTT_CONFIG //Uncomment so as to hide MQTT setting from Wifi manager page
|
||||
|
||||
/*-------------DEFINE YOUR ADVANCED NETWORK PARAMETERS BELOW----------------*/
|
||||
//#define MDNS_SD //uncomment if you want to use mdns for discovering automatically your ip server, please note that MDNS with ESP32 can cause the BLE to not work
|
||||
//#define MDNS_SD //uncomment if you want to use mDNS for discovering automatically your IP server, please note that mDNS with ESP32 can cause the BLE to not work
|
||||
#define maxConnectionRetry 10 //maximum MQTT connection attempts before going to wifimanager setup if never connected once
|
||||
#define maxConnectionRetryWifi 5 //maximum Wifi connection attempts with existing credential at start (used to bypass ESP32 issue on wifi connect)
|
||||
#define maxRetryWatchDog 11 //maximum Wifi or mqtt re-connection attempts before restarting
|
||||
#define maxRetryWatchDog 11 //maximum Wifi or MQTT re-connection attempts before restarting
|
||||
|
||||
//set minimum quality of signal so it ignores AP's under that quality
|
||||
#define MinimumWifiSignalQuality 8
|
||||
@@ -199,7 +199,7 @@ const char* certificate PROGMEM = R"EOF("
|
||||
# define AWS_IOT false
|
||||
# endif
|
||||
|
||||
//# define MQTT_HTTPS_FW_UPDATE //uncomment to enable updating via mqtt message.
|
||||
//# define MQTT_HTTPS_FW_UPDATE //uncomment to enable updating via MQTT message.
|
||||
|
||||
# ifdef MQTT_HTTPS_FW_UPDATE
|
||||
// If used, this should be set to the root CA certificate of the server hosting the firmware.
|
||||
@@ -480,7 +480,7 @@ int lowpowermode = DEFAULT_LOW_POWER_MODE;
|
||||
#if defined(ZgatewayRF) || defined(ZgatewayIR) || defined(ZgatewaySRFB) || defined(ZgatewayWeatherStation)
|
||||
// variable to avoid duplicates
|
||||
# ifndef time_avoid_duplicate
|
||||
# define time_avoid_duplicate 3000 // if you want to avoid duplicate mqtt message received set this to > 0, the value is the time in milliseconds during which we don't publish duplicates
|
||||
# define time_avoid_duplicate 3000 // if you want to avoid duplicate MQTT message received set this to > 0, the value is the time in milliseconds during which we don't publish duplicates
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
+5
-5
@@ -96,7 +96,7 @@ int minRssi = abs(MinimumRSSI); //minimum rssi value
|
||||
void pubBTMainCore(JsonObject& data, bool haPresenceEnabled = true) {
|
||||
if (abs((int)data["rssi"] | 0) < minRssi && data.containsKey("id")) {
|
||||
String topic = data["id"].as<const char*>();
|
||||
topic.replace(":", ""); // Initially publish topic ends with mac address
|
||||
topic.replace(":", ""); // Initially publish topic ends with MAC address
|
||||
# if useBeaconUuidForTopic
|
||||
if (data.containsKey("model_id") && data["model_id"].as<String>() == "IBEACON")
|
||||
topic = data["uuid"].as<const char*>(); // If model_id is IBEACON, use uuid as topic
|
||||
@@ -454,7 +454,7 @@ void procBLETask(void* pvParameters) {
|
||||
}
|
||||
# endif
|
||||
|
||||
if ((!oneWhite || isWhite(device)) && !isBlack(device)) { //if not black listed mac we go AND if we have no white mac or this mac is white we go out
|
||||
if ((!oneWhite || isWhite(device)) && !isBlack(device)) { //if not black listed MAC we go AND if we have no white MAC or this MAC is white we go out
|
||||
if (advertisedDevice->haveName())
|
||||
BLEdata["name"] = (char*)advertisedDevice->getName().c_str();
|
||||
if (advertisedDevice->haveManufacturerData()) {
|
||||
@@ -487,7 +487,7 @@ void procBLETask(void* pvParameters) {
|
||||
PublishDeviceData(BLEdata); // PublishDeviceData has its own logic whether it needs to publish the json or not
|
||||
}
|
||||
} else {
|
||||
Log.trace(F("Filtered mac device" CR));
|
||||
Log.trace(F("Filtered MAC device" CR));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -827,9 +827,9 @@ bool BTtoMQTT() {
|
||||
BLEdevice* device = getDeviceByMac((char*)mac.c_str());
|
||||
|
||||
if (isBlack(device))
|
||||
return false; //if black listed mac we go out
|
||||
return false; //if black listed MAC we go out
|
||||
if (oneWhite && !isWhite(device))
|
||||
return false; //if we have at least one white mac and this mac is not white we go out
|
||||
return false; //if we have at least one white MAC and this MAC is not white we go out
|
||||
|
||||
BLEdata["rssi"] = (int)rssi;
|
||||
if (!publishOnlySensors && hassPresence)
|
||||
|
||||
+46
-46
@@ -4,7 +4,7 @@
|
||||
Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
|
||||
Send and receiving command by MQTT
|
||||
|
||||
This is the Home Assistant mqtt Discovery addon.
|
||||
This is the Home Assistant MQTT Discovery addon.
|
||||
|
||||
Copyright: (c) Rafal Herok
|
||||
|
||||
@@ -51,7 +51,7 @@ String getUniqueId(String name, String sufix) {
|
||||
/**
|
||||
* Create a discover messages form a list of attribute
|
||||
*
|
||||
* @param mac the mac adres
|
||||
* @param mac the MAC address
|
||||
* @param sensorList[][0] = component type
|
||||
* @param sensorList[][1] = name
|
||||
* @param sensorList[][2] = availability topic
|
||||
@@ -189,7 +189,7 @@ void announceDeviceTrigger(bool use_gateway_info, char* topic, char* type, char*
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Generate message and publish it on an mqtt discovery exploiter. For HA @see https://www.home-assistant.io/docs/mqtt/discovery/
|
||||
* @brief Generate message and publish it on an MQTT discovery exploiter. For HA @see https://www.home-assistant.io/docs/mqtt/discovery/
|
||||
*
|
||||
* @param sensor_type the Type
|
||||
* @param st_topic set state topic,
|
||||
@@ -209,7 +209,7 @@ void announceDeviceTrigger(bool use_gateway_info, char* topic, char* type, char*
|
||||
* @param device_name set device name,
|
||||
* @param device_manufacturer set device manufacturer,
|
||||
* @param device_model set device model,
|
||||
* @param device_mac set device mac,
|
||||
* @param device_mac set device MAC,
|
||||
* @param retainCmd set retain
|
||||
* @param state_class set state class
|
||||
*
|
||||
@@ -354,7 +354,7 @@ void pubMqttDiscovery() {
|
||||
Gateway_AnnouncementMsg, will_Message, "", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
createDiscovery("sensor", //set Type
|
||||
@@ -363,7 +363,7 @@ void pubMqttDiscovery() {
|
||||
"", "", "s", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
|
||||
@@ -374,7 +374,7 @@ void pubMqttDiscovery() {
|
||||
"", "", "B", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
createDiscovery("sensor", //set Type
|
||||
@@ -383,7 +383,7 @@ void pubMqttDiscovery() {
|
||||
"", "", "", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# ifndef ESP32_ETHERNET
|
||||
@@ -393,7 +393,7 @@ void pubMqttDiscovery() {
|
||||
"", "", "dB", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# endif
|
||||
@@ -405,7 +405,7 @@ void pubMqttDiscovery() {
|
||||
"", "", "", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5TOUGH)
|
||||
@@ -415,7 +415,7 @@ void pubMqttDiscovery() {
|
||||
"", "", "V", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a child device, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
createDiscovery("sensor", //set Type
|
||||
@@ -424,7 +424,7 @@ void pubMqttDiscovery() {
|
||||
"", "", "A", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a child device, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
createDiscovery("sensor", //set Type
|
||||
@@ -433,7 +433,7 @@ void pubMqttDiscovery() {
|
||||
"", "", "V", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a child device, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
createDiscovery("sensor", //set Type
|
||||
@@ -442,7 +442,7 @@ void pubMqttDiscovery() {
|
||||
"", "", "A", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a child device, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# endif
|
||||
@@ -453,7 +453,7 @@ void pubMqttDiscovery() {
|
||||
"", "", "%", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a child device, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
createDiscovery("binary_sensor", //set Type
|
||||
@@ -462,7 +462,7 @@ void pubMqttDiscovery() {
|
||||
"", "", "%", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a child device, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
createDiscovery("binary_sensor", //set Type
|
||||
@@ -471,7 +471,7 @@ void pubMqttDiscovery() {
|
||||
"", "", "%", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a child device, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# endif
|
||||
@@ -482,7 +482,7 @@ void pubMqttDiscovery() {
|
||||
"{\"cmd\":\"restart\"}", "", "", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoSYSset, //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
createDiscovery("switch", //set Type
|
||||
@@ -491,7 +491,7 @@ void pubMqttDiscovery() {
|
||||
"{\"cmd\":\"erase\"}", "", "", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoSYSset, //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
createDiscovery("switch", //set Type
|
||||
@@ -500,7 +500,7 @@ void pubMqttDiscovery() {
|
||||
"{\"discovery\":true}", "{\"discovery\":false}", "", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoSYSset, //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
|
||||
"", "", "", "", true, // device name, device manufacturer, device model, device mac, retain,
|
||||
"", "", "", "", true, // device name, device manufacturer, device model, device MAC, retain,
|
||||
stateClassNone //State Class
|
||||
);
|
||||
|
||||
@@ -523,7 +523,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, BMEsensor[i][3], BMEsensor[i][4],
|
||||
BMEsensor[i][5], BMEsensor[i][6], BMEsensor[i][7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
}
|
||||
@@ -545,7 +545,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, HTUsensor[i][3], HTUsensor[i][4],
|
||||
HTUsensor[i][5], HTUsensor[i][6], HTUsensor[i][7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
}
|
||||
@@ -566,7 +566,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, AHTsensor[i][3], AHTsensor[i][4],
|
||||
AHTsensor[i][5], AHTsensor[i][6], AHTsensor[i][7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
}
|
||||
@@ -588,7 +588,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, DHTsensor[i][3], DHTsensor[i][4],
|
||||
DHTsensor[i][5], DHTsensor[i][6], DHTsensor[i][7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
}
|
||||
@@ -605,7 +605,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, ADCsensor[3], ADCsensor[4],
|
||||
ADCsensor[5], ADCsensor[6], ADCsensor[7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# endif
|
||||
@@ -627,7 +627,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, BH1750sensor[i][3], BH1750sensor[i][4],
|
||||
BH1750sensor[i][5], BH1750sensor[i][6], BH1750sensor[i][7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
}
|
||||
@@ -650,7 +650,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, TSL2561sensor[i][3], TSL2561sensor[i][4],
|
||||
TSL2561sensor[i][5], TSL2561sensor[i][6], TSL2561sensor[i][7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
}
|
||||
@@ -667,7 +667,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, HCSR501sensor[3], HCSR501sensor[4],
|
||||
HCSR501sensor[5], HCSR501sensor[6], HCSR501sensor[7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# endif
|
||||
@@ -683,7 +683,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, GPIOInputsensor[3], GPIOInputsensor[4],
|
||||
GPIOInputsensor[5], GPIOInputsensor[6], GPIOInputsensor[7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# endif
|
||||
@@ -705,7 +705,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, INA226sensor[i][3], INA226sensor[i][4],
|
||||
INA226sensor[i][5], INA226sensor[i][6], INA226sensor[i][7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
}
|
||||
@@ -727,7 +727,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, actuatorONOFF[3], actuatorONOFF[4],
|
||||
actuatorONOFF[5], actuatorONOFF[6], actuatorONOFF[7],
|
||||
0, "", "", true, subjectMQTTtoONOFF,
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# endif
|
||||
@@ -744,7 +744,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, gatewayRF[3], gatewayRF[4],
|
||||
gatewayRF[5], gatewayRF[6], gatewayRF[7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
|
||||
@@ -762,7 +762,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, gatewayRF2[3], gatewayRF2[4],
|
||||
gatewayRF2[5], gatewayRF2[6], gatewayRF2[7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# endif
|
||||
@@ -779,7 +779,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, gatewayRFM69[3], gatewayRFM69[4],
|
||||
gatewayRFM69[5], gatewayRFM69[6], gatewayRFM69[7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# endif
|
||||
@@ -796,7 +796,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, gatewayLORA[3], gatewayLORA[4],
|
||||
gatewayLORA[5], gatewayLORA[6], gatewayLORA[7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# endif
|
||||
@@ -813,7 +813,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, gatewaySRFB[3], gatewaySRFB[4],
|
||||
gatewaySRFB[5], gatewaySRFB[6], gatewaySRFB[7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# endif
|
||||
@@ -830,7 +830,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, gatewayPilight[3], gatewayPilight[4],
|
||||
gatewayPilight[5], gatewayPilight[6], gatewayPilight[7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# endif
|
||||
@@ -847,7 +847,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, gatewayIR[3], gatewayIR[4],
|
||||
gatewayIR[5], gatewayIR[6], gatewayIR[7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# endif
|
||||
@@ -864,7 +864,7 @@ void pubMqttDiscovery() {
|
||||
will_Topic, gateway2G[3], gateway2G[4],
|
||||
gateway2G[5], gateway2G[6], gateway2G[7],
|
||||
0, "", "", true, "",
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# endif
|
||||
@@ -876,7 +876,7 @@ void pubMqttDiscovery() {
|
||||
"", "", "ms", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain,
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain,
|
||||
stateClassNone //State Class
|
||||
);
|
||||
createDiscovery("sensor", //set Type
|
||||
@@ -885,7 +885,7 @@ void pubMqttDiscovery() {
|
||||
"", "", "", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
createDiscovery("switch", //set Type
|
||||
@@ -894,7 +894,7 @@ void pubMqttDiscovery() {
|
||||
"{\"interval\":0}", "", "", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoBTset, //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
createDiscovery("switch", //set Type
|
||||
@@ -903,7 +903,7 @@ void pubMqttDiscovery() {
|
||||
"{\"onlysensors\":true}", "{\"onlysensors\":false}", "", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoBTset, //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
|
||||
"", "", "", "", true, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", true, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
createDiscovery("switch", //set Type
|
||||
@@ -912,7 +912,7 @@ void pubMqttDiscovery() {
|
||||
"{\"hasspresence\":true}", "{\"hasspresence\":false}", "", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoBTset, //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
|
||||
"", "", "", "", true, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", true, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# ifdef ESP32
|
||||
@@ -922,7 +922,7 @@ void pubMqttDiscovery() {
|
||||
"{\"lowpowermode\":2}", "{\"lowpowermode\":0}", "", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
"", "", true, subjectMQTTtoBTset, //set,payload_avalaible,payload_not avalaible,is a gateway entity, command topic
|
||||
"", "", "", "", true, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", true, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
createDiscovery("switch", //set Type
|
||||
@@ -931,7 +931,7 @@ void pubMqttDiscovery() {
|
||||
"{\"bleconnect\":true}", "{\"bleconnect\":false}", "", //set,payload_on,payload_off,unit_of_meas,
|
||||
0, //set off_delay
|
||||
Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoBTset, //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
|
||||
"", "", "", "", true, // device name, device manufacturer, device model, device mac, retain
|
||||
"", "", "", "", true, // device name, device manufacturer, device model, device MAC, retain
|
||||
stateClassNone //State Class
|
||||
);
|
||||
# endif
|
||||
|
||||
+2
-2
@@ -128,14 +128,14 @@ bool hassPresence = HassPresence;
|
||||
#endif
|
||||
|
||||
#ifndef useBeaconUuidForTopic
|
||||
# define useBeaconUuidForTopic false // define true to use iBeacon UUID as topic, instead of sender (random) mac address
|
||||
# define useBeaconUuidForTopic false // define true to use iBeacon UUID as topic, instead of sender (random) MAC address
|
||||
#endif
|
||||
|
||||
/*-------------------HOME ASSISTANT ROOM PRESENCE ----------------------*/
|
||||
#define subjectHomePresence "presence/" // will send Home Assistant room presence message to this topic (first part is same for all rooms, second is room name)
|
||||
|
||||
#ifndef useBeaconUuidForPresence
|
||||
# define useBeaconUuidForPresence false // //define true to use iBeacon UUID as for presence, instead of sender mac (random) address
|
||||
# define useBeaconUuidForPresence false // //define true to use iBeacon UUID as for presence, instead of sender MAC (random) address
|
||||
#endif
|
||||
|
||||
/*-------------------PIN DEFINITIONS----------------------*/
|
||||
|
||||
+2
-2
@@ -41,13 +41,13 @@ extern void MQTTtoIR(char* topicOri, JsonObject& RFdata);
|
||||
#define subjectMultiGTWIR "+/+/IRtoMQTT"
|
||||
#define IRbitsKey "IRBITS_" // bits will be defined if a subject contains IRbitsKey followed by a value of 2 digits
|
||||
#define IRRptKey "RPT_" // repeats will be defined if a subject contains IRRptKey followed by a value of 1 digit
|
||||
#define repeatIRwMQTT false // do we repeat a received signal by using mqtt, we send a command signal to subjectForwardMQTTtoIR
|
||||
#define repeatIRwMQTT false // do we repeat a received signal by using MQTT, we send a command signal to subjectForwardMQTTtoIR
|
||||
#define repeatIRwNumber 0 // default repeat of the signal
|
||||
//#define RawDirectForward false // direct repeat of IR signal with raw data
|
||||
#define RawFrequency 38 // raw frequency sending
|
||||
//#define DumpMode true // uncomment so as to see big dumps of IR codes
|
||||
|
||||
#define pubIRunknownPrtcl false // key to avoid mqtt publication of unknown IR protocol (set to true if you want to publish unknown protocol)
|
||||
#define pubIRunknownPrtcl false // key to avoid MQTT publication of unknown IR protocol (set to true if you want to publish unknown protocol)
|
||||
#define PanasonicAddress 0x4004 // Panasonic address (Pre data)
|
||||
|
||||
#if defined(ESP8266) || defined(ESP32) //IR supported protocols on ESP8266, all supported per default
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ int minimumRssi = 0;
|
||||
#define subjectMQTTtoPilightProtocol "/commands/MQTTtoPilight/protocols"
|
||||
#define subjectPilighttoMQTT "/PilighttoMQTT"
|
||||
#define subjectGTWPilighttoMQTT "/PilighttoMQTT"
|
||||
#define repeatPilightwMQTT false // do we repeat a received signal by using mqtt with Pilight gateway
|
||||
#define repeatPilightwMQTT false // do we repeat a received signal by using MQTT with Pilight gateway
|
||||
|
||||
/*-------------------RTL_433 topics & parameters----------------------*/
|
||||
//433Mhz RTL_433 MQTT Subjects and keys
|
||||
|
||||
@@ -33,7 +33,7 @@ extern void pubMqttDiscovery();
|
||||
/**
|
||||
* Create a discover messages form a list of attribute
|
||||
*
|
||||
* @param mac the mac adres
|
||||
* @param mac the MAC address
|
||||
* @param sensorList[][0] = component type
|
||||
* @param sensorList[][1] = name
|
||||
* @param sensorList[][2] = availability topic
|
||||
@@ -56,7 +56,7 @@ extern void createDiscoveryFromList(const char* mac,
|
||||
const char* device_model);
|
||||
|
||||
/**
|
||||
* @brief Generate message and publish it on an mqtt discovery exploiter. For HA @see https://www.home-assistant.io/docs/mqtt/discovery/
|
||||
* @brief Generate message and publish it on an MQTT discovery exploiter. For HA @see https://www.home-assistant.io/docs/mqtt/discovery/
|
||||
*
|
||||
* @param sensor_type the Type
|
||||
* @param st_topic set state topic,
|
||||
@@ -76,7 +76,7 @@ extern void createDiscoveryFromList(const char* mac,
|
||||
* @param device_name set device name,
|
||||
* @param device_manufacturer set device manufacturer,
|
||||
* @param device_model set device model,
|
||||
* @param device_mac set device mac,
|
||||
* @param device_mac set device MAC,
|
||||
* @param retainCmd set retain
|
||||
* @param state_class set state class
|
||||
*
|
||||
|
||||
+6
-6
@@ -239,7 +239,7 @@ ESP8266WiFiMulti wifiMulti;
|
||||
#define convertTemp_CtoF(c) ((c * 1.8) + 32)
|
||||
#define convertTemp_FtoC(f) ((f - 32) * 5 / 9)
|
||||
|
||||
// client link to pubsub mqtt
|
||||
// client link to pubsub MQTT
|
||||
PubSubClient client;
|
||||
|
||||
void revert_hex_data(const char* in, char* out, int l) {
|
||||
@@ -666,7 +666,7 @@ void setup() {
|
||||
client.setClient(*(Client*)eClient);
|
||||
|
||||
#if defined(MDNS_SD) && (defined(ESP8266) || defined(ESP32))
|
||||
Log.trace(F("Connecting to MQTT by mDNS without mqtt hostname" CR));
|
||||
Log.trace(F("Connecting to MQTT by mDNS without MQTT hostname" CR));
|
||||
connectMQTTmdns();
|
||||
#else
|
||||
uint16_t port = strtol(mqtt_port, NULL, 10);
|
||||
@@ -1013,7 +1013,7 @@ WiFiManager wifiManager;
|
||||
|
||||
//flag for saving data
|
||||
bool shouldSaveConfig = false;
|
||||
//do we have been connected once to mqtt
|
||||
//do we have been connected once to MQTT
|
||||
|
||||
//callback notifying us of the need to save config
|
||||
void saveConfigCallback() {
|
||||
@@ -1172,7 +1172,7 @@ void setup_wifimanager(bool reset_settings) {
|
||||
//set config save notify callback
|
||||
wifiManager.setSaveConfigCallback(saveConfigCallback);
|
||||
|
||||
//set static ip
|
||||
//set static IP
|
||||
# ifdef NetworkAdvancedSetup
|
||||
Log.trace(F("Adv wifi cfg" CR));
|
||||
IPAddress gateway_adress(gateway);
|
||||
@@ -1293,8 +1293,8 @@ void WiFiEvent(WiFiEvent_t event) {
|
||||
Log.notice(F("Ethernet Connected" CR));
|
||||
break;
|
||||
case SYSTEM_EVENT_ETH_GOT_IP:
|
||||
Log.trace(F("OpenMQTTGateway mac: %s" CR), ETH.macAddress().c_str());
|
||||
Log.trace(F("OpenMQTTGateway ip: %s" CR), ETH.localIP().toString().c_str());
|
||||
Log.trace(F("OpenMQTTGateway MAC: %s" CR), ETH.macAddress().c_str());
|
||||
Log.trace(F("OpenMQTTGateway IP: %s" CR), ETH.localIP().toString().c_str());
|
||||
Log.trace(F("OpenMQTTGateway link speed: %d Mbps" CR), ETH.linkSpeed());
|
||||
esp32EthConnected = true;
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user