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,6 +363,7 @@ void setup() {
response += "</h1>\r\n"; response += "</h1>\r\n";
response += "<h3>Sensor Status</h3>\r\n"; response += "<h3>Sensor Status</h3>\r\n";
response += "<table>\r\n"; response += "<table>\r\n";
if (capability_dht) {
response += "<tr><td>Temperature</td><td>"; response += "<tr><td>Temperature</td><td>";
response += str_temperature; response += str_temperature;
response += "&deg;C</td></tr>\r\n"; response += "&deg;C</td></tr>\r\n";
@ -372,6 +373,7 @@ void setup() {
response += "<tr><td>Heat Index</td><td>"; response += "<tr><td>Heat Index</td><td>";
response += str_heatindex; response += str_heatindex;
response += "&deg;C</td></tr>\r\n"; response += "&deg;C</td></tr>\r\n";
}
response += "</table>\r\n"; response += "</table>\r\n";
response += "<form action=\"/\" method=\"get\"><button>Reload</button></form>\r\n"; response += "<form action=\"/\" method=\"get\"><button>Reload</button></form>\r\n";
response += "</div>\r\n"; response += "</div>\r\n";
@ -407,10 +409,12 @@ void setup() {
mqtt["server"] = mqtt_server; mqtt["server"] = mqtt_server;
mqtt["port"] = mqtt_port; mqtt["port"] = mqtt_port;
mqtt["topic"] = mqtt_topic; mqtt["topic"] = mqtt_topic;
if (capability_dht) {
JsonObject& dht = json.createNestedObject("dht"); JsonObject& dht = json.createNestedObject("dht");
dht["temperature"] = str_temperature; dht["temperature"] = str_temperature;
dht["humidity"] = str_humidity; dht["humidity"] = str_humidity;
dht["heatindex"] = str_heatindex; dht["heatindex"] = str_heatindex;
}
String response; String response;
json.printTo(response); json.printTo(response);
http_server.send(200, "text/plain", response); http_server.send(200, "text/plain", response);