Mqtt discovery (#320)

* add mqtt discovery (compatibile with home assistant) with omg status binary sensor & bme280 sensor

* added mqtt discovery to Test_config.h for ESP32 (ESP8266 & other boards was not tested)

* include support for ESP8266 & arduino mega

* fix getting MAC for esp8266

* esp8266 fix

* make mqtt discovery functions functions more generic, readable and easy to use & extend

* make mqtt discovery functions functions more generic, readable and easy to use & extend PART 2

* remove the macro for each attribute and supposing that if there is a bme280 we expose all
This commit is contained in:
Florian authored and GitHub committed 2018-11-28 21:25:27 +01:00
1 parent 67dd7ac078
commit 81c02c850e
5 files changed
+218 -5

No files matched your search

+12 -1
View File
@@ -133,6 +133,9 @@
#ifdef ZsensorGPIOKeyCode
#include "config_GPIOKeyCode.h"
#endif
#ifdef ZmqttDiscovery
#include "config_mqttDiscovery.h"
#endif
/*------------------------------------------------------------------------*/
@@ -193,7 +196,7 @@ void saveConfigCallback () {
}
boolean reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
trc(F("MQTT connection...")); //F function enable to decrease sram usage
@@ -204,6 +207,11 @@ boolean reconnect() {
pub(will_Topic,Gateway_AnnouncementMsg,will_Retain);
// publish version
pub(version_Topic,OMG_VERSION,will_Retain);
//home assistant discovery
#ifdef ZmqttDiscovery
pubMqttDiscovery();
#endif
//Subscribing to topic
if (client.subscribe(subjectMQTTtoX)) {
#ifdef ZgatewayRF
@@ -783,6 +791,9 @@ void stateMeasures(){
#ifdef ZsensorGPIOKeyCode
modules = modules + ZsensorGPIOKeyCode;
#endif
#ifdef ZmqttDiscovery
modules = modules + ZmqttDiscovery;
#endif
SYSdata["modules"] = modules;
trc(modules);
char JSONmessageBuffer[100];