From a210d5462bd2c30fdc48c54b7ebe3c958c4476d6 Mon Sep 17 00:00:00 2001 From: DigiH Date: Sun, 2 Jul 2023 17:34:12 +0200 Subject: [PATCH] [WebUI] WebUI command fix (#1705) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • renamed command displaymetric to displayMetric for consistency with reported displayMetric • added WebUI to receivingMQTT to be able to receive commands --- docs/use/displays.md | 6 +++--- main/ZmqttDiscovery.ino | 8 ++++---- main/ZwebUI.ino | 6 +++--- main/main.ino | 3 +++ 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/use/displays.md b/docs/use/displays.md index 7997d6e..f820cee 100644 --- a/docs/use/displays.md +++ b/docs/use/displays.md @@ -5,7 +5,7 @@ Several options are available for the display of information on the SSD1306 disp The current SSD1306 display states are being published to the `SSD1306toMQTT` topic, e.g. -`{"onstate":true,"brightness":50,"displaymetric":true,"display-flip":true,"idlelogo":true,"log-oled":false,"json-oled":true}` +`{"onstate":true,"brightness":50,"display-flip":true,"idlelogo":true,"log-oled":false,"json-oled":true}` ### Display ON/OFF To turn the SSD1306 display on or off. @@ -36,9 +36,9 @@ To have applicable device properties displayed in Imperial units, e.g. °F for t This can be set with the compiler directive `-DDISPLAY_METRIC=false`. -or with the runtime command +As the display Metric setting is being defined in the WebUI part of OpenMQTTGateway changes need to be sent there with the runtime command -`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoSSD1306/config -m {"displaymetric":false}` +`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoWebUI/config -m {"displayMetric":false}` ### Rotating the display by 180 degrees diff --git a/main/ZmqttDiscovery.ino b/main/ZmqttDiscovery.ino index 7fa8601..7d96a1b 100644 --- a/main/ZmqttDiscovery.ino +++ b/main/ZmqttDiscovery.ino @@ -507,11 +507,11 @@ void pubMqttDiscovery() { "false", "true" //state_off, state_on ); createDiscovery("switch", //set Type - subjectSSD1306toMQTT, "SSD1306: Display metric", (char*)getUniqueId("displaymetric", "").c_str(), //set state_topic,name,uniqueId - will_Topic, "", "{{ value_json.displaymetric }}", //set availability_topic,device_class,value_template, - "{\"displaymetric\":true,\"save\":true}", "{\"displaymetric\":false,\"save\":true}", "", //set,payload_on,payload_off,unit_of_meas, + subjectWebUItoMQTT, "SSD1306: Display metric", (char*)getUniqueId("displayMetric", "").c_str(), //set state_topic,name,uniqueId + will_Topic, "", "{{ value_json.displayMetric }}", //set availability_topic,device_class,value_template, + "{\"displayMetric\":true,\"save\":true}", "{\"displayMetric\":false,\"save\":true}", "", //set,payload_on,payload_off,unit_of_meas, 0, //set off_delay - Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoSSD1306set, //set,payload_available,payload_not available ,is a gateway entity, command topic + Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoWebUIset, //set,payload_available,payload_not available ,is a gateway entity, command topic "", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain stateClassNone, //State Class "false", "true" //state_off, state_on diff --git a/main/ZwebUI.ino b/main/ZwebUI.ino index fe06912..eec5ba8 100644 --- a/main/ZwebUI.ino +++ b/main/ZwebUI.ino @@ -1307,9 +1307,9 @@ void MQTTtoWebUI(char* topicOri, JsonObject& WebUIdata) { // json object decodin if (cmpToMainTopic(topicOri, subjectMQTTtoWebUIset)) { WEBUI_TRACE_LOG(F("MQTTtoWebUI json set" CR)); // properties - if (WebUIdata.containsKey("displaymetric")) { - displayMetric = WebUIdata["displaymetric"].as(); - Log.notice(F("Set displaymetric: %T" CR), displayMetric); + if (WebUIdata.containsKey("displayMetric")) { + displayMetric = WebUIdata["displayMetric"].as(); + Log.notice(F("Set displayMetric: %T" CR), displayMetric); success = true; } // save, load, init, erase diff --git a/main/main.ino b/main/main.ino index 1f6616e..d2d0a41 100644 --- a/main/main.ino +++ b/main/main.ino @@ -2270,6 +2270,9 @@ void receivingMQTT(char* topicOri, char* datacallback) { # ifdef MQTT_HTTPS_FW_UPDATE MQTTHttpsFWUpdate(topicOri, jsondata); # endif +# ifdef ZwebUI + MQTTtoWebUI(topicOri, jsondata); +# endif #endif SendReceiveIndicatorON();