From 34cd3e0450db70b8d6cf31d4b19abcc492a64d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Tue, 9 Jan 2018 20:36:38 +0100 Subject: [PATCH] Build with Thingspeak support, but only show it on webUI if there are relays or sensors available --- code/espurna/config/general.h | 2 +- code/espurna/thinkspeak.ino | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index a95e77df..5dc9e6dc 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -642,7 +642,7 @@ PROGMEM const char* const custom_reset_string[] = { // ----------------------------------------------------------------------------- #ifndef THINGSPEAK_SUPPORT -#define THINGSPEAK_SUPPORT 0 // Enable Thingspeak support by default (???Kb) +#define THINGSPEAK_SUPPORT 1 // Enable Thingspeak support by default (2.56Kb) #endif #define THINGSPEAK_ENABLED 0 // Thingspeak disabled by default diff --git a/code/espurna/thinkspeak.ino b/code/espurna/thinkspeak.ino index b1f9cae0..9c689005 100644 --- a/code/espurna/thinkspeak.ino +++ b/code/espurna/thinkspeak.ino @@ -34,7 +34,8 @@ unsigned long _tspk_last_flush = 0; void _tspkWebSocketOnSend(JsonObject& root) { - root["tspkVisible"] = 1; + unsigned char visible = 0; + root["tspkEnabled"] = getSetting("tspkEnabled", THINGSPEAK_ENABLED).toInt() == 1; root["tspkKey"] = getSetting("tspkKey"); @@ -42,6 +43,7 @@ void _tspkWebSocketOnSend(JsonObject& root) { for (byte i=0; i 0) visible = 1; #if SENSOR_SUPPORT JsonArray& list = root.createNestedArray("tspkMagnitudes"); @@ -52,8 +54,11 @@ void _tspkWebSocketOnSend(JsonObject& root) { element["index"] = magnitudeIndex(i); element["idx"] = getSetting("tspkMagnitude", i, 0).toInt(); } + if (magnitudeCount() > 0) visible = 1; #endif + root["tspkVisible"] = visible; + } void _tspkConfigure() {