only print DHT info when capability is set
This commit is contained in:
parent
89ac7b2dc9
commit
9a57ab474b
30
things.ino
30
things.ino
@ -363,15 +363,17 @@ void setup() {
|
||||
response += "</h1>\r\n";
|
||||
response += "<h3>Sensor Status</h3>\r\n";
|
||||
response += "<table>\r\n";
|
||||
response += "<tr><td>Temperature</td><td>";
|
||||
response += str_temperature;
|
||||
response += "°C</td></tr>\r\n";
|
||||
response += "<tr><td>Humidity</td><td>";
|
||||
response += str_humidity;
|
||||
response += "%RH</td></tr>\r\n";
|
||||
response += "<tr><td>Heat Index</td><td>";
|
||||
response += str_heatindex;
|
||||
response += "°C</td></tr>\r\n";
|
||||
if (capability_dht) {
|
||||
response += "<tr><td>Temperature</td><td>";
|
||||
response += str_temperature;
|
||||
response += "°C</td></tr>\r\n";
|
||||
response += "<tr><td>Humidity</td><td>";
|
||||
response += str_humidity;
|
||||
response += "%RH</td></tr>\r\n";
|
||||
response += "<tr><td>Heat Index</td><td>";
|
||||
response += str_heatindex;
|
||||
response += "°C</td></tr>\r\n";
|
||||
}
|
||||
response += "</table>\r\n";
|
||||
response += "<form action=\"/\" method=\"get\"><button>Reload</button></form>\r\n";
|
||||
response += "</div>\r\n";
|
||||
@ -407,10 +409,12 @@ void setup() {
|
||||
mqtt["server"] = mqtt_server;
|
||||
mqtt["port"] = mqtt_port;
|
||||
mqtt["topic"] = mqtt_topic;
|
||||
JsonObject& dht = json.createNestedObject("dht");
|
||||
dht["temperature"] = str_temperature;
|
||||
dht["humidity"] = str_humidity;
|
||||
dht["heatindex"] = str_heatindex;
|
||||
if (capability_dht) {
|
||||
JsonObject& dht = json.createNestedObject("dht");
|
||||
dht["temperature"] = str_temperature;
|
||||
dht["humidity"] = str_humidity;
|
||||
dht["heatindex"] = str_heatindex;
|
||||
}
|
||||
String response;
|
||||
json.printTo(response);
|
||||
http_server.send(200, "text/plain", response);
|
||||
|
Loading…
Reference in New Issue
Block a user