Light relay turn on with sunset and turn off with sunrise

@Ze_Pico Ah, ok. The temporary fix for seconds is:

Brazil = 4294952896
Mnus 2 to the power 32 = -4294967296
= -14400
= -4 hours

1 Like

@Dmitriy simple mode is fine right across GMT+14 to GMT -12.

@Dmitriy
your choice was for the simple time input where there is no time zone
but here we are discussing the advance time input sketch.

 BLYNK_WRITE(V1) {
  TimeInputParam t(param);

  // Process start time

  if (t.hasStartTime())
  {
    Serial.println(String("Start: ") +
                   t.getStartHour() + ":" +
                   t.getStartMinute() + ":" +
                   t.getStartSecond());
  }
  else if (t.isStartSunrise())
  {
    Serial.println("Start at sunrise");
  }
  else if (t.isStartSunset())
  {
    Serial.println("Start at sunset");
  }
  else
  {
    // Do nothing
  }

  // Process stop time

  if (t.hasStopTime())
  {
    Serial.println(String("Stop: ") +
                   t.getStopHour() + ":" +
                   t.getStopMinute() + ":" +
                   t.getStopSecond());
  }
  else if (t.isStopSunrise())
  {
    Serial.println("Stop at sunrise");
  }
  else if (t.isStopSunset())
  {
    Serial.println("Stop at sunset");
  }
  else
  {
    // Do nothing: no stop time was set
  }

  // Process timezone
  // Timezone is already added to start/stop time

  Serial.println(String("Time zone: ") + t.getTZ());

  // Get timezone offset (in seconds)
  Serial.print(String("Time zone offset: ") + t.getTZ_Offset()/3600);
  Serial.println(String(" Hour(s)"));

  
  // Process weekdays (1. Mon, 2. Tue, 3. Wed, ...)

  for (int i = 1; i <= 7; i++) {
    if (t.isWeekdaySelected(i)) {
      Serial.println(String("Day ") + i + " is selected");
    }
  }

  Serial.println();
}

there is a tz in simple mode, param[4].
I’m sure @Dmitriy knows the problem with the advanced mode.

thanks, you are correct.

Should work now on master branch

@vshymanskyy
hi,
same as before
on local and cloud servers
“simple time input” is OK but not the “advance time input” sketch.

[19553] Ready (ping: 0ms).
Start at sunrise
Stop at sunrise
Time zone: Pacific/Samoa
Time zone offset: 4294927696
Day 4 is selected

You have to use latest version from github

@vshymanskyy
i tested it from
https://github.com/blynkkk/blynk-library/tree/master/examples/Widgets/TimeInput/AdvancedTimeInput
this example is for arduino, i adjusted it for nodeMCU
the result is same as above
I don’t know what am i missing?

@Ze_Pico I think what @vshymanskyy is saying is you need the Blynk library from the master not an example sketch.

yes Costas you are write.
i thought i was using the latest library 0.4.6 but I found new modification from 3 days
thanks Costas

@vshymanskyy
thanks a lot.

one more favour can you pls. find for me a simple sketch for activating an output on sunset and deactivating it on sunrise, as all sketches I found are long and complex.

@Ze_Pico look up the TimeLord.h or the SunLight.h libraries for your local sunrise and sunset times to use alongside the TimeInput widget.

I tested it before (post:33) 4 inputs are required and they all affect the result.

I hope I can find a simple algorithm handling all variables.