Skip to content

Commit

Permalink
WebUI command fix
Browse files Browse the repository at this point in the history
• renamed command displaymetric to displayMetric for consistency with reported displayMetric
• added WebUI to receivingMQTT to be able to receive commands
  • Loading branch information
DigiH committed Jun 30, 2023
1 parent 01a9cdf commit 215d0c4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
6 changes: 3 additions & 3 deletions docs/use/displays.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions main/ZmqttDiscovery.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions main/ZwebUI.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>();
Log.notice(F("Set displaymetric: %T" CR), displayMetric);
if (WebUIdata.containsKey("displayMetric")) {
displayMetric = WebUIdata["displayMetric"].as<bool>();
Log.notice(F("Set displayMetric: %T" CR), displayMetric);
success = true;
}
// save, load, init, erase
Expand Down
3 changes: 3 additions & 0 deletions main/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 215d0c4

Please sign in to comment.