From 9a57ab474bc3c01820ed85f2b1719335583eded2 Mon Sep 17 00:00:00 2001 From: Ronald Schaten Date: Tue, 22 Mar 2016 00:43:36 +0100 Subject: [PATCH] only print DHT info when capability is set --- things.ino | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/things.ino b/things.ino index 055b2d0..340aa4b 100644 --- a/things.ino +++ b/things.ino @@ -363,15 +363,17 @@ void setup() { response += "\r\n"; response += "

Sensor Status

\r\n"; response += "\r\n"; - response += "\r\n"; - response += "\r\n"; - response += "\r\n"; + if (capability_dht) { + response += "\r\n"; + response += "\r\n"; + response += "\r\n"; + } response += "
Temperature"; - response += str_temperature; - response += "°C
Humidity"; - response += str_humidity; - response += "%RH
Heat Index"; - response += str_heatindex; - response += "°C
Temperature"; + response += str_temperature; + response += "°C
Humidity"; + response += str_humidity; + response += "%RH
Heat Index"; + response += str_heatindex; + response += "°C
\r\n"; response += "
\r\n"; response += "\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);