valueAsASubject to valueAsATopic inconsistency fix (#1260)
This commit is contained in:
1 parent
312ef858c1
commit
b16fbcbef2
6 files changed
+13
-10
No files matched your search
@@ -32,10 +32,12 @@ You can know compile and upload to your board and the gateway should connect wit
|
|||||||
|
|
||||||
## Add the received "value" at the end of the topic
|
## Add the received "value" at the end of the topic
|
||||||
For the gateways that publish a "value" parameter on the json (RF, IR...), it is possible to concatenate this parameter at the end of the topic.
|
For the gateways that publish a "value" parameter on the json (RF, IR...), it is possible to concatenate this parameter at the end of the topic.
|
||||||
So as to activate this function you need to uncomment the line below in User_config.h
|
So as to activate this function you need to set `valueAsATopic` to true in User_config.h
|
||||||
|
|
||||||
``` cpp
|
``` cpp
|
||||||
//#define valueAsASubject true
|
#ifndef valueAsATopic
|
||||||
|
# define valueAsATopic false // define true to integrate msg value into the subject when receiving
|
||||||
|
#endif
|
||||||
```
|
```
|
||||||
|
|
||||||
Per default you see the following data:
|
Per default you see the following data:
|
||||||
|
|||||||
+3
-2
@@ -456,8 +456,9 @@ int lowpowermode = DEFAULT_LOW_POWER_MODE;
|
|||||||
#define eraseCmd "erase"
|
#define eraseCmd "erase"
|
||||||
#define statusCmd "status"
|
#define statusCmd "status"
|
||||||
|
|
||||||
// uncomment the line below to integrate msg value into the subject when receiving
|
#ifndef valueAsATopic
|
||||||
//#define valueAsASubject true
|
# define valueAsATopic false // define true to integrate msg value into the subject when receiving
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
# define JSON_MSG_BUFFER 768
|
# define JSON_MSG_BUFFER 768
|
||||||
|
|||||||
+1
-1
@@ -89,7 +89,7 @@ void RFtoMQTTdiscovery(SIGNAL_SIZE_UL_ULL MQTTvalue) {
|
|||||||
Log.trace(F("RF Entity Discovered, create HA Discovery CFG" CR));
|
Log.trace(F("RF Entity Discovered, create HA Discovery CFG" CR));
|
||||||
char* switchRF[2] = {val, "RF"};
|
char* switchRF[2] = {val, "RF"};
|
||||||
Log.trace(F("CreateDiscoverySwitch: %s" CR), switchRF[1]);
|
Log.trace(F("CreateDiscoverySwitch: %s" CR), switchRF[1]);
|
||||||
# ifdef valueAsASubject
|
# if valueAsATopic
|
||||||
String discovery_topic = String(subjectRFtoMQTT) + "/" + String(switchRF[0]);
|
String discovery_topic = String(subjectRFtoMQTT) + "/" + String(switchRF[0]);
|
||||||
# else
|
# else
|
||||||
String discovery_topic = String(subjectRFtoMQTT);
|
String discovery_topic = String(subjectRFtoMQTT);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ void rtl_433_Callback(char* message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String topic = String(subjectRTL_433toMQTT);
|
String topic = String(subjectRTL_433toMQTT);
|
||||||
# ifdef valueAsASubject
|
# if valueAsATopic
|
||||||
String model = RFrtl_433_ESPdata["model"];
|
String model = RFrtl_433_ESPdata["model"];
|
||||||
String id = RFrtl_433_ESPdata["id"];
|
String id = RFrtl_433_ESPdata["id"];
|
||||||
if (model != 0) {
|
if (model != 0) {
|
||||||
|
|||||||
+2
-2
@@ -313,7 +313,7 @@ void pub(const char* topicori, JsonObject& data) {
|
|||||||
Log.notice(F("Send on %s msg %s" CR), topicori, dataAsString.c_str());
|
Log.notice(F("Send on %s msg %s" CR), topicori, dataAsString.c_str());
|
||||||
digitalWrite(LED_SEND_RECEIVE, LED_SEND_RECEIVE_ON);
|
digitalWrite(LED_SEND_RECEIVE, LED_SEND_RECEIVE_ON);
|
||||||
String topic = String(mqtt_topic) + String(gateway_name) + String(topicori);
|
String topic = String(mqtt_topic) + String(gateway_name) + String(topicori);
|
||||||
#ifdef valueAsASubject
|
#if valueAsATopic
|
||||||
# ifdef ZgatewayPilight
|
# ifdef ZgatewayPilight
|
||||||
String value = data["value"];
|
String value = data["value"];
|
||||||
String protocol = data["protocol"];
|
String protocol = data["protocol"];
|
||||||
@@ -2100,7 +2100,7 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(valueAsASubject) && !defined(ZgatewayPilight)
|
#if valueAsATopic && !defined(ZgatewayPilight)
|
||||||
# if defined(ESP32) || defined(ESP8266) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
|
# if defined(ESP32) || defined(ESP8266) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
|
||||||
String toString(uint64_t input) {
|
String toString(uint64_t input) {
|
||||||
String result = "";
|
String result = "";
|
||||||
|
|||||||
+2
-2
@@ -760,7 +760,7 @@ build_flags =
|
|||||||
'-DZradioCC1101="CC1101"'
|
'-DZradioCC1101="CC1101"'
|
||||||
'-DZgatewayRTL_433="rtl_433"'
|
'-DZgatewayRTL_433="rtl_433"'
|
||||||
'-DGateway_Name="OpenMQTTGateway_rtl_433_ESP"'
|
'-DGateway_Name="OpenMQTTGateway_rtl_433_ESP"'
|
||||||
'-DvalueAsASubject=true' ; MQTT topic includes model and device
|
'-DvalueAsATopic=true' ; MQTT topic includes model and device
|
||||||
; '-DPUBLISH_UNPARSED=true' ; Publish details of undecoded signals
|
; '-DPUBLISH_UNPARSED=true' ; Publish details of undecoded signals
|
||||||
; '-DRTL_DEBUG=4' ; enable rtl_433 verbose device decode
|
; '-DRTL_DEBUG=4' ; enable rtl_433 verbose device decode
|
||||||
|
|
||||||
@@ -784,7 +784,7 @@ build_flags =
|
|||||||
'-DZgatewayPilight="Pilight"'
|
'-DZgatewayPilight="Pilight"'
|
||||||
'-DZradioCC1101="CC1101"'
|
'-DZradioCC1101="CC1101"'
|
||||||
'-DGateway_Name="OpenMQTTGateway_multi_receiver"'
|
'-DGateway_Name="OpenMQTTGateway_multi_receiver"'
|
||||||
'-DvalueAsASubject=true' ; MQTT topic includes model and device (rtl_433) or protocol and id ( RF and PiLight )
|
'-DvalueAsATopic=true' ; MQTT topic includes model and device (rtl_433) or protocol and id (RF and PiLight)
|
||||||
; '-DDEFAULT_RECEIVER=1' ; Default receiver to enable on startup
|
; '-DDEFAULT_RECEIVER=1' ; Default receiver to enable on startup
|
||||||
|
|
||||||
[env:tinypico-ble]
|
[env:tinypico-ble]
|
||||||
|
|||||||
Reference in new issue
Block a user