diff --git a/code/espurna/scheduler.ino b/code/espurna/scheduler.ino index 64c578a8..c5f3bebf 100644 --- a/code/espurna/scheduler.ino +++ b/code/espurna/scheduler.ino @@ -17,20 +17,25 @@ Adapted by Xose PĂ©rez void _schWebSocketOnSend(JsonObject &root){ - root["schVisible"] = 1; - root["maxSchedules"] = SCHEDULER_MAX_SCHEDULES; - JsonArray &sch = root.createNestedArray("schedule"); - for (byte i = 0; i < SCHEDULER_MAX_SCHEDULES; i++) { - if (!hasSetting("schSwitch", i)) break; - JsonObject &scheduler = sch.createNestedObject(); - scheduler["schEnabled"] = getSetting("schEnabled", i, 1).toInt() == 1; - scheduler["schSwitch"] = getSetting("schSwitch", i, 0).toInt(); - scheduler["schAction"] = getSetting("schAction", i, 0).toInt(); - scheduler["schType"] = getSetting("schType", i, 0).toInt(); - scheduler["schHour"] = getSetting("schHour", i, 0).toInt(); - scheduler["schMinute"] = getSetting("schMinute", i, 0).toInt(); - scheduler["schWDs"] = getSetting("schWDs", i, ""); + if (relayCount() > 0) { + + root["schVisible"] = 1; + root["maxSchedules"] = SCHEDULER_MAX_SCHEDULES; + JsonArray &sch = root.createNestedArray("schedule"); + for (byte i = 0; i < SCHEDULER_MAX_SCHEDULES; i++) { + if (!hasSetting("schSwitch", i)) break; + JsonObject &scheduler = sch.createNestedObject(); + scheduler["schEnabled"] = getSetting("schEnabled", i, 1).toInt() == 1; + scheduler["schSwitch"] = getSetting("schSwitch", i, 0).toInt(); + scheduler["schAction"] = getSetting("schAction", i, 0).toInt(); + scheduler["schType"] = getSetting("schType", i, 0).toInt(); + scheduler["schHour"] = getSetting("schHour", i, 0).toInt(); + scheduler["schMinute"] = getSetting("schMinute", i, 0).toInt(); + scheduler["schWDs"] = getSetting("schWDs", i, ""); + } + } + } #endif // WEB_SUPPORT