[SYS][BREAKING] Optim json size (#1823)

This commit is contained in:
Florian authored and GitHub committed 2023-12-05 08:05:19 -06:00
1 parent 25af43bdeb
commit 5a07020144
6 files changed
+66 -66

No files matched your search

+1 -1
View File
@@ -78,7 +78,7 @@ You should see the gateway connected to your broker by checking with an MQTT cli
To make the auto discovery compatible with OpenHAB you have to send the following command with a retain flag. To make the auto discovery compatible with OpenHAB you have to send the following command with a retain flag.
`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"ohdiscovery":true}'` `mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"ohdisc":true}'`
## Adding the things ## Adding the things
1. From the Administration click on "Things" under "Settings", you should see a number in the INBOX button 1. From the Administration click on "Things" under "Settings", you should see a number in the INBOX button
+3 -3
View File
@@ -225,11 +225,11 @@ Or by an MQTT command.
To change presence publication topic, use this MQTT command: To change presence publication topic, use this MQTT command:
`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/config -m '{"presenceTopic":"presence/"}'` `mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/config -m '{"prestopic":"presence/"}'`
To use iBeacon UUID for presence, instead of sender (random) MAC address, use this MQTT command: To use iBeacon UUID for presence, instead of sender (random) MAC address, use this MQTT command:
`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/config -m '{"presenceUseBeaconUuid":true}'` `mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/config -m '{"presuseuuid":true}'`
This will change usual payload for iBeacon from: This will change usual payload for iBeacon from:
`{"id":"60:87:57:4C:9B:C2","mac_type":1,"rssi":-78,"distance":7.85288,"brand":"GENERIC","model":"iBeacon","model_id":"IBEACON","mfid":"4c00","uuid":"1de4b189115e45f6b44e509352269977","major":0,"minor":0,"txpower":-66}` `{"id":"60:87:57:4C:9B:C2","mac_type":1,"rssi":-78,"distance":7.85288,"brand":"GENERIC","model":"iBeacon","model_id":"IBEACON","mfid":"4c00","uuid":"1de4b189115e45f6b44e509352269977","major":0,"minor":0,"txpower":-66}`
@@ -250,7 +250,7 @@ home/OpenMQTTGateway/BTtoMQTT/5210A84690AC {"id":"52:10:A8:46:90:AC","mac_type":
To use iBeacon UUID as topic, use this MQTT command: To use iBeacon UUID as topic, use this MQTT command:
`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/config -m '{"pubBeaconUuidForTopic":true}'` `mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/config -m '{"pubuuid4topic":true}'`
Resulting in such messages (for the same iBeacon as previously): Resulting in such messages (for the same iBeacon as previously):
``` ```
+5 -5
View File
@@ -22,13 +22,13 @@ With Home Assistant, this command is directly available through MQTT auto discov
## Auto discovery ## Auto discovery
You can deactivate the MQTT auto discovery function, this function enables to automatically create devices/entities with Home Assistant convention. You can deactivate the MQTT auto discovery function, this function enables to automatically create devices/entities with Home Assistant convention.
### Deactivate ### Deactivate
`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"discovery":false}'` `mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"disc":false}'`
### Activate ### Activate
`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"discovery":true}'` `mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"disc":true}'`
If you want the settings to be kept upon gateway restart, you can save the state by adding `"save":true` (ESP32 only). If you want the settings to be kept upon gateway restart, you can save the state by adding `"save":true` (ESP32 only).
`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"discovery":false, "save":true}'` `mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"disc":false, "save":true}'`
::: tip ::: tip
Auto discovery is enable by default on release binaries, on platformio (except for UNO). With Arduino IDE please read the [advanced configuration section](../upload/advanced-configuration#auto-discovery) of the documentation. Auto discovery is enable by default on release binaries, on platformio (except for UNO). With Arduino IDE please read the [advanced configuration section](../upload/advanced-configuration#auto-discovery) of the documentation.
@@ -37,10 +37,10 @@ Auto discovery is enable by default on release binaries, on platformio (except f
## AutoDiscovery compatible with OpenHAB (default: false) ## AutoDiscovery compatible with OpenHAB (default: false)
OpenHAB does not support the key `is_defined` in the json template, to remove it at runtime and make the auto discovery compatible you can use the following command with a retain flag. OpenHAB does not support the key `is_defined` in the json template, to remove it at runtime and make the auto discovery compatible you can use the following command with a retain flag.
`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"ohdiscovery":true}'` `mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"ohdisc":true}'`
If you want the settings to be kept upon gateway restart, you can save the state by adding `"save":true` (ESP32 only). If you want the settings to be kept upon gateway restart, you can save the state by adding `"save":true` (ESP32 only).
`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"ohdiscovery":true, "save":true}'` `mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"ohdisc":true, "save":true}'`
::: tip ::: tip
This command can also be used with other controllers that does not support the is_defined key. This command can also be used with other controllers that does not support the is_defined key.
+15 -14
View File
@@ -122,21 +122,22 @@ String stateBTMeasures(bool start) {
jo["onlysensors"] = BTConfig.pubOnlySensors; jo["onlysensors"] = BTConfig.pubOnlySensors;
jo["randommacs"] = BTConfig.pubRandomMACs; jo["randommacs"] = BTConfig.pubRandomMACs;
jo["hasspresence"] = BTConfig.presenceEnable; jo["hasspresence"] = BTConfig.presenceEnable;
jo["presenceTopic"] = BTConfig.presenceTopic; jo["prestopic"] = BTConfig.presenceTopic;
jo["presenceUseBeaconUuid"] = BTConfig.presenceUseBeaconUuid; jo["presuseuuid"] = BTConfig.presenceUseBeaconUuid;
jo["minrssi"] = -abs(BTConfig.minRssi); // Always export as negative value jo["minrssi"] = -abs(BTConfig.minRssi); // Always export as negative value
jo["extDecoderEnable"] = BTConfig.extDecoderEnable; jo["extDecoderEnable"] = BTConfig.extDecoderEnable;
jo["extDecoderTopic"] = BTConfig.extDecoderTopic; jo["extDecoderTopic"] = BTConfig.extDecoderTopic;
jo["filterConnectable"] = BTConfig.filterConnectable; jo["filterConnectable"] = BTConfig.filterConnectable;
jo["pubadvdata"] = BTConfig.pubAdvData; jo["pubadvdata"] = BTConfig.pubAdvData;
jo["pubBeaconUuidForTopic"] = BTConfig.pubBeaconUuidForTopic; jo["pubuuid4topic"] = BTConfig.pubBeaconUuidForTopic;
jo["ignoreWBlist"] = BTConfig.ignoreWBlist; jo["ignoreWBlist"] = BTConfig.ignoreWBlist;
jo["presenceawaytimer"] = BTConfig.presenceAwayTimer; jo["presenceawaytimer"] = BTConfig.presenceAwayTimer;
jo["movingtimer"] = BTConfig.movingTimer; jo["movingtimer"] = BTConfig.movingTimer;
jo["forcepassivescan"] = BTConfig.forcePassiveScan; jo["forcepscn"] = BTConfig.forcePassiveScan;
jo["tskstck"] = uxTaskGetStackHighWaterMark(xProcBLETaskHandle);
jo["crstck"] = uxTaskGetStackHighWaterMark(xCoreTaskHandle);
jo["enabled"] = BTConfig.enabled; jo["enabled"] = BTConfig.enabled;
jo["bletaskstack"] = uxTaskGetStackHighWaterMark(xProcBLETaskHandle); jo["scnct"] = scanCount;
jo["blecoretaskstack"] = uxTaskGetStackHighWaterMark(xCoreTaskHandle);
if (start) { if (start) {
Log.notice(F("BT sys: ")); Log.notice(F("BT sys: "));
@@ -211,15 +212,15 @@ void BTConfig_fromJson(JsonObject& BTdata, bool startup = false) {
// publish devices which randomly change their MAC addresses // publish devices which randomly change their MAC addresses
Config_update(BTdata, "randommacs", BTConfig.pubRandomMACs); Config_update(BTdata, "randommacs", BTConfig.pubRandomMACs);
// Home Assistant presence message topic // Home Assistant presence message topic
Config_update(BTdata, "presenceTopic", BTConfig.presenceTopic); Config_update(BTdata, "prestopic", BTConfig.presenceTopic);
// Home Assistant presence message use iBeacon UUID // Home Assistant presence message use iBeacon UUID
Config_update(BTdata, "presenceUseBeaconUuid", BTConfig.presenceUseBeaconUuid); Config_update(BTdata, "presuseuuid", BTConfig.presenceUseBeaconUuid);
// Timer to trigger a device state as offline if not seen // Timer to trigger a device state as offline if not seen
Config_update(BTdata, "presenceawaytimer", BTConfig.presenceAwayTimer); Config_update(BTdata, "presenceawaytimer", BTConfig.presenceAwayTimer);
// Timer to trigger a device state as offline if not seen // Timer to trigger a device state as offline if not seen
Config_update(BTdata, "movingtimer", BTConfig.movingTimer); Config_update(BTdata, "movingtimer", BTConfig.movingTimer);
// Force passive scan // Force passive scan
Config_update(BTdata, "forcepassivescan", BTConfig.forcePassiveScan); Config_update(BTdata, "forcepscn", BTConfig.forcePassiveScan);
// MinRSSI set // MinRSSI set
Config_update(BTdata, "minrssi", BTConfig.minRssi); Config_update(BTdata, "minrssi", BTConfig.minRssi);
// Send undecoded device data // Send undecoded device data
@@ -231,7 +232,7 @@ void BTConfig_fromJson(JsonObject& BTdata, bool startup = false) {
// Publish advertisement data // Publish advertisement data
Config_update(BTdata, "pubadvdata", BTConfig.pubAdvData); Config_update(BTdata, "pubadvdata", BTConfig.pubAdvData);
// Use iBeacon UUID as topic, instead of sender (random) MAC address // Use iBeacon UUID as topic, instead of sender (random) MAC address
Config_update(BTdata, "pubBeaconUuidForTopic", BTConfig.pubBeaconUuidForTopic); Config_update(BTdata, "pubuuid4topic", BTConfig.pubBeaconUuidForTopic);
// Disable Whitelist & Blacklist // Disable Whitelist & Blacklist
Config_update(BTdata, "ignoreWBlist", (BTConfig.ignoreWBlist)); Config_update(BTdata, "ignoreWBlist", (BTConfig.ignoreWBlist));
// Enable or disable the BT gateway // Enable or disable the BT gateway
@@ -265,18 +266,18 @@ void BTConfig_fromJson(JsonObject& BTdata, bool startup = false) {
jo["onlysensors"] = BTConfig.pubOnlySensors; jo["onlysensors"] = BTConfig.pubOnlySensors;
jo["randommacs"] = BTConfig.pubRandomMACs; jo["randommacs"] = BTConfig.pubRandomMACs;
jo["hasspresence"] = BTConfig.presenceEnable; jo["hasspresence"] = BTConfig.presenceEnable;
jo["presenceTopic"] = BTConfig.presenceTopic; jo["prestopic"] = BTConfig.presenceTopic;
jo["presenceUseBeaconUuid"] = BTConfig.presenceUseBeaconUuid; jo["presuseuuid"] = BTConfig.presenceUseBeaconUuid;
jo["minrssi"] = -abs(BTConfig.minRssi); // Always export as negative value jo["minrssi"] = -abs(BTConfig.minRssi); // Always export as negative value
jo["extDecoderEnable"] = BTConfig.extDecoderEnable; jo["extDecoderEnable"] = BTConfig.extDecoderEnable;
jo["extDecoderTopic"] = BTConfig.extDecoderTopic; jo["extDecoderTopic"] = BTConfig.extDecoderTopic;
jo["filterConnectable"] = BTConfig.filterConnectable; jo["filterConnectable"] = BTConfig.filterConnectable;
jo["pubadvdata"] = BTConfig.pubAdvData; jo["pubadvdata"] = BTConfig.pubAdvData;
jo["pubBeaconUuidForTopic"] = BTConfig.pubBeaconUuidForTopic; jo["pubuuid4topic"] = BTConfig.pubBeaconUuidForTopic;
jo["ignoreWBlist"] = BTConfig.ignoreWBlist; jo["ignoreWBlist"] = BTConfig.ignoreWBlist;
jo["presenceawaytimer"] = BTConfig.presenceAwayTimer; jo["presenceawaytimer"] = BTConfig.presenceAwayTimer;
jo["movingtimer"] = BTConfig.movingTimer; jo["movingtimer"] = BTConfig.movingTimer;
jo["forcepassivescan"] = BTConfig.forcePassiveScan; jo["forcepscn"] = BTConfig.forcePassiveScan;
jo["enabled"] = BTConfig.enabled; jo["enabled"] = BTConfig.enabled;
// Save config into NVS (non-volatile storage) // Save config into NVS (non-volatile storage)
String conf = ""; String conf = "";
+13 -11
View File
@@ -497,9 +497,9 @@ void pubMqttDiscovery() {
stateClassNone //State Class stateClassNone //State Class
); );
createDiscovery("switch", //set Type createDiscovery("switch", //set Type
subjectSYStoMQTT, "SYS: Auto discovery", (char*)getUniqueId("discovery", "").c_str(), //set state_topic,name,uniqueId subjectSYStoMQTT, "SYS: Auto discovery", (char*)getUniqueId("disc", "").c_str(), //set state_topic,name,uniqueId
will_Topic, "", "{{ value_json.discovery }}", //set availability_topic,device_class,value_template, will_Topic, "", "{{ value_json.disc }}", //set availability_topic,device_class,value_template,
"{\"discovery\":true,\"save\":true}", "{\"discovery\":false,\"save\":true}", "", //set,payload_on,payload_off,unit_of_meas, "{\"disc\":true,\"save\":true}", "{\"disc\":false,\"save\":true}", "", //set,payload_on,payload_off,unit_of_meas,
0, //set off_delay 0, //set off_delay
Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoSYSset, //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic 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,
@@ -507,9 +507,9 @@ void pubMqttDiscovery() {
"false", "true" //state_off, state_on "false", "true" //state_off, state_on
); );
createDiscovery("switch", //set Type createDiscovery("switch", //set Type
subjectSYStoMQTT, "SYS: OpenHAB discovery", (char*)getUniqueId("ohdiscovery", "").c_str(), //set state_topic,name,uniqueId subjectSYStoMQTT, "SYS: OpenHAB discovery", (char*)getUniqueId("ohdisc", "").c_str(), //set state_topic,name,uniqueId
will_Topic, "", "{{ value_json.ohdiscovery }}", //set availability_topic,device_class,value_template, will_Topic, "", "{{ value_json.ohdisc }}", //set availability_topic,device_class,value_template,
"{\"ohdiscovery\":true,\"save\":true}", "{\"ohdiscovery\":false,\"save\":true}", "", //set,payload_on,payload_off,unit_of_meas, "{\"ohdisc\":true,\"save\":true}", "{\"ohdisc\":false,\"save\":true}", "", //set,payload_on,payload_off,unit_of_meas,
0, //set off_delay 0, //set off_delay
Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoSYSset, //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic 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,
@@ -518,9 +518,9 @@ void pubMqttDiscovery() {
); );
# ifdef RGB_INDICATORS # ifdef RGB_INDICATORS
createDiscovery("number", //set Type createDiscovery("number", //set Type
subjectSYStoMQTT, "SYS: LED Brightness", (char*)getUniqueId("rgbbrightness", "").c_str(), //set state_topic,name,uniqueId subjectSYStoMQTT, "SYS: LED Brightness", (char*)getUniqueId("rgbb", "").c_str(), //set state_topic,name,uniqueId
will_Topic, "", "{{ (value_json.rgbbrightness/2.55) | round(0) }}", //set availability_topic,device_class,value_template, will_Topic, "", "{{ (value_json.rgbb/2.55) | round(0) }}", //set availability_topic,device_class,value_template,
"{\"rgbbrightness\":{{ (value*2.55) | round(0) }},\"save\":true}", "", "", //set,payload_on,payload_off,unit_of_meas, "{\"rgbb\":{{ (value*2.55) | round(0) }},\"save\":true}", "", "", //set,payload_on,payload_off,unit_of_meas,
0, //set off_delay 0, //set off_delay
Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoSYSset, //set,payload_available,payload_not available ,is a gateway entity, command topic Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoSYSset, //set,payload_available,payload_not available ,is a gateway entity, command topic
"", "", "", "", false, // device name, device manufacturer, device model, device ID, retain, "", "", "", "", false, // device name, device manufacturer, device model, device ID, retain,
@@ -1227,7 +1227,7 @@ void pubMqttDiscovery() {
"false", "true" //state_off, state_on "false", "true" //state_off, state_on
); );
# define EntitiesCount 8 # define EntitiesCount 10
const char* obsoleteEntities[EntitiesCount][2] = { const char* obsoleteEntities[EntitiesCount][2] = {
// Remove previously created entities for version < 1.4.0 // Remove previously created entities for version < 1.4.0
{"switch", "active_scan"}, // Replaced by adaptive scan {"switch", "active_scan"}, // Replaced by adaptive scan
@@ -1238,7 +1238,9 @@ void pubMqttDiscovery() {
{"switch", "erase"}, // Now a button {"switch", "erase"}, // Now a button
{"switch", "force_scan"}, // Now a button {"switch", "force_scan"}, // Now a button
{"sensor", "interval"}, // Now a number {"sensor", "interval"}, // Now a number
{"sensor", "scanbcnct"}}; // Now a number {"sensor", "scanbcnct"}, // Now a number
{"switch", "ohdiscovery"}, // Now a new key
{"switch", "discovery"}}; // Now a new key
for (int i = 0; i < EntitiesCount; i++) { for (int i = 0; i < EntitiesCount; i++) {
eraseTopic(obsoleteEntities[i][0], (char*)getUniqueId(obsoleteEntities[i][1], "").c_str()); eraseTopic(obsoleteEntities[i][0], (char*)getUniqueId(obsoleteEntities[i][1], "").c_str());
+29 -32
View File
@@ -811,10 +811,10 @@ void SYSConfig_init() {
} }
void SYSConfig_fromJson(JsonObject& SYSdata) { void SYSConfig_fromJson(JsonObject& SYSdata) {
Config_update(SYSdata, "discovery", SYSConfig.discovery); Config_update(SYSdata, "disc", SYSConfig.discovery);
Config_update(SYSdata, "ohdiscovery", SYSConfig.ohdiscovery); Config_update(SYSdata, "ohdisc", SYSConfig.ohdiscovery);
# ifdef RGB_INDICATORS # ifdef RGB_INDICATORS
Config_update(SYSdata, "rgbbrightness", SYSConfig.rgbbrightness); Config_update(SYSdata, "rgbb", SYSConfig.rgbbrightness);
# endif # endif
} }
#else #else
@@ -2367,17 +2367,17 @@ void eraseAndRestart() {
#if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) #if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
String stateMeasures() { String stateMeasures() {
StaticJsonDocument<1024> SYSdata; StaticJsonDocument<JSON_MSG_BUFFER> SYSdata;
SYSdata["uptime"] = uptime(); SYSdata["uptime"] = uptime();
SYSdata["version"] = OMG_VERSION; SYSdata["version"] = OMG_VERSION;
# ifdef RGB_INDICATORS # ifdef RGB_INDICATORS
SYSdata["rgbbrightness"] = SYSConfig.rgbbrightness; SYSdata["rgbb"] = SYSConfig.rgbbrightness;
# endif # endif
# ifdef ZmqttDiscovery # ifdef ZmqttDiscovery
SYSdata["discovery"] = SYSConfig.discovery; SYSdata["disc"] = SYSConfig.discovery;
SYSdata["ohdiscovery"] = SYSConfig.ohdiscovery; SYSdata["ohdisc"] = SYSConfig.ohdiscovery;
# endif # endif
# if defined(ESP8266) || defined(ESP32) # if defined(ESP8266) || defined(ESP32)
SYSdata["env"] = ENV_NAME; SYSdata["env"] = ENV_NAME;
@@ -2392,22 +2392,21 @@ String stateMeasures() {
} }
# endif # endif
SYSdata["freemem"] = freeMem; SYSdata["freemem"] = freeMem;
SYSdata["mqttport"] = mqtt_port; SYSdata["mqttp"] = mqtt_port;
SYSdata["mqttsecure"] = mqtt_secure; SYSdata["mqtts"] = mqtt_secure;
SYSdata["msgproc"] = queueLengthSum; SYSdata["msgprc"] = queueLengthSum;
SYSdata["msgspeed"] = round2((float)queueLengthSum / uptime()); SYSdata["msgblck"] = blockedMessages;
SYSdata["msgblock"] = blockedMessages; SYSdata["maxq"] = maxQueueLength;
SYSdata["maxqueue"] = maxQueueLength;
# ifdef ESP32 # ifdef ESP32
minFreeMem = ESP.getMinFreeHeap(); minFreeMem = ESP.getMinFreeHeap();
SYSdata["minfreemem"] = minFreeMem; SYSdata["minmem"] = minFreeMem;
# ifndef NO_INT_TEMP_READING # ifndef NO_INT_TEMP_READING
SYSdata["tempc"] = intTemperatureRead(); SYSdata["tempc"] = round2(intTemperatureRead());
# endif # endif
SYSdata["freestack"] = uxTaskGetStackHighWaterMark(NULL); SYSdata["freestck"] = uxTaskGetStackHighWaterMark(NULL);
# endif # endif
SYSdata["ethernet"] = ethConnected; SYSdata["eth"] = ethConnected;
if (ethConnected) { if (ethConnected) {
# ifdef ESP32_ETHERNET # ifdef ESP32_ETHERNET
SYSdata["mac"] = (char*)ETH.macAddress().c_str(); SYSdata["mac"] = (char*)ETH.macAddress().c_str();
@@ -2428,9 +2427,6 @@ String stateMeasures() {
# ifdef ESP32 # ifdef ESP32
SYSdata["lowpowermode"] = (int)lowpowermode; SYSdata["lowpowermode"] = (int)lowpowermode;
# endif # endif
SYSdata["interval"] = BTConfig.BLEinterval;
SYSdata["intervalcnct"] = BTConfig.intervalConnect;
SYSdata["scnct"] = scanCount;
# endif # endif
# ifdef ZboardM5STACK # ifdef ZboardM5STACK
M5.Power.begin(); M5.Power.begin();
@@ -2468,6 +2464,7 @@ String stateMeasures() {
_modules.replace("\"", "'"); _modules.replace("\"", "'");
SYSdata["modules"] = _modules.c_str(); SYSdata["modules"] = _modules.c_str();
String output; String output;
serializeJson(SYSdata, output); serializeJson(SYSdata, output);
return output; return output;
@@ -2868,9 +2865,9 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
} }
} }
# ifdef RGB_INDICATORS # ifdef RGB_INDICATORS
if (SYSdata.containsKey("rgbbrightness") && SYSdata["rgbbrightness"].is<float>()) { if (SYSdata.containsKey("rgbb") && SYSdata["rgbb"].is<float>()) {
if (SYSdata["rgbbrightness"] >= 0 && SYSdata["rgbbrightness"] <= 255) { if (SYSdata["rgbb"] >= 0 && SYSdata["rgbb"] <= 255) {
SYSConfig.rgbbrightness = round2(SYSdata["rgbbrightness"]); SYSConfig.rgbbrightness = round2(SYSdata["rgbb"]);
leds.setBrightness(SYSConfig.rgbbrightness); leds.setBrightness(SYSConfig.rgbbrightness);
leds.show(); leds.show();
# ifdef ZactuatorONOFF # ifdef ZactuatorONOFF
@@ -2884,8 +2881,8 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
} }
# endif # endif
# ifdef ZmqttDiscovery # ifdef ZmqttDiscovery
if (SYSdata.containsKey("ohdiscovery") && SYSdata["ohdiscovery"].is<bool>()) { if (SYSdata.containsKey("ohdisc") && SYSdata["ohdisc"].is<bool>()) {
SYSConfig.ohdiscovery = SYSdata["ohdiscovery"]; SYSConfig.ohdiscovery = SYSdata["ohdisc"];
Log.notice(F("OpenHAB discovery: %T" CR), SYSConfig.ohdiscovery); Log.notice(F("OpenHAB discovery: %T" CR), SYSConfig.ohdiscovery);
stateMeasures(); stateMeasures();
} }
@@ -3046,11 +3043,11 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
#endif #endif
#ifdef ZmqttDiscovery #ifdef ZmqttDiscovery
if (SYSdata.containsKey("discovery")) { if (SYSdata.containsKey("disc")) {
if (SYSdata["discovery"].is<bool>()) { if (SYSdata["disc"].is<bool>()) {
if (SYSdata["discovery"] == true && SYSConfig.discovery == false) if (SYSdata["disc"] == true && SYSConfig.discovery == false)
lastDiscovery = millis(); lastDiscovery = millis();
SYSConfig.discovery = SYSdata["discovery"]; SYSConfig.discovery = SYSdata["disc"];
stateMeasures(); stateMeasures();
if (SYSConfig.discovery) if (SYSConfig.discovery)
pubMqttDiscovery(); pubMqttDiscovery();
@@ -3063,10 +3060,10 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
if (SYSdata.containsKey("save") && SYSdata["save"].as<bool>()) { if (SYSdata.containsKey("save") && SYSdata["save"].as<bool>()) {
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer; StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
JsonObject jo = jsonBuffer.to<JsonObject>(); JsonObject jo = jsonBuffer.to<JsonObject>();
jo["discovery"] = SYSConfig.discovery; jo["disc"] = SYSConfig.discovery;
jo["ohdiscovery"] = SYSConfig.ohdiscovery; jo["ohdisc"] = SYSConfig.ohdiscovery;
# ifdef RGB_INDICATORS # ifdef RGB_INDICATORS
jo["rgbbrightness"] = SYSConfig.rgbbrightness; jo["rgbb"] = SYSConfig.rgbbrightness;
# endif # endif
// Save config into NVS (non-volatile storage) // Save config into NVS (non-volatile storage)
String conf = ""; String conf = "";