Browse Source

Option to disable schedules without delting them (#453)

i18n
Xose Pérez 7 years ago
parent
commit
f7295859c3
5 changed files with 2286 additions and 2275 deletions
  1. BIN
      code/espurna/data/index.html.gz
  2. +13
    -6
      code/espurna/scheduler.ino
  3. +2264
    -2262
      code/espurna/static/index.html.gz.h
  4. +3
    -4
      code/html/custom.js
  5. +6
    -3
      code/html/index.html

BIN
code/espurna/data/index.html.gz View File


+ 13
- 6
code/espurna/scheduler.ino View File

@ -22,10 +22,11 @@ void _schWebSocketOnSend(JsonObject &root){
for (byte i = 0; i < SCHEDULER_MAX_SCHEDULES; i++) {
if (!hasSetting("schSwitch", i)) break;
JsonObject &scheduler = sch.createNestedObject();
scheduler["schSwitch"] = getSetting("schSwitch", i, "");
scheduler["schAction"] = getSetting("schAction", i, "");
scheduler["schHour"] = getSetting("schHour", i, "");
scheduler["schMinute"] = getSetting("schMinute", i, "");
scheduler["schEnabled"] = getSetting("schEnabled", i, 1).toInt() == 1;
scheduler["schSwitch"] = getSetting("schSwitch", i, 0).toInt();
scheduler["schAction"] = getSetting("schAction", i, 0).toInt();
scheduler["schHour"] = getSetting("schHour", i, 0).toInt();
scheduler["schMinute"] = getSetting("schMinute", i, 0).toInt();
scheduler["schWDs"] = getSetting("schWDs", i, "");
}
}
@ -45,6 +46,7 @@ void _schConfigure() {
if (delete_flag) {
delSetting("schEnabled", i);
delSetting("schSwitch", i);
delSetting("schAction", i);
delSetting("schHour", i);
@ -55,14 +57,16 @@ void _schConfigure() {
#if DEBUG_SUPPORT
int sch_enabled = getSetting("schEnabled", i, 1).toInt() == 1;
int sch_action = getSetting("schAction", i, 0).toInt();
int sch_hour = getSetting("schHour", i, 0).toInt();
int sch_minute = getSetting("schMinute", i, 0).toInt();
String sch_weekdays = getSetting("schWDs", i, "");
DEBUG_MSG_P(
PSTR("[SCH] Schedule #%d: %s switch #%d at %02d:%02d on %s\n"),
PSTR("[SCH] Schedule #%d: %s switch #%d at %02d:%02d on %s%s\n"),
i, sch_action == 0 ? "turn OFF" : sch_action == 1 ? "turn ON" : "toggle", sch_switch,
sch_hour, sch_minute, (char *) sch_weekdays.c_str()
sch_hour, sch_minute, (char *) sch_weekdays.c_str(),
sch_enabled ? "" : " (disabled)"
);
#endif // DEBUG_SUPPORT
@ -104,6 +108,9 @@ void _schCheck() {
int sch_switch = getSetting("schSwitch", i, 0xFF).toInt();
if (sch_switch == 0xFF) break;
// Skip disabled schedules
if (getSetting("schEnabled", i, 1).toInt() == 0) continue;
String sch_weekdays = getSetting("schWDs", i, "");
if (_schIsThisWeekday(sch_weekdays)) {


+ 2264
- 2262
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


+ 3
- 4
code/html/custom.js View File

@ -151,7 +151,7 @@ function validateForm(form) {
// These fields will always be a list of values
var is_group = [
"ssid", "pass", "gw", "mask", "ip", "dns",
"schSwitch","schAction","schHour","schMinute","schWDs",
"schEnabled", "schSwitch","schAction","schHour","schMinute","schWDs",
"relayBoot", "relayPulse", "relayTime",
"mqttGroup", "mqttGroupInv",
"dczRelayIdx", "dczMagnitude",
@ -1001,6 +1001,7 @@ function processData(data) {
Object.keys(schedule).forEach(function(key) {
$("input[name='" + key + "']", line).val(schedule[key]);
$("select[name='" + key + "']", line).prop("value", schedule[key]);
$(":checkbox", line).prop("checked", schedule[key]);
});
}
return;
@ -1246,9 +1247,7 @@ $(function() {
$(".button-add-network").on("click", function() {
$(".more", addNetwork()).toggle();
});
$(".button-add-schedule").on("click", function() {
$("div.more", addSchedule()).toggle();
});
$(".button-add-schedule").on("click", addSchedule);
$(document).on("change", "input", hasChanged);
$(document).on("change", "select", hasChanged);


+ 6
- 3
code/html/index.html View File

@ -1083,11 +1083,11 @@
<label class="pure-u-1 pure-u-lg-1-4">When time is</label>
<div class="pure-u-1-4 pure-u-lg-1-5">
<input class="pure-u-2-3" name="schHour" type="number" min="0" step="1" max="23" />
<div class="pure-u-1-4 hint center"> h</div>
<div class="pure-u-1-4 hint center">&nbsp;h</div>
</div>
<div class="pure-u-1-4 pure-u-lg-1-5">
<input class="pure-u-2-3" name="schMinute" type="number" min="0" step="1" max="59" />
<div class="pure-u-1-4 hint center"> m</div>
<div class="pure-u-1-4 hint center">&nbsp;m</div>
</div>
<div class="pure-u-0 pure-u-lg-1-3"></div>
@ -1095,7 +1095,7 @@
<div class="pure-u-2-5 pure-u-lg-1-5">
<input class="pure-u-23-24 pure-u-lg-23-24" name="schWDs" type="text" maxlength="15" tabindex="0" value="1,2,3,4,5,6,7" />
</div>
<div class="pure-u-3-5 pure-u-lg-1-2 hint center">1 for Monday, 2 for Tuesday...</div>
<div class="pure-u-3-5 pure-u-lg-1-2 hint center">&nbsp;1 for Monday, 2 for Tuesday...</div>
<label class="pure-u-1 pure-u-lg-1-4">Action</label>
<div class="pure-u-1 pure-u-lg-1-5">
@ -1108,6 +1108,9 @@
<select class="pure-u-1 pure-u-lg-1-5 isrelay" name="schSwitch"></select>
<div class="pure-u-0 pure-u-lg-1-5"></div>
<label class="pure-u-1 pure-u-lg-1-4">Enabled</label>
<div class="pure-u-1 pure-u-lg-3-4"><input type="checkbox" name="schEnabled" /></div>
<div class="pure-u-0 pure-u-lg-1-4"></div>
<button class="pure-button button-del-schedule" type="button">Delete schedule</button>


Loading…
Cancel
Save