Browse Source

Build with Thingspeak support, but only show it on webUI if there are relays or sensors available

i18n
Xose Pérez 6 years ago
parent
commit
34cd3e0450
2 changed files with 7 additions and 2 deletions
  1. +1
    -1
      code/espurna/config/general.h
  2. +6
    -1
      code/espurna/thinkspeak.ino

+ 1
- 1
code/espurna/config/general.h View File

@ -642,7 +642,7 @@ PROGMEM const char* const custom_reset_string[] = {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef THINGSPEAK_SUPPORT #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 #endif
#define THINGSPEAK_ENABLED 0 // Thingspeak disabled by default #define THINGSPEAK_ENABLED 0 // Thingspeak disabled by default


+ 6
- 1
code/espurna/thinkspeak.ino View File

@ -34,7 +34,8 @@ unsigned long _tspk_last_flush = 0;
void _tspkWebSocketOnSend(JsonObject& root) { void _tspkWebSocketOnSend(JsonObject& root) {
root["tspkVisible"] = 1;
unsigned char visible = 0;
root["tspkEnabled"] = getSetting("tspkEnabled", THINGSPEAK_ENABLED).toInt() == 1; root["tspkEnabled"] = getSetting("tspkEnabled", THINGSPEAK_ENABLED).toInt() == 1;
root["tspkKey"] = getSetting("tspkKey"); root["tspkKey"] = getSetting("tspkKey");
@ -42,6 +43,7 @@ void _tspkWebSocketOnSend(JsonObject& root) {
for (byte i=0; i<relayCount(); i++) { for (byte i=0; i<relayCount(); i++) {
relays.add(getSetting("tspkRelay", i, 0).toInt()); relays.add(getSetting("tspkRelay", i, 0).toInt());
} }
if (relayCount() > 0) visible = 1;
#if SENSOR_SUPPORT #if SENSOR_SUPPORT
JsonArray& list = root.createNestedArray("tspkMagnitudes"); JsonArray& list = root.createNestedArray("tspkMagnitudes");
@ -52,8 +54,11 @@ void _tspkWebSocketOnSend(JsonObject& root) {
element["index"] = magnitudeIndex(i); element["index"] = magnitudeIndex(i);
element["idx"] = getSetting("tspkMagnitude", i, 0).toInt(); element["idx"] = getSetting("tspkMagnitude", i, 0).toInt();
} }
if (magnitudeCount() > 0) visible = 1;
#endif #endif
root["tspkVisible"] = visible;
} }
void _tspkConfigure() { void _tspkConfigure() {


Loading…
Cancel
Save