I modify All_days function. For now work, but still testing
BLYNK_WRITE(V8)//All days
{
if (alldays==1) {
sprintf(Date, "%02d/%02d/%04d", day(), month(), year());
sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
TimeInputParam t(param);
terminal.print("All Days Checked schedule at: ");
terminal.println(Time);
terminal.flush();
int dayadjustment = -1;
if(weekday() == 1){
dayadjustment = 6; // needed for Sunday, Time library is day 1 and Blynk is day 7
}
if(t.isWeekdaySelected(weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
terminal.println("ALL DAYS ACTIVE today");
terminal.flush();
if (t.hasStartTime()) // Process start time
{
terminal.println(String("Start: ") + t.getStartHour() + ":" + t.getStartMinute());
terminal.flush();
}
if (t.hasStopTime()) // Process stop time
{
terminal.println(String("Stop : ") + t.getStopHour() + ":" + t.getStopMinute());
terminal.flush();
}
// Display timezone details, for information purposes only
terminal.println(String("Time zone: ") + t.getTZ()); // Timezone is already added to start/stop time
// terminal.println(String("Time zone offset: ") + t.getTZ_Offset()); // Get timezone offset (in seconds)
terminal.flush();
for (int i = 1; i <= 7; i++) { // Process weekdays (1. Mon, 2. Tue, 3. Wed, ...)
if (t.isWeekdaySelected(i)) {
terminal.println(String("Day ") + i + " is selected");
terminal.flush();
}
}
nowseconds = ((hour() * 3600) + (minute() * 60) + second());
startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
//Serial.println(startsecondswd); // used for debugging
if(nowseconds >= startsecondswd){
terminal.print("ALL DAYS STARTED at");
terminal.println(String(" ") + t.getStartHour() + ":" + t.getStartMinute());
terminal.flush();
if(nowseconds <= startsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
digitalWrite(pompa, LOW); // set LED ON
Blynk.virtualWrite(V2, 1);
// code here to switch the relay ON
}
}
else{
terminal.println("All Day Device NOT STARTED today");
terminal.flush();
}
stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
//Serial.println(stopsecondswd); // used for debugging
if((nowseconds >= stopsecondswd) && (stopsecondswd>startsecondswd)){
digitalWrite(pompa, HIGH); // set LED OFF
Blynk.virtualWrite(V2, 0);
terminal.print("All day STOPPED at");
terminal.println(String(" ") + t.getStopHour() + ":" + t.getStopMinute());
terminal.flush();
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
digitalWrite(pompa, HIGH); // set LED OFF
Blynk.virtualWrite(V2, 0);
// code here to switch the relay OFF
}
}
else{
if(nowseconds >= startsecondswd){
digitalWrite(pompa, LOW); // set LED ON TEST!!!!!
Blynk.virtualWrite(V2, 1);
terminal.println("All day is ON");
terminal.flush();
}
}
if((nowseconds >= stopsecondswd) && (stopsecondswd<startsecondswd) && (nowseconds<startsecondswd)){
digitalWrite(pompa, HIGH); // set LED OFF
Blynk.virtualWrite(V2, 0);
terminal.print("All day STOPPED at");
terminal.println(String(" ") + t.getStopHour() + ":" + t.getStopMinute());
terminal.flush();
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
digitalWrite(pompa, HIGH); // set LED OFF
Blynk.virtualWrite(V2, 0);
// code here to switch the relay OFF
}
}
}
else{
terminal.println("All day INACTIVE today");
terminal.flush();
// nothing to do today, check again in 30 SECONDS time
}
terminal.println();
}
}
Output is revert for my relay