only print DHT info when capability is set

This commit is contained in:
Ronald Schaten 2016-03-22 00:43:36 +01:00
parent 89ac7b2dc9
commit 9a57ab474b

View File

@ -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 += "&deg;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 += "&deg;C</td></tr>\r\n";
if (capability_dht) {
response += "<tr><td>Temperature</td><td>";
response += str_temperature;
response += "&deg;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 += "&deg;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);