Time input widget stop time inability?

Dear @Dmitriy @vshymanskyy
I am observing one possible Time input widget inability or perhaps bug. Let me describe in order to replicate and test:
( I use 0.3.9 library and Latest Android Blynk application 1.15.2 )
Using the Time input widget in two cases,
(1) Using/setting Both Start Time ( START AT ) and Stop Time ( STOP AT )
(2) using only the Stop Time ( STOP AT ) with Start Time ( START AT ) in this case reseted to --:–

The (1) is working just fine, pressing OK at the widgets Set the time page the values are coming to my sketch as it should.

The (2) case is not working or partially working… If I select START AT and I put any time and STOP AT my preference then the values are coming to my sketch as it should, even if I put the START AT to reset value --:-- ( after first selecting any value )
If ( new setting ) I leave or select START AT --:-- and put my preference at STOP AT then the values did not come to my sketch, And that is the reported problem.

Please check by yourself and let me know.

Thanks and Best Regards,
Mike Kranidis

@Dmitriy I can confirm a similar situation.

With START AT - Sunrise and STOP AT Sunset all fine as:

Checked schedule at: 17:38:18
Sunrise: 6:28
Start Sunrise seconds is: 23280
Sunset: 18:34
Stop Sunset seconds is: 66840
Schedule ACTIVE today
Time zone: Europe/Nicosia
Time zone offset: 10800
Day 6 is selected
23280
Motor STARTED at sunrise
66840
Motor is still RUNNING

But problems occur with --:–

Is some signal / data sent when --:-- is selected and if so what is the variable?

We have t.hasStartTime() and t.hasStopTime() but they don’t appear to cover the reset time of --:–

That’s correct. We thought it is logical to always expect input for startAt. We will fix.

1 Like

@Dmitriy
Thanks a lot Dmitriy. It is more convenient not to demand START AT in order to have working the STOP AT because in this case if you implement a timer like I did, you can specify only a working stop function based to STOP AT time setting independent to ( not setted ) START AT setting…

Best Regards,
Mike Kranidis

Dear Dmitriy,
All my Time input widgets stopped working a few minutes ago and I did not change anything to my setup (sw / hw). Did you change something server wise?
Thanks

@mikekgr is it the first time you have used TimeInput today (Sunday)?

Time library is day 1 and Blynk is day 7.

Earlier today I found a bug in my code. I was taking 1 off the Time Library day to match Blynk days and this is fine but not on a Sunday.

My fix is:

  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
....... 

Previously I just had:

if(t.isWeekdaySelected((weekday() -1)){ //Time library starts week on Sunday, Blynk on Monday

2 Likes

@mikekgr no changes on server. Look like @Costas is right.

1 Like

Yes that is probably the problem because I running your code.
Thanks Costas!

1 Like

I did update my code on this site earlier today.

1 Like

@mikekgr fixed. Please check with latest Blynk app.

I can test it in 2-3 hours and I will let you know.

Thanks!

@Dmitriy
Yes this problem solved.
Congrats !

@Costas
Dear Costas, can you check the time input widget because after a restart of my WeMos, without touching the sketch, I can not use the time input widget. Something bad happens to my sketch, blynk server, latest update of app or black magic…
Thanks

@mikekgr I updated the app earlier today and all is fine here.

did you check recently?

60 seconds ago.

ok then, I have to start hunding the poke… ammmm the bug !
Thanks

@Costas
Good morning Costas. I hope that your are fine today.

I still hunter my problem / bug. Till yesterday evening, I had no problem using the following sketch ( actually the part of my sketch that is relevant ). After the Android application update and possible Blynk public server update, the problem started. The problem is that this routine NEVER activate or de-activate the RL1 or RL2 (Relay 1 , Relay 2). Can you find why? I state again, without touching my code (sketch)…
Thanks Costas.

/// Relay 1 (RL1): gp12 <--> virtual switch V16 for manual activation or by timer, ///
/// Relay 2 (RL2): gp13 <--> virtual switch V17 for manual activation or by timer  ///
/// START of Timer1 function for V21 Time Input widget ///

long start1secondswd ;
long stop1secondswd ;
long now1seconds ;

/// RL1 or RL2 for Timer 1 selection for Virtual Switch V31 ///
/// V31Timer if false => RL1, true => RL2 ... ///
bool V31Timer = false :

/// Check timers for activetoday ? function ///
  timer.setInterval(15000L, activetoday);  // check every 15 seconds if schedule should run today 

/// START of activetoday function check every 15 seconds if schedule should run today ///
void activetoday(){        // check if schedule should run today
  {
    Blynk.syncVirtual(V21); // sync timeinput widget
    }
}
/// END of activetoday function ///


BLYNK_WRITE(V21)
{
 TimeInputParam t(param);
 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
   now1seconds = ((hour() * 3600) + (minute() * 60) + second());
   start1secondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
   if(now1seconds >= start1secondswd){
    if(now1seconds <= start1secondswd + 40 ){ 
     if(V31Timer == true){ /// V31 Virtual switch widget to select RL1 or RL2 for Timer 1 V31 /// /// RL1 activation ///
       digitalWrite(12,HIGH);
       Blynk.virtualWrite(V16, (digitalRead(12)));
     } else { /// V31 Virtual switch widget to select RL1 or RL2 for Timer 1 V31 /// /// RL2 activation ///
           digitalWrite(13,HIGH);
           Blynk.virtualWrite(V17, (digitalRead(13)));
        }
    }
   }
   stop1secondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
   if(now1seconds >= stop1secondswd){
    if(now1seconds <= stop1secondswd + 40){   // 40s on 20s timer ensures 1 trigger command is sent
     if(V31Timer == true){ /// RL1 de-activation ///
      digitalWrite(12,LOW);
      Blynk.virtualWrite(V16, (digitalRead(12)));
     } else { /// RL2 de-activation ///
         digitalWrite(13,LOW);
         Blynk.virtualWrite(V17, (digitalRead(13)));
        }
    }
   }
 }
}
/// END of Timer1 function for V21 ///

@mikekgr all good here. I’ll take a look at your code now.

First compilation error is bool V31Timer = false : needs to be bool V31Timer = false ;

@mikekgr looks ok here. I set ON at 11:47 and OFF at 11.48 with the 15s timer reduced to 5s (to speed up testing). Added some Serial.println()'s and #define TestLED 2 (for ESP onboard LED). LED came on and went off as expected and the Serial Monitor showed the following:

Time now in seconds is 42408
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42413
[305599] Time sync: OK
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42417
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42422
GP13 HIGH
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42427
GP13 HIGH
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42432
GP13 HIGH
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42437
GP13 HIGH
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42442
GP13 HIGH
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42447
GP13 HIGH
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42452
GP13 HIGH
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42457
GP13 HIGH
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42462
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42467
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42472
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42477
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42482
GP13 LOW
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42487
GP13 LOW
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42492
GP13 LOW
Running V21
Day 2 is selected
Time library adjusted day number is 2
Time now in seconds is 42497
GP13 LOW