mirror of
https://github.com/1technophile/OpenMQTTGateway.git
synced 2026-03-05 23:14:26 +01:00
valueAsASubject to valueAsATopic inconsistency fix (#1260)
This commit is contained in:
@@ -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
|
||||
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
|
||||
//#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:
|
||||
|
||||
@@ -456,8 +456,9 @@ int lowpowermode = DEFAULT_LOW_POWER_MODE;
|
||||
#define eraseCmd "erase"
|
||||
#define statusCmd "status"
|
||||
|
||||
// uncomment the line below to integrate msg value into the subject when receiving
|
||||
//#define valueAsASubject true
|
||||
#ifndef valueAsATopic
|
||||
# define valueAsATopic false // define true to integrate msg value into the subject when receiving
|
||||
#endif
|
||||
|
||||
#if defined(ESP32)
|
||||
# define JSON_MSG_BUFFER 768
|
||||
|
||||
@@ -89,7 +89,7 @@ void RFtoMQTTdiscovery(SIGNAL_SIZE_UL_ULL MQTTvalue) {
|
||||
Log.trace(F("RF Entity Discovered, create HA Discovery CFG" CR));
|
||||
char* switchRF[2] = {val, "RF"};
|
||||
Log.trace(F("CreateDiscoverySwitch: %s" CR), switchRF[1]);
|
||||
# ifdef valueAsASubject
|
||||
# if valueAsATopic
|
||||
String discovery_topic = String(subjectRFtoMQTT) + "/" + String(switchRF[0]);
|
||||
# else
|
||||
String discovery_topic = String(subjectRFtoMQTT);
|
||||
|
||||
@@ -50,7 +50,7 @@ void rtl_433_Callback(char* message) {
|
||||
}
|
||||
|
||||
String topic = String(subjectRTL_433toMQTT);
|
||||
# ifdef valueAsASubject
|
||||
# if valueAsATopic
|
||||
String model = RFrtl_433_ESPdata["model"];
|
||||
String id = RFrtl_433_ESPdata["id"];
|
||||
if (model != 0) {
|
||||
|
||||
@@ -313,7 +313,7 @@ void pub(const char* topicori, JsonObject& data) {
|
||||
Log.notice(F("Send on %s msg %s" CR), topicori, dataAsString.c_str());
|
||||
digitalWrite(LED_SEND_RECEIVE, LED_SEND_RECEIVE_ON);
|
||||
String topic = String(mqtt_topic) + String(gateway_name) + String(topicori);
|
||||
#ifdef valueAsASubject
|
||||
#if valueAsATopic
|
||||
# ifdef ZgatewayPilight
|
||||
String value = data["value"];
|
||||
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__)
|
||||
String toString(uint64_t input) {
|
||||
String result = "";
|
||||
|
||||
@@ -760,7 +760,7 @@ build_flags =
|
||||
'-DZradioCC1101="CC1101"'
|
||||
'-DZgatewayRTL_433="rtl_433"'
|
||||
'-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
|
||||
; '-DRTL_DEBUG=4' ; enable rtl_433 verbose device decode
|
||||
|
||||
@@ -784,7 +784,7 @@ build_flags =
|
||||
'-DZgatewayPilight="Pilight"'
|
||||
'-DZradioCC1101="CC1101"'
|
||||
'-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
|
||||
|
||||
[env:tinypico-ble]
|
||||
|
||||
Reference in New Issue
Block a user