[Solved] Terminal is working only with opened application?

I have sonoff itead, so I’m using it to check some devices with ping.
So, I need to swith off and then on for 30 seconds.

First, I made (V10) button to turn on and turn off the relay, and (V6) to
get how many pings are failed. Looking good.

    BLYNK_READ(V6) { 
      Blynk.virtualWrite(6, numberOfPingsFailed);
    }

    BLYNK_WRITE(V10) {
      int virtualV10ButtonValue = param.asInt(); //? HIGH : LOW;
      if (virtualV10ButtonValue == LOW) {
        digitalWrite(RELAY_PIN, LOW);
        terminal.println("Relay 1 was set to:OFF");
      }
      else {
        digitalWrite(RELAY_PIN, HIGH);
        terminal.println("Relay 1 was set to:ON");
      }
    }

Then I failed. I used the EVENTOR block, so I can switch relay (V10), but I can’t make the EVENTOR make something like this:

  1. If (V6)(number of failed pings) more then 5 set (V10)(button) to 0. - This is working.
  2. Second is to make 30 second sleep, then set (V10) to 1. - can’t do this.

Ok, I made terminal (V4) to send command there.

    BLYNK_WRITE(V4) {
     if (String("reboot") == param.asStr()) {
        reboot_device();
      }
      else if (String("reset30sec") == param.asStr()) {
        digitalWrite(RELAY_PIN, !digitalRead(RELAY_PIN));
        numberOfPingsFailed = 0;
        Blynk.virtualWrite(6, numberOfPingsFailed);
        Sleep(30000)
        digitalWrite(RELAY_PIN, !digitalRead(RELAY_PIN));
      }
    else  {
        terminal.print("Unknown command:");
        terminal.write(param.getBuffer(), param.getLength());
        terminal.println();
      }
      terminal.flush();
    }

So, i ve got two problems:

1.When I make EVENTOR to send command “reset30sec” to (V4)(terminal) if (V6) is more than 5 - this is working only if my android application on my phone is open. Otherwise it do nothing. So, if my android apllication on my phone is closed - terminal is sleeping?

2.Second, when in my android application(it is open) I make EVENTOR to send command “reboot”, on some conditions, so it send and my sonoff rebooting. But than, when it boot, it get sended command “reboot” again from the terminal, so it reboot again and looping. Is it because of blynk.syncall function I’m using?

    BLYNK_CONNECTED() {
      if (isFirstConnect) {
        Blynk.syncAll();
        isFirstConnect = false;
      }
    }

So,I make like this in my BLYNK_WRITE(V4) function:

    if (String("reboot") == param.asStr()) {
        terminal.print("rebooting")
        reboot_device();
      }

Now, my device answer “rebooting” to the terminal, then reboot, after rebooting read his own “rebooting” as a command ans answer “Unknown command:”. It is working, but not in the propper way.

@pavel.1632 BLYNK_READ commands are working only when app is open. This is mostly done to decrease load on server side. However, I believe someday in future this will be fixed. But for now we have what we have.

Probably - yes. Blynk.syncAll(); triggers latest state for all pins and same “reboot” command comes again so you are rebooted again.

I wrote message about BLYNK_READ, but then tried to use blynkwrite with push - it is working.

    void timerLoop30sec(void) {

      if (BLYNK_ENABLED && Blynk.connected()) {
    if (getTempFromFirstSensor)  {
      Blynk.virtualWrite(3, getTempFromFirstSensor());
     if (PINGCHECK_ENABLED) Blynk.virtualWrite(6, numberOfPingsFailed);
    }
      }
    }

So it work with terminal. I was totally upset that it is not possible to do it without application opened, but then decide to reread blynk docs. Dmitry - you would have to write “use push instead of BLYNK WRITE”, but thank you nonethless.

I think we will fix that very soon. As BLYNK_READ really simplify things,